我不理解我的代码有什么问题...
用法:
/建议
机器人将建议发送到名为Sugestations的频道 这是meh代码:
if(cmd === `${prefix}suggest`){
// USAGE:
// /suggest this is the suggestion
let suggestion = args.join(" ").slice(22);
let suggestEmbed = new Discord.RichEmbed()
.setDescription("~~-------~~**__NEW SUGGESTION!__**~~-------~~")
.setColor("#ff0000")
.addField("Suggestion By", `${message.author} (${message.author.id})`)
.addField("Channel", message.channel)
.addField("Time", message.createdAt)
.addField("Suggestion", suggestion)
.setTimestamp()
.setFooter("Use /invite to invite me to your server!");
let suggestchannel = message.guild.channels.find(`name`, "suggestions");
if(!suggestchannel) return message.channel.send("Couldn't find suggestions channel. Please **create one for this command to work!**");
message.delete().catch(O_o=>{});
suggestchannel.send(suggestEmbed);
return;
}
答案 0 :(得分:0)
您在代码行suggestchannel.send(...)
中犯了一个错误。您不能将嵌入内容作为消息内容发送,因为该必须是字符串。
在这里您可以找到有关此的更多信息:https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=send
这是已更正的代码,请尝试使用以下代码:
if (cmd === `${prefix}suggest`) {
// USAGE:
// /suggest this is the suggestion
const suggestion = args.join(' ').slice(22);
const suggestEmbed = new Discord.RichEmbed()
.setDescription('~~-------~~**__NEW SUGGESTION!__**~~-------~~')
.setColor('#ff0000')
.addField('Suggestion By', `${message.author} (${message.author.id})`)
.addField('Channel', message.channel)
.addField('Time', message.createdAt)
.addField('Suggestion', suggestion)
.setTimestamp()
.setFooter('Use /invite to invite me to your server!');
const suggestchannel = message.guild.channels.find(`name`, 'suggestions');
if (!suggestchannel) return message.channel.send("Couldn't find suggestions channel. Please **create one for this command to work!**");
message.delete().catch(O_o => {});
suggestchannel.send({ embed: suggestEmbed });
}