繁体   English   中英

来自所有通道的阻塞命令 Discord.js

[英]Blocking commands from all channels Discord.js

我正在寻找阻止来自 discord 服务器中每个通道的用户命令。 我希望这些命令只能通过私人聊天执行。 我正在使用 Discord.js 的最新版本,但我不知道该怎么做。

client.on("message", (message) => {
    if (message.guild) {return false}; // The message was sent in a guild. return false will prevent the code below from running.

    
    // The message was sent in DMs. You can execute your commands here.
});

您可以检查if (message.channel.type;= 'dm') return; 完全忽略在服务器中发送的所有消息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM