【问题标题】:Is there a way to return who deleted a message (Discord Bot Development)有没有办法返回谁删除了一条消息(Discord Bot Development)
【发布时间】:2021-03-13 01:19:17
【问题描述】:

我的 discord 机器人目前正在我的 discord 服务器中记录已删除的消息。但是,它也与我的机器人的其他一些代码冲突。为了解决这个问题,我该如何返回在公会中删除消息的用户?我正在使用 messageDelete 事件。

这是我的代码,但这并不重要,因为这是一个更通用的问题:

bot.on('messageDelete', msg => {

    if (!msg.partial) {
        const channel = bot.channels.cache.get('781032825050759229');
        if (channel) {
            const MessageDeletedByUser = new Discord.MessageEmbed()
                .setColor('YELLOW')
                .setThumbnail(msg.author.avatarURL(msg.author.defaultAvatarURL))
                .addField(msg.author.tag + " (MESSAGE DELETED)", ":warning:** <@" + msg.author.id + ">" + "'s message was deleted by the user**\n ")
                .addField("\n:speaking_head: Full Message :speaking_head:", "- " + msg.content)
                .addField("\n\n:newspaper: Message Info :newspaper: ", "\n- Channel ID: " + msg.channel + ' [' + "<#" + msg.channel.id + ">" + "]" + "\n- User ID: " + msg.author.id + " [" + "<@" + msg.author.id + ">" + "]")
                .addField(msg.author.id, 'hello')
                .setTimestamp()
                .setFooter('--Depressed Children--');

            channel.send(MessageDeletedByUser)
            msg.channel.send(msg.attachments)

        }
    }
}

);

任何可靠的答案将不胜感激!

【问题讨论】:

  • 请出示您的代码好吗?
  • 我刚刚编辑了我的帖子,代码就在那里
  • 不,不可能

标签: javascript discord.js


【解决方案1】:

这是不可能的。 Message 对象没有属性表明它是由谁删除的,正如您在 Message docs 中看到的那样。

another StackOverflow response 中,用户使用了审核日志。它不是很可靠,但它可以工作。

【讨论】:

    猜你喜欢
    • 2023-04-10
    • 2021-10-18
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 2021-01-28
    • 2021-10-08
    • 2021-06-20
    • 2020-12-03
    相关资源
    最近更新 更多