Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

125
Vistas
Ban discord invite

I would like to make a whitelist on the bot and that the people who are in it can send links.

client.on(`message`, async message => {
   let msg = message
   const bannedWords = [`discord.gg`, `.gg/`, `.gg /`, `. gg /`, `. gg/`, `discord .gg /`, `discord.gg /`, `discord .gg/`, `discord .gg`, `discord . gg`, `discord. gg`, `discord gg`, `discordgg`, `discord gg /`]
   try {
       if (bannedWords.some(word => message.content.toLowerCase().includes(word))) {
           if (message.author.id === message.guild.ownerID) return;
           await message.delete();
           await message.channel.send(`<@`+message.author+`> **You cannot send invites to other Discord servers 💣**`).then((m) => m.delete({ timeout: 3000 }))
       }
   } catch (e) {
       console.log(e);
   }
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can do the same like you did with the banned words and put everyone's User ID in an array. (Not recommended for medium / large guilds) or work with roles. So let's say, you make a role and give it to the persons who are allowed to put in links. Then check if they have the role, if not you could send a warning and remove the message.

Example with whitelist arrays using user ids:

client.on(`message`, async message => {
    let msg = message;

    // Put all the user ID's in this array
    const allowedUsers = ["user_id_1","user_id_2","user_id_3"];
    const bannedWords = [`discord.gg`, `.gg/`, `.gg /`, `. gg /`, `. gg/`, `discord .gg /`, `discord.gg /`, `discord .gg/`, `discord .gg`, `discord . gg`, `discord. gg`, `discord gg`, `discordgg`, `discord gg /`]
    try {
        if (bannedWords.some(word => message.content.toLowerCase().includes(word))) {
            if (message.author.id === message.guild.ownerID) return;
            if(allowedUsers.indexOf(message.author.id) !== -1) return;
            
            await message.delete();
            await message.channel.send(`<@`+message.author+`> **You cannot send invites to other Discord servers 💣**`).then((m) => m.delete({ timeout: 3000 }))
        }
    } catch (e) {
        console.log(e);
    }
});

Or you can do it with roles. Just create a new role for example Links Allowed, copy the ID of this role and put it in de code below at message.member.roles.cache.has("role_id_of_allowed")

client.on(`message`, async message => {
    let msg = message;

    // Put all the user ID's in this array
    const bannedWords = [`discord.gg`, `.gg/`, `.gg /`, `. gg /`, `. gg/`, `discord .gg /`, `discord.gg /`, `discord .gg/`, `discord .gg`, `discord . gg`, `discord. gg`, `discord gg`, `discordgg`, `discord gg /`]
    try {
        if (bannedWords.some(word => message.content.toLowerCase().includes(word))) {
            if (message.author.id === message.guild.ownerID) return;
            if(message.member.roles.cache.has("role_id_of_allowed") === true) return;
            
            await message.delete();
            await message.channel.send(`<@`+message.author+`> **You cannot send invites to other Discord servers 💣**`).then((m) => m.delete({ timeout: 3000 }))
        }
    } catch (e) {
        console.log(e);
    }
});

If it's not working properly, you can also fetch the user's profile first by using await message.guild.members.fetch(); to refresh the cache.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda