Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

126
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda