Node.js Discord.js在触发时删除所有bot和用户消息
正如我在标题中所说的,我希望bot在激活命令后删除所有使用的消息,结果只留下嵌入消息,但我不能这样做。有这样做的线索吗Node.js Discord.js在触发时删除所有bot和用户消息,node.js,discord,discord.js,bots,commando,Node.js,Discord,Discord.js,Bots,Commando,正如我在标题中所说的,我希望bot在激活命令后删除所有使用的消息,结果只留下嵌入消息,但我不能这样做。有这样做的线索吗 const { Command } = require("discord.js-commando"); const Discord = require("discord.js"); module.exports = class PruebaCommand extends Command { constructor(client) {
const { Command } = require("discord.js-commando");
const Discord = require("discord.js");
module.exports = class PruebaCommand extends Command {
constructor(client) {
super(client, {
name: "prueba",
aliases: ["test"],
group: "general",
memberName: "prueba",
guildOnly: true,
description: " - ",
});
}
run(message, args) {
let embed1 = new Discord.MessageEmbed();
const filter = (m) => m.author.id == message.author.id;
message.channel.send(
`Proporciona el nombre del jugador al cual te gustaría añadir a la DODGE LIST`
);
message.channel
.awaitMessages(filter, { time: 30000, max: 1 })
.then((msg) => {
let msg1 = msg.first().content;
message.channel.send(`Link de tu Imagen`).then((msg) => {
msg.channel
.awaitMessages(filter, { time: 30000, max: 1 })
.then((msg) => {
let msg2 = msg.first().content;
message.channel.send(`Correcto, creando tu embed`).then((msg) => {
embed1.setAuthor("˜”*°•.˜”*°• DODGE LIST •°*”˜.•°*”˜");
embed1.setDescription(
"Un nuevo jugador ha sido añadido a la Dodge List"
);
embed1.addFields(
{ name: "__NOMBRE:__", value: msg1 },
{ name: "__SERVIDOR:__", value: "LAS" }
);
embed1.setImage(msg2);
embed1.setColor("RANDOM");
message.channel.send(embed1);
});
});
});
});
}
};
抱歉,如果代码有点奇怪,或者执行方式不应该是这样,我是新手,从来没有使用WaitMessages来生成命令如果我理解正确,您希望删除来自用户的所有消息,以及bot,即命令、响应和您等待的额外信息,而不是那种反应?好了,给你,我很快就想到了,还有更好的办法:
/。。。
var messages=[message];
//...
.等待消息(筛选器、选项)
.then(msgs=>messages.push(msgs.first())//请记住,只有最大消息数为1时,此选项才有效
//... 在所有消息的末尾,写下以下内容:
messages.forEach(m=>m.delete())