如果命令在错误的通道中执行,则返回

时间:2020-06-05 01:47:53

标签: discord.js

如果命令是在错误的通道中执行的,则漫游器应检测到该命令,然后return message.reply("wrong channel")

使用下面的代码,我想使bots channel成为机器人运行其命令的主要渠道

代码:

if(!message.guild.channels.cache.find(channel => channel.name === "bots")) return message.reply("wrong channel")

代码不起作用。

1 个答案:

答案 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")

希望这会有所帮助。