forked from drstrangegithub/discord.js-ModerationBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
87 lines (73 loc) · 2.72 KB
/
index.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const Discord = require("discord.js");
const fs = require("fs");
const client = new Discord.Client();
const { Prefix, Token, Color } = require("./config.js");
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
client.db = require("quick.db");
client.on("ready", async () => {
console.log(`Yo boii!! Moderation.V1 has been deployed!! Coded by 365 ɢᴀᴍɪɴɢ ɴ ᴍᴏʀᴇ_2.0#6766`);
client.user
.setActivity(`Discord Tricks`, { type: "LISTENING" })
.catch(error => console.log(error));
});
client.on("message", async message => {
if (message.channel.type === "dm") return;
if (message.author.bot) return;
if (!message.guild) return;
if (!message.member)
message.member = await message.guild.fetchMember(message);
if (message.content.match(new RegExp(`^<@!?${client.user.id}>`))) {
return message.channel.send(`Bot Prefix : ${Prefix}`);
}
});
let modules = ["fun", "info", "moderation"];
modules.forEach(function(module) {
fs.readdir(`./commands/${module}`, function(err, files) {
if (err)
return new Error(
"Missing Folder Of Commands! Example : Commands/<Folder>/<Command>.js"
);
files.forEach(function(file) {
if (!file.endsWith(".js")) return;
let command = require(`./commands/${module}/${file}`);
console.log(`${command.name} Command Has Been Loaded - ✅`);
if (command.name) client.commands.set(command.name, command);
if (command.aliases) {
command.aliases.forEach(alias =>
client.aliases.set(alias, command.name)
);
}
if (command.aliases.length === 0) command.aliases = null;
});
});
});
client.on("message", async message => {
if (message.channel.type === "dm") return;
if (message.author.bot) return;
if (!message.guild) return;
if (!message.member)
message.member = await message.guild.fetchMember(message);
if (!message.content.startsWith(Prefix)) return;
const args = message.content
.slice(Prefix.length)
.trim()
.split(" ");
const cmd = args.shift().toLowerCase();
if (cmd.length === 0) return;
let command =
client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd));
if (!command) return;
if (command) {
if (!message.guild.me.hasPermission("ADMINISTRATOR"))
return message.channel.send(
"I Don't Have Enough Permission To Use This Or Any Of My Commands | Require : Administrator"
);
command.run(client, message, args);
}
console.log(
`User : ${message.author.tag} (${message.author.id}) Server : ${message.guild.name} (${message.guild.id}) Command : ${command.name}`
);
});
client.login(Token);
//Bot Coded by 365 ɢᴀᴍɪɴɢ ɴ ᴍᴏʀᴇ_2.0#6766 DONOT share WITHOUT credits!!