-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathindex.js
More file actions
136 lines (119 loc) · 4.66 KB
/
index.js
File metadata and controls
136 lines (119 loc) · 4.66 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
const express = require('express')
const app = express();
const port = 3000
app.get('/', (req, res) => res.send('Yo boi!! I am ALIVE!!'))
app.listen(port, () =>
console.log(`Your app is listening to http://localhost:${port}`)
);
const Discord = require("discord.js");
const fs = require("fs");
const client = new Discord.Client();
const { Prefix, 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.V2 has been deployed!! 🚀 Coded by 365 ɢᴀᴍɪɴɢ ɴ ᴍᴏʀᴇ_2.0#0002`);
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.on('guildMemberAdd', async (member) => {
if(db.has(`captcha-${member.guild.id}`)=== false) return;
const url = 'https://api.no-api-key.com/api/v2/captcha';
try {
fetch(url)
.then(res => res.json())
.then(async json => {
console.log(json)
const msg = await member.send(
new MessageEmbed()
.setTitle('Please enter the captcha')
.setImage(json.captcha)
.setColor("RANDOM")
)
try {
const filter = (m) => {
if(m.author.bot) return;
if(m.author.id === member.id && m.content === json.captcha_text) return true;
else {
msg.channel.send("You have answered the captcha incorrectly!")
}
};
const response = await msg.channel.awaitMessages(filter, {
max : 1,
time : 10000,
errors : ['time']
})
if(response) {
msg.channel.send('Congrats, you have answered the captcha.')
}
} catch (error) {
msg.channel.send(`You have been kicked from **${member.guild.name}** for not answering the captcha correctly.`)
member.kick()
}
})
} catch (error) {
console.log(error)
}
})
client.login(process.env.Token);
//Bot Coded by 365 ɢᴀᴍɪɴɢ ɴ ᴍᴏʀᴇ_2.0#0002 DONOT share WITHOUT credits!!