【问题标题】:How to remove a message after a specific period of time in DiscordJS?如何在 DiscordJS 中的特定时间段后删除消息?
【发布时间】:2020-02-06 01:47:47
【问题描述】:

我有一个需要 DiscordJS 的问题。

是,如何正确删除机器人发送的 Discord 消息?

我知道这是一个新手问题,但我是 DiscordJS 的新手。

我非常感谢我收到的所有回复,无论是否有帮助。

【问题讨论】:

    标签: javascript node.js discord.js


    【解决方案1】:

    您必须对消息对象使用.delete 方法才能删除消息。等消息发送出去,过一段时间再删除即可。

    对于 (Rich)embeds,使用以下代码:

    const Discord = require('discord.js');
    
    const RichEmbed = new Discord.RichEmbed()
        .setAuthor('test');
    
    const message = await message.channel.send({ embed: RichEmbed }).then(r => r.delete('time in milliseconds'));
    

    对于普通消息,使用以下代码:

    const message = await message.channel.send('Hello').then(r => r.delete('time in milliseconds'))
    

    【讨论】:

      猜你喜欢
      • 2020-11-08
      • 1970-01-01
      • 1970-01-01
      • 2019-06-02
      • 2018-11-13
      • 2019-12-28
      • 2021-09-13
      • 2021-10-22
      • 2022-01-06
      相关资源
      最近更新 更多