首页 > 解决方案 > 如果机器人没有发送消息的权限,我怎么能不收到错误消息?

问题描述

我的代码中有,但是当我禁用机器人发送消息if (!message.guild.me.hasPermission("SEND_MESSAGES")) return;的权限时,它给了我一个错误,. 我怎么可能解决这个问题,所以当我的机器人无法将消息发送到聊天中时我不会收到错误消息。(node:2504) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions

标签: javascriptnode.jsbotsdiscorddiscord.js

解决方案


在消息事件之前执行此操作

尝试这个:

if (message.author.bot) {
 return;
} else {
 //do soemthing if user is not a bot
}

推荐阅读