-
Notifications
You must be signed in to change notification settings - Fork 24
/
index.js
229 lines (125 loc) · 4.11 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
const { Client, Collection } = require("discord.js");
const { config } = require("dotenv");
const { prefix,db,token } = require("./config.json");
require("./server.js");
const Discord = require("discord.js");
const client = new Client({
disableEveryone: true
});
require("discord-buttons")(client)
//--------WELCOME---------
const { createCanvas, loadImage, registerFont } = require("canvas");
//--------MUSIC - CLIENT------
const { Player } = require('discord-player');
const fs = require("fs")
client.player = new Player(client);
//-----database-------
const {Database} = require("quickmongo")
//Collection
client.db = new Database(db)
client.commands = new Collection();
client.aliases = new Collection();
client.queue = new Map();
client.snipes = new Map();
["command"].forEach(handler => {
require(`./handlers/${handler}`)(client);
});
const mongoose = require("mongoose");
mongoose
.connect(db, {
useUnifiedTopology: true,
useNewUrlParser: true,
})
.then(console.log("Connected to mongo db"));
const player = fs.readdirSync('./player').filter(file => file.endsWith('.js'));
//RANKS
const Levels = require("discord-xp");
Levels.setURL(db);
for (const file of player) {
//console.log(`Loading discord-player event ${file}`);
const event = require(`./player/${file}`);
client.player.on(file.split(".")[0], event.bind(null, client));
};
client.on("ready", () => {
console.log(`Hi, ${client.user.username} is now online!`);
client.user.setActivity("PARAS GAMING 🇮🇳");
});
client.on("clickMenu",async menu => {
if(menu.values[0]== "APPLE"){
menu.channel.send(`I ALSO LIKE APPLE`)
}
if(menu.values[1]== "MANGO"){
menu.channel.send(`I ALSO LIKE MANGO`)
}
if(menu.values[3]== "BANANA"){
menu.channel.send(`I ALSO LIKE BANANA`)
}
})
client.on("messageDelete",async (message) => {
client.snipes.set(message.channel.id,{
content : message.content,
author: message.author.tag,
image: message.attachments.first() ? message.attachments.first().proxyURL : null
})
})
//ANTI-MENTION
client.on("message",async message => {
if(message.mentions.members.array().length >= 4){
if(message){
await message.delete()
}
return message.reply(`You are not allow to mention mass members!`)
}
})
//THANKS FOR WATCHING
//FOR MORE HELP JOIN MY SERVER
client.on("message", async message => {
if (message.author.bot) return;
if (!message.guild) return;
const randomXp = Math.floor(Math.random() * 98) + 1;
const level = await Levels.appendXp(
message.author.id,
message.guild.id,
randomXp
);
if (level) {
const user = await Levels.fetch(message.author.id, message.guild.id);
message.channel
.send(
` ${message.author.username}, You just leveled up to level ${user.level}!`
)
.then((m) => m.delete({ timeout: 10000 }));
}
//AFK SYSTEM
//IF YOU WANT MAKE GLOABAL AFK SYSTEM JUST REMOVE SERVER id
//THAKKS FOR WATCHING
//DON'T FORGET TO JOIN SUPPORT SERVER
if (!message.content.startsWith(prefix)) return;
// If message.member is uncached, cache it.
if (!message.member)
message.member = await message.guild.fetchMember(message);
const args = message.content
.slice(prefix.length)
.trim()
.split(/ +/g);
const cmd = args.shift().toLowerCase();
if (cmd.length === 0) return;
// Get the command
let command = client.commands.get(cmd);
// If none is found, try to find it by alias
if (!command) command = client.commands.get(client.aliases.get(cmd));
// If a command is finally found, run the command
if (command) command.run(client, message, args);
});
client.on("message", async message => {
if (message.content === "!welcome") {
client.emit("guildMemberAdd", message.member);
}
});
client.on("guildMemberAdd", async member => {
let message = `${member} welcome to ${member.guild.name}`
let channel = await client.db.get(`channel_${member.guild.id}`)
if(!channel)return;
client.channels.cache.get(channel).send(message)
});
client.login(token);