如果命令是在错误的通道中执行的,则漫游器应检测到该命令,然后return message.reply("wrong channel")
使用下面的代码,我想使bots channel
成为机器人运行其命令的主要渠道
代码:
if(!message.guild.channels.cache.find(channel => channel.name === "bots")) return message.reply("wrong channel")
代码不起作用。
答案 0 :(得分:1)
我设法找到一个问题并加以解决。
旧代码:
{
"registration_ids":["device token"],
"content_available": true,
"notification" : {
"force-start": "1",
"content-available": "1",
"no-cache": "1",
"body":"Test" ,
"title" : "Test",
"sound" : "default" ,
"icon":"default",
"badge": 56
},
"data": {
"force-start": "1",
"content-available": "1",
"no-cache": "1",
"body":"Test" ,
"title" : "Test",
"sound" : "default" ,
"icon":"default",
"badge": 56
},
"priority":10
新代码:
if(!message.guild.channels.cache.find(channel => channel.name === "bots")) return message.reply("wrong channel")
希望这会有所帮助。