未定义发送(建议命令)

Send is not defined (suggest command)

TypeError: Cannot read property 'send' of undefined我做错了什么?我不明白我应该在哪里定义它。可能只是我忘了一件愚蠢的事情。我将不胜感激 improvements/suggestions.

module.exports = {
    name: 'suggest',
    aliases: ['sug', 'suggestion'],
    description: 'Suggest something for the Bot',
    execute( client, message, args) {
        const filter = m => m.author.id === message.author.id;
        message.channel.send(Suggest something for the Bot or send "cancel" to cancel the suggestion)
        message.channel.awaitMessages(filter, {max: 1,})
            .then(async(collected) => {
                if (collected.first().content.toLowerCase() == 'cancel') {
                message.reply("The suggestion has been cancelled.")
                } 
                else { client.channels.get("702825446248808519").send(collected.first().content)
                    message.channel.send(Your suggestion has been sent)
                }
            })
    },
    catch (err) {
        console.log(err)
    }
};
message.channel.send(Suggest something for the Bot or send "cancel" to cancel the suggestion) 

这是行不通的,使用此代码您正在尝试发送一个不存在的 var,我猜您正在尝试发送文本,因此它应该如下所示:

message.channel.send('Suggest something for the Bot or send "cancel" to cancel the suggestion')

这里也一样:

message.channel.send(Your suggestion has been sent)

变成:

message.channel.send('Your suggestion has been sent')

此外,如果您使用的是 discord.js v12,请将 client.channels.get 更改为 client.channels.cache.get

希望对您有所帮助