discord.js - 如何修复 UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Channel
问题描述
我只会读这个频道,但它出错(节点:17212)UnhandledPromiseRejectionWarning:DiscordAPIError:未知频道
我的代码
client.on('message', async message => {
if(message.channel.name.includes("Command-only")){
message.channel.bulkDelete("1", true);
if(!message.author.bot){
message.channel.send("Test, you say :" + `${message.content}`);
}
}
})
解决方案
您的机器人正在阅读所有发送给它的消息,包括没有名称的 DM。您应该过滤掉 dm 频道。
if(message.channel.type === 'dm') return;
推荐阅读
- node.js - '包'nodejs'未安装,因此未删除'Ubuntu 18.04
- java - Zuul 网关服务器未显示任何路由
- javascript - Javascript - UTC 时间与本地时间转换
- reactjs - 在 ReactWebChat 中使用 renderMarkdown 和实际写入 DOM 之间会发生什么?
- pytorch - 在pytorch中广播元素明智的乘法
- flutter - 如何在 Dart 中使用 StreamZip 合并流
- python - 使用 Wget 时如何正确解析 Web 链接以避免 403 错误?
- mediawiki - 英语维基词典 API:输出中缺少变格表
- android - 如何在对话框中显示 recyclerVIew?
- linux - 将 C 语言中的 Linux 系统调用表重写为程序集