【发布时间】:2018-07-14 23:46:30
【问题描述】:
为了测试,我试图停止所有命令,除非在某个频道中。我知道如何专门为每个命令执行此操作,但我试图在主 bot 文件中捕获它,并返回一条消息。到目前为止,我已经尝试了两种方法:
bot.on('command', async m => { (Also tried 'commandmessage')
console.log('COMMAND');
if (m.channel != 'bot-testing') {
return m.channel.send('You can\'t use commands here!');
}
});
这根本不起作用。然后我尝试了这个:
bot.on('message', async m => {
m.isDM = (m.guild ? false : true);
if (m.content[0] != bot.commandPrefix) {
return;
} else {
if (m.channel != 'bot-testing') {
m.channel.send('You can\'t use commands here!');
}
}
});
哪种有效,但不会停止命令。
【问题讨论】:
标签: node.js discord.js