discord - 如何让我的不和谐机器人删除它自己之前发送的消息?
问题描述
目前,我的机器人中有一个命令,它将对discord.gg
消息中的任何内容做出反应。我希望机器人能够在每次发布不和谐邀请时发布嵌入消息,但删除它发送的最后一条嵌入消息,这样看起来机器人在频道末尾保留一条特定消息。
这就是代码现在的样子,感谢您的帮助!
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);
}
解决方案
我不知道如何删除最后一个嵌入,但是我想出了另一个你可以尝试的解决方案。
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 等。
推荐阅读
- math - F部门和T部门
- html - 如何在html中制作一个透明的文本框
- magento - 如何解决 Magento 管理目录产品搜索问题
- tensorflow - 我可以在 IMXRT1060 上实现 Yamnet 吗?
- java - 我尝试使用本地计算机中的 MSI 通过 appservice 检索 keyvault 机密,但出现错误:java.net.ConnectException:Connection denied:connect
- mongodb - MongoDB / Mongoose 确保对象数组之间的唯一性
- django - 如何使用 Docker 独立部署 Django 应用程序?
- reactjs - 页面刷新后内容消失
- python - 是否可以将mysql中的查询结果拆分为python中的多个字符串?
- amazon-web-services - 需要在 nomad hcl 文件中写入 S3 配置