I am trying to make my bot delete a specific number of messages, I think an if
would be best for the case, but I don't know how to do this...
This is how it's supposed to work: There's a message from my bot in the channel, it's always the last one in the chat. My bot will check if the message is actually there, if it is, it will delete the message, along with the command, and then send a new message. If the message is not there, it will just delete the command and send the new message.
Here's my code for reference:
if(/* message is there */) const fetched = await message.channel.fetchMessages({limit: 2});
else const fetched = await message.channel.fetchMessages({limit: 1});
// Deletes stuff
message.channel.bulkDelete(fetched)
.catch(error => message.reply(`There was an error: ${error}`));
message.channel.send("```Open```");
How can I check if that previous message is there?