send is not defined

烈酒焚心 提交于 2020-04-30 06:28:17

问题


I don't get how to fix the TypeError Cannot read property 'send' of undefined This is caused by the line where I get the channel 702825446248808519

module.exports = {
    name: 'suggest',
    aliases: ['sug', 'suggestion'],
    description: 'Suggest something for the Bot',
    execute(client, message) {
        const filter = m => m.author.id === message.author.id;

        message.channel.send(`Please provide a suggestion for the Bot or cancel this command with "cancel"!`)

        message.channel.awaitMessages(filter, { max: 1, })
            .then(async (collected) => {
                if (collected.first().content.toLowerCase() === 'cancel') {
                    message.reply("Your suggestion has been cancelled.")
                }
                else {
                    const embed = new RichEmbed()
                        .setFooter(client.user.username, client.user.displayAvatarURL)
                        .setTimestamp()
                        .addField(`New Suggestion from:`, `**${message.author.tag}**`)
                        .addField(`Suggestion:`, `${collected.first().content}\n**Its your choice!**`)
                        .setColor('0x0099ff');
                    client.channels.get("702825446248808519").send(embed)

                    message.channel.send(`Your suggestion has been filled to the staff team. Thank you!`)
                }
            })
    },
    catch(err) {
        console.log(err)
    }
};

回答1:


.get() is not a method for ChannelManager, you need to use .fetch()

So your line client.channels.get("702825446248808519").send(embed) needs to be replaced with client.channels.fetch("702825446248808519").send(embed)



来源:https://stackoverflow.com/questions/61464984/send-is-not-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!