我收到由client.user.username
的{{1}}中的embed
引起的错误.setFooter()
。
module.exports = {
name: 'suggest',
aliases: ['sug', 'suggestion'],
description: 'Suggest something for the Bot',
execute(message, client, args) {
const Discord = require('discord.js');
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 {
let embed = new Discord.MessageEmbed()
.setFooter(client.user.username, client.user.displayAvatarURL)
.setTimestamp()
.addField(`New Suggestion from:`, `**${message.author.tag}**`)
.addField(`New Suggestion:`, `${collected.first().content}`)
.setColor('0x0099ff');
client.channels.fetch("702825446248808519").send(embed)
message.channel.send(`Your suggestion has been filled to the staff team. Thank you!`)
}
})
},
catch(err) {
console.log(err)
}
};
答案 0 :(得分:1)
根据您的评论here
try {command.execute(message,args); } catch(错误){console.error(错误); message.reply('执行该命令时出错!'); }})
您没有将client
传递到execute()
中,您需要这样做。
您还需要在await
上使用channels.fetch()
,因为它会返回一个承诺,因此将client.channels.fetch("702825446248808519").send(embed)
替换为:
const channel = await client.channels.fetch("702825446248808519")
channel.send(embed)