如何在 DiscordJS 中的特定时间段后删除消息?

How to remove a message after a specific period of time in DiscordJS?

我有一个要求 DiscordJS 的问题。

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

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

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

您必须对消息对象使用 .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'))