有没有一种方法可以将漫游器绑定到一个特定的频道?

时间:2019-08-27 10:24:19

标签: javascript discord discord.js

我正在制作Discord漫游器,并希望使其只能在1个特定频道上发布。我不能使它的角色不及普通成员低,否则将无法赋予他们角色。

我已经尝试根据通道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.')
}

我希望该漫游器只能在此一个频道中发布。

1 个答案:

答案 0 :(得分:3)

请尝试检查该类的message.channel属性,而不是检查id

if(message.channel.id != "615842616373805067") return console.log('Wrong channel, no role.');
//rest of your code

确保检查official documentation以获得每个类,方法,属性等的详细说明。

相关问题