discord.js - 从特定频道中的特定消息中删除所有反应
问题描述
// remove reactions from sign up message
command(client, 'noreactions', message => {
client.channels.cache.get(channelBotTest).fetch(messageWSSignUp).reactions.removeAll().catch(error =>
console.error('Failed to clear reactions: ', error)
);
})
到目前为止,这是我的代码。我希望能够在私人频道中运行一个命令,该命令将删除特定频道中特定消息的所有反应。
收到此错误:TypeError:无法读取未定义的属性“removeAll”
我不确定是否也需要定义频道?
请帮忙。
谢谢
解决方案
fetch()
返回一个Promise而不是立即返回值。要从 Promise 中获取消息对象,您可以使用.then()
回调或await
关键字。
command(client, 'noreactions', message => {
client.channels.cache.get(channelBotTest).fetch(messageWSSignUp).then(fetchedMessage => {
fetchedMessage.reactions.removeAll().catch(error =>
console.error('Failed to clear reactions: ', error)
)
}).catch(err => console.log('failed to fetch the message'))
})
推荐阅读
- python - 如何索引这个 csv 文件?
- javascript - 当可以随机删除它们时如何跟踪通过单击复选框创建的表行的ID
- python - python mpmath nstr 不带零
- javascript - iPhone 上的 Chrome 溢出空白页面上的内容(仅在新标签上,不重新加载)
- java - Spring Boot - 在一个类中拥有所有自动装配的配置变量
- python-3.x - 使用 unittest 模块测试 Flask 微服务
- ios - 如何直接从 iOS 共享表打开我的应用程序?嘿
- javascript - Javascript/NodeJS 中的协议缓冲区字段选项
- r - 索引匹配就像在 excel 中一样,但在 R 中按两列。两个不同的数据框
- post - 将 ESP32 CAM 拍摄的图像发布到 Clarifai 不起作用