【问题标题】:How do I make my discord bot delete it's own previous message sent?如何让我的不和谐机器人删除它自己之前发送的消息?
【发布时间】:2020-09-06 11:23:13
【问题描述】:

目前,我的机器人中有一个命令,它将对消息中带有discord.gg 的任何内容作出反应。我希望机器人能够在每次发布不和谐邀请时发布嵌入消息,但删除它发送的 last 嵌入消息,这样看起来机器人最后会保留一条特定消息的一个频道。

现在的代码是这样的,谢谢你的帮助!

let keyword15 = ["discord.gg"];
if (msg.author.bot) return;
if((msg.content.toLowerCase().includes(keyword15) )
){          
    const embed2 = new Discord.MessageEmbed()
    .setDescription('Promotion Operator \n ▫️ **Do not post outside the advertisement channel.** \n ▫️ **Do not advertise your server via DM.**')
    .setColor(0x000000)
    msg.channel.send(embed2);    
}

【问题讨论】:

    标签: discord discord.js


    【解决方案1】:

    我不知道如何删除最后一个嵌入,但我想出了另一个你可以尝试的解决方案。

    let keyword15 = ["discord.gg"];
    if (msg.author.bot) return;
    if((msg.content.toLowerCase().includes(keyword15) )
    ){          
        const embed2 = new Discord.MessageEmbed()
        .setDescription('Promotion Operator \n ▫️ **Do not post outside the advertisement channel.** \n ▫️ **Do not advertise your server via DM.**')
        .setColor(0x000000)
        msg.channel.send(embed2).then(msg => {
    msg.delete(300000)
    });
    }
    

    将在 5 分钟后删除嵌入,您可以随时更改时间,请记住不和谐使用毫秒,因此如果您想使用 10 分钟,则必须输入 600000 等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-26
      • 2020-04-08
      • 1970-01-01
      • 2021-05-29
      • 2021-04-25
      • 2021-01-19
      • 2023-03-16
      • 2021-08-07
      相关资源
      最近更新 更多