【发布时间】:2020-08-26 08:38:37
【问题描述】:
我正在做一个报告命令并得到这个错误
reportsChannel.send(`**${message.author.username}** has reported **${target.user.username}** for
^
**${reason}**.`);
TypeError: Cannot read property 'send' of undefined
仅当我在与存储所有报告的通道不同的服务器中时才会发生此错误
这是我的代码:
switch(args[0]){
case 'report':
let target = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
if(!target) return message.channel.send('Please provide a user that you wish to report').then(m => m.delete({timeout: 15000}));
var reason = args.slice(2).join(" ");
if(!reason) return message.channel.send(`Please provide a reason for reporting **${target.user.username}**`).then(m => m.delete({timeout: 15000}));
let reportsChannel = message.guild.channels.cache.find(x => x.id === "747697771594645566")
if(args[1] === target, args[2] === reason){
message.channel.send('Your report has been filled to the staff team. Thank you for reporting!')
reportsChannel.send(`**${message.author.username}** has reported **${target.user.username}** for **${reason}**.`);
}
break;
};
知道如何解决这个问题吗?谢谢
【问题讨论】:
标签: discord bots discord.js