TypeError:无法读取属性';发送';未定义discord.js v12的
我有一个反应-角色系统,从最后一部分到最后一部分TypeError:无法读取属性';发送';未定义discord.js v12的,discord.js,Discord.js,我有一个反应-角色系统,从最后一部分到最后一部分 async run(message, client, con) { await message.channel.send("Give the color for the embed.") answer = await message.channel.awaitMessages(answer => answer.author.id === message.author.id,{max:
async run(message, client, con) {
await message.channel.send("Give the color for the embed.")
answer = await message.channel.awaitMessages(answer => answer.author.id === message.author.id,{max: 1});
var color = (answer.map(answers => answers.content).join()).toUpperCase()
if(color.toUpperCase()==='CANCEL') return (message.channel.send("The Process Has Been Cancelled!"))
function embstr(){
var finalString = '';
for(var i =0;i<n;i++){
finalString += b[i]+ ' - '+a[i] +'\n';
}
return finalString;
}
const botmsg = message.client.channels.cache.get(channel => channel.id === reactChannel)
const embed = new MessageEmbed()
.setTitle(embtitle)
.setColor(color)
.setDescription(embstr());
botmsg.send(embed);
message.channel.send("Reaction Role has been created successfully")
.get()
方法将雪花作为其参数。也就是某个对象的ID。它不是一个迭代器,这意味着您当前尝试执行的是不正确的JavaScript操作
我们不需要传入一个参数来表示通道对象,而只需要传入我们想要获取的通道ID。或者,您可以将.get()
替换为那里的.find()
,它实际上是一个使用这种回调形式的迭代器,尽管考虑到我们可以只使用.get()
,这在涉及ID时更准确,但在我们的案例中是不够的
/**
*代码不足:
*const botmsg=message.client.channels.cache.find(channel=>channel.id==reactChannel)
*/
const botmsg=message.client.channels.cache.get(reactChannel/*假设reactChannel表示通道ID*/)
{
"stack": "TypeError: Cannot read property 'send' of undefined
at SlowmodeCommand.run (B:\\stuff\\Downloads\\Admeeeeeen bot\\src\\commands\\reactionroles\\createreactionrole.js:100:22)
at processTicksAndRejections (node:internal/process/task_queues:93:5)"
}