as I said in the title, I would like the bot to delete all the messages used after activating the command, leaving only the embed as a result, but I can't do it. Any clue to do so?
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);
});
});
});
});
}
};
Sorry if the code is somewhat strange, or executed the way it shouldn't be, I am new to this and have never used awaitMessages to make a command
If I understand correctly, you want to delete all the messages that came from the user, and the bot, which would be the command, the response, the extra info you waited for, and but not that response? Well here you go, this just came quickly to my head, there could be a better way:
//...
var messages = [message];
//...
<channel>.awaitMessages(filter, options)
.then(msgs => messages.push(msgs.first())) //keep in mind this would only work if it’s 1 message max
//... at the end of all the awaitMessages, put this:
messages.forEach(m => m.delete())