-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
35 lines (30 loc) · 889 Bytes
/
Copy pathserver.js
File metadata and controls
35 lines (30 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Global objects
const Discord = require("discord.js");
const client = new Discord.Client();
const config = require("./config/config.json");
client.on("ready", () => {
console.log("Booting complete!");
console.log("Bot online!");
});
client.on('guildMemberAdd', member => {
let bannableName = false;
config.regexes.forEach(matcher => {
const regex = new RegExp(matcher.match, matcher.flags);
if (member.displayName.match(regex)) {
console.log(`Matching regex: /${matcher.match}/${matcher.flags}`)
bannableName = true;
}
});
if (bannableName) {
const reason = `The username "${member.displayName}" did not meet the standards of ${member.guild.name}.`
console.log(reason);
member.
ban({
reason: reason,
days: 7
}).
catch(console.error);
}
});
console.log("Booting up...");
client.login(config.token);