Discord 我得到一个错误,如果它说我的参数没有定义

Discord 我得到一个错误,如果它说我的参数没有定义,discord,discord.js,Discord,Discord.js,这是我在arg中得到的错误,第二个代码块是我的命令代码。它应该做LTM!C当我用另一个命令处理程序安装它时,它正在工作,但它应该仍然可以工作。最后一个是我的命令处理程序。 错误: 代码: 我找到了答案。我没有通过命令处理程序传递args。是否将args传递到命令文件?让我们看看你的命令handler@Toasty我把命令处理程序放在了。它和命令放在了同一个位置,就在下面 let channelName = args[0]; ^ Typ

这是我在arg中得到的错误,第二个代码块是我的命令代码。它应该做LTM!C当我用另一个命令处理程序安装它时,它正在工作,但它应该仍然可以工作。最后一个是我的命令处理程序。 错误:

代码:


我找到了答案。我没有通过命令处理程序传递args。

是否将
args
传递到命令文件?让我们看看你的命令handler@Toasty我把命令处理程序放在了。它和命令放在了同一个位置,就在下面
let channelName = args[0];
                              ^

TypeError: Cannot read property '0' of undefined
        let channelName = args[0];
        let channelTime = args[1];
        if(!channelTime) return message.channel.send(" no time")
        if(!channelName) return message.channel.send("no name") // YOu can edit this with embeds etc
        let msTime = ms(channelTime);

        const categoryID = message.member.guild.channels.cache.find(c => c.id == `850420491915493387`) //add category id

        if (!categoryID) return message.channel.send('No Category made!')
        message.guild.channels.create(channelName, { type: 'text' }).then(
            (createdChannel) => {

                createdChannel.setParent(categoryID).then(
                    (settedParent) => {

                        settedParent.updateOverwrite(message.guild.roles.cache.find(x => x.name === '@everyone'), {
                            SEND_MESSAGES: false,
                            VIEW_CHANNEL: false  // YOu can make this public or private channel by making false or true
                        });

                        setTimeout(() => {
                            const deleted = message.guild.channels.cache.find(channel => channel.name.toLowerCase() === args[0])
                            deleted.delete()  

                        }, msTime)
                    }
// IGnore these ones its just for error bs
                ).catch(err => {
                    // if err console err
                    return console.log(err)
                });
            }
        ).catch(err => {
// if err console err
            return console.log(err)
        });
    })```



Cmd Handler:
const { prefix } = require('./config.json')

module.exports = (client, aliases, callback) => {
    if (typeof aliases === 'string') {
        aliases = [aliases]
    }

    client.on('message', (message) => {
        const { content } = message

        aliases.forEach((alias) => {
            const command = `${prefix}${alias}`

            if (content.startsWith(`${command} `) || content === command) {
                console.log(`Running the command ${command}`)
                callback(message)
            }
        })
    })
}