阻止来自所有通道的命令不和谐.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;以完全忽略服务器中发送的所有消息。

最新更新