【问题标题】:Removing all reaction from a specific message in a specific channel从特定频道中的特定消息中删除所有反应
【发布时间】:2021-04-21 08:38:24
【问题描述】:
// 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”

我不确定是否也需要定义频道?

请帮忙。

谢谢

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    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'))
    })
    

    【讨论】:

    • 谢谢!如果消息是嵌入的,这是否同样有效?如果没有,我应该如何改变它?
    • 按原样,我在控制台上收到“无法获取消息”。
    猜你喜欢
    • 2019-06-13
    • 1970-01-01
    • 2021-05-18
    • 2020-10-01
    • 1970-01-01
    • 2022-01-12
    • 1970-01-01
    • 2020-09-01
    • 2020-06-29
    相关资源
    最近更新 更多