javascript - 如果机器人没有发送消息的权限,我怎么能不收到错误消息?
问题描述
我的代码中有,但是当我禁用机器人发送消息if (!message.guild.me.hasPermission("SEND_MESSAGES")) return;
的权限时,它给了我一个错误,. 我怎么可能解决这个问题,所以当我的机器人无法将消息发送到聊天中时我不会收到错误消息。(node:2504) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
解决方案
在消息事件之前执行此操作
尝试这个:
if (message.author.bot) {
return;
} else {
//do soemthing if user is not a bot
}
推荐阅读
- reactjs - 将功能组件转换为类组件react js
- javascript - 固定 div 中的文本溢出
- c - 使用缓冲区溢出覆盖函数返回地址
- python - Python3.8:十进制整数文字中的前导零是不允许的;对八进制整数使用 0o 前缀
- c# - 如何在接口中调用带有主体的方法
- python - 为什么错误 asyncio.exceptions.TimeoutError
- ios - @Published 数组值未在 swiftUIView 中更新
- kubernetes - 如何从默认 kops 命令更改 kubernetes 上下文中的默认命名空间?
- css - Google Helvetica 字体未使用 css2 API 加载(403 错误)
- azure - 使用复制活动,如何从 datalake gen2 文件夹中捕捉一个月的最后一天文件并使用 ADF 将其存储到同一 datalake 中的另一个文件夹中?