Discord bot delete invites

I’m trying to make my bot delete messages containing links.
ex: “discord.gg/”
but I think message.content.includes is deprecated because I don’t even get an error if a message contains the text…

Did you check discordjs site docs

Of course. Everything else works. I also have commands check for
if( !message.content.includes(“?”)) {…}
And that works

Message.content.includes isn’t deprecated - it’s a JS string prototype function.

You can check for a discord.gg link like so

if (message.content.includes("discord.gg/")) {
    //message includes discord link
} else {
    //message doesn’t include discord link


I recommend using regExp instead of includes

let discordInvite = /(https:\/\/)?(www\.)?(discord\.gg|discord\.me|discordapp\.com\/invite|discord\.com\/invite)\/([a-z0-9-.]+)?/i;
  if (discordInvite.test(string)) {
//Message includes invite
}else {
//Message doesn't includes invite
  if (message.content.includes("discord.gg/")) {
    message.reply("dont advertise"); 

^^that’s how I do it, should be easy

invite link can be like “discordapp.com” or “discord.com

I think you mixed up languages. It is message.delete()

1 Like

But that would include things like channel link.