|Help| Discord bot to delete discord invite links (With Code)

Status
This thread has been locked.

IAmVolvic

Supreme
Feedback score
4
Posts
177
Reactions
49
Resources
0
This code I found to delete bad words haha, But I just want it to delete discord links aka only invite links.
As you can see under bad words "https://discord.gg/"
I want it to delete it but it does nothing because in the message it had :,//,. so it does nothing can someone help me. this is JS btw

CODE -----------------------------
var badWords = [
"https://discord.gg/"
];

bot.on('message', message => {
var words = message.content.toLowerCase().trim().match(/\w+|\s+|[^\s\w]+/g);
var containsBadWord = words.some(word => {
return badWords.includes(word);
});
if (containsBadWord) {
message.delete(1);
message.channel.send("Advertising on this server is now allowed please read the rules.!");
}
});
CODE END -----------------------------
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Nathan

Discord Bot Developer
Supreme
Feedback score
50
Posts
372
Reactions
329
Resources
2
client.on("message", message => {
const discordWords = ["discord.gg", "discord.com/invite"];
if (discordWords.some(word => message.content.includes(word))) {
let modRole = message.guild.roles.find("name", "• CEO");
if (message.guild.member(message.author).roles.has(modRole.id)) return;
if (message.content.includes('gg/J98DVEG')) return;
if (message.content.includes('invite/J98DVEG')) return;
message.delete();
}
})

This will check for any discord invites and delete them. It will not do this for my invite which is J98DVEG. Change it, nor will it delete the message if you have the role "• CEO" change it
 

IAmVolvic

Supreme
Feedback score
4
Posts
177
Reactions
49
Resources
0
Oh amazing just for like learning it.. Could you maybe if you have time break it down for me?[DOUBLEPOST=1525889618][/DOUBLEPOST]
client.on("message", message => {
const discordWords = ["discord.gg", "discord.com/invite"];
if (discordWords.some(word => message.content.includes(word))) {
let modRole = message.guild.roles.find("name", "• CEO");
if (message.guild.member(message.author).roles.has(modRole.id)) return;
if (message.content.includes('gg/J98DVEG')) return;
if (message.content.includes('invite/J98DVEG')) return;
message.delete();
}
})

This will check for any discord invites and delete them. It will not do this for my invite which is J98DVEG. Change it, nor will it delete the message if you have the role "• CEO" change it
Getting an error xD..


Aha right I am trying to break this down but I think its not working because its not


(node:6484) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not han
dled with .catch(). (rejection id: 1)
(node:6484) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.[DOUBLEPOST=1525889646][/DOUBLEPOST]BTW it has to be a Listener code..
 
Last edited:
Status
This thread has been locked.
Top