我正在制作一个 Discord 机器人,并希望使其只能在 1 个特定 channel 上发布。我不能让它的 Angular 色比普通成员(member)低,否则就无法给他们 Angular 色。
我尝试了基于 channel ID 的 if/else 语句。
case 'start':
if (message.channel === 615842616373805067) {
//somewhat unimportant command
return message.member.addRole('615166824849604619'),
message.channel.send(` ${message.author} has been given the role.)`,
message.delete);
//unimportant command ends here
} else {
console.log('Wrong channel, no role.')
}
我希望机器人只能在这一个 channel 中发帖。
最佳答案
不要检查 message.channel
类,而是尝试检查该类的 id
属性
if(message.channel.id != "615842616373805067") return console.log('Wrong channel, no role.');
//rest of your code
请务必检查official documentation有关每个类、方法、属性等的详细说明
关于javascript - 有没有一种方法可以将机器人绑定(bind)到一个特定的 channel ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57672630/