1
votes

Currently, I have a command in my bot where it will react to anything with discord.gg in the message. I want the bot to be able to post the embed message each time a discord invite is posted, but delete the last embed message it sent so it would look like the bot is keeping one specific message at the end of a channel.

This is what the code looks like right now, thank you for your help!

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);    
}
1

1 Answers

1
votes

I wouldn't know how to delete the last embed but, I have came up with another solution you could try.

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)
});
}

that there will delete the embed after 5 minutes, You can always change the time, Just keep in mind discord uses milliseconds so if you want to use 10 minutes you would have to put in 600000, etc.