[英]Blocking commands from all channels Discord.js
i'm looking for blocking user's commands from every channel in the discord server.我正在寻找阻止来自 discord 服务器中每个通道的用户命令。 I want the commands to be executable only by private chat.
我希望这些命令只能通过私人聊天执行。 I'm using last version of Discord.js but i have no idea how to do this.
我正在使用 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.
});
You could just check if (message.channel.type;= 'dm') return;
您可以检查
if (message.channel.type;= 'dm') return;
to completely ignore all messages that are sent in a server.完全忽略在服务器中发送的所有消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.