-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
267 lines (236 loc) · 10.8 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
const { Client, MessageAttachment, Collection, Intents, MessageEmbed } = require('discord.js');
// const db = require('quick.db')
const Discord = require('discord.js');
const {token , PREFIX, DBL_API_KEY } = require('./config');
const bot = new Client({ disableMentions: 'everyone' });
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
const hook = new Discord.WebhookClient(process.env.webhook_id, process.env.webhook_token );
const mongoose = require('mongoose');
// const User = require('./models/user')
// const { REST } = require('@discordjs/rest');
const { Routes } = require('discord.js');
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBL_API_KEY)
const fs = require("fs");
const db = require('quick.db');
const jimp = require('jimp');
const uptime = require("discord-uptime-bot");
uptime.webserver(6969)
const DiscordBotListAPI = require('dbl-api');
const api = new DiscordBotListAPI();
bot.phone = new Collection();
bot.commands = new Collection();
bot.aliases = new Collection();
// const { loadEvents } = require("../handler/loadEvents");
// const { loadSlashCommands } = require("../handler/loadSlashCommands")
// const { loadPlayerEvents } = require("../handler/loadPlayerEvents");
["aliases", "commands"].forEach(x => bot[x] = new Collection());
["console", "command", "event" ].forEach(x => require(`./handler/${x}`)(bot));
mongoose.connect(process.env.Mongo);
bot.categories = fs.readdirSync("./commands/" );
// bot.categories = fs.readdirSync("./SlashCommands/");
// const rest = new REST({ version: '10' }).setToken('token');
["command"].forEach(handler => {
require(`./handler/${handler}`)(bot);
});
fs.readdir("./events/guild", (_err, files) => {
files.forEach(file => {
if (!file.endsWith(".js")) return;
const event = require(`./events/guild/${file}`);
let eventName = file.split(".")[0];
console.log(`[Event] ✅ Loaded: ${eventName}`);
client.on(eventName, event.bind(null, client));
delete require.cache[require.resolve(`./events/guild/${file}`)];
});
});
fs.readdir("./events/client", (_err, files) => {
files.forEach(file => {
if (!file.endsWith(".js")) return;
const event = require(`./events/client/${file}`);
let eventName = file.split(".")[0];
console.log(`[Event] ✅ Loaded: ${eventName}`);
client.on(eventName, event.bind(null, client));
delete require.cache[require.resolve(`./events/client/${file}`)];
});
});
// const Enmap = require("enmap");
// bot.setups = new Enmap({ name: "setups", dataDir: "./databases/setups" });
bot.on('ready', () => {
setInterval(() => {
dbl.postStats(bot.guilds.cache.size);
}, 1800000);
});
// bot.on('ready' , () => {
// })
bot.on('message', async message => {
let prefix;
if (message.author.bot || message.channel.type === "dm") return;
try {
let fetched = await db.fetch(`prefix_${message.guild.id}`);
if (fetched == null) {
prefix = PREFIX
} else {
prefix = fetched
}
} catch (e) {
console.log(e)
};
if (message.author.bot) return;
if (message.channel.type === "dm") return;
let messageFetch = db.fetch(`guildMessages_${message.guild.id}`)
if (messageFetch === null) return;
db.add(`messages_${message.guild.id}_${message.author.id}`, 1)
let messagefetch = db.fetch(`messages_${message.guild.id}_${message.author.id}`)
let messages;
if (messagefetch == 0) messages = 0; //Level 0
else if (messagefetch == 100) messages = 100; // Level 1
else if (messagefetch == 200) messages = 200; // Level 2
else if (messagefetch == 300) messages = 300; // Level 3
else if (messagefetch == 400) messages = 400; // Level 4
else if (messagefetch == 500) messages = 500; // Level 5
else if (messagefetch == 600) messages = 600; // Level 6
else if (messagefetch == 700) messages = 700; // Level 7
else if (messagefetch == 800) messages = 800; // Level 8
else if (messagefetch == 900) messages = 900; // Level 9
else if (messagefetch == 1000) messages = 1000; // Level 10
else if (messagefetch == 1100) messages = 1100; // Level 11
else if (messagefetch == 1200) messages = 1200; // Level 12
else if (messagefetch == 1300) messages = 1300; // Level 13
else if (messagefetch == 1400) messages = 1400; // Level 14
else if (messagefetch == 1500) messages = 1500; // Level 15
else if (messagefetch == 1600) messages = 1600; // Level 16
else if (messagefetch == 1700) messages = 1700; // Level 17
else if (messagefetch == 1800) messages = 1800; // Level 18
else if (messagefetch == 1900) messages = 1900; // Level 19
else if (messagefetch == 2000) messages = 2000; // Level 20
else if (messagefetch == 2100) messages = 2100; // Level 21
else if (messagefetch == 2200) messages = 2200; // Level 22
else if (messagefetch == 2300) messages = 2300; // Level 23
else if (messagefetch == 2400) messages = 2400; // Level 24
else if (messagefetch == 2500) messages = 2500; // Level 25
else if (messagefetch == 2600) messages = 2600; // Level 26
else if (messagefetch == 2700) messages = 2700; // Level 27
else if (messagefetch == 2800) messages = 2800; // Level 28
else if (messagefetch == 2900) messages = 2900; // Level 29
else if (messagefetch == 3000) messages = 3000; // Level 30
else if (messagefetch == 3100) messages = 3100; // Level 31
else if (messagefetch == 3200) messages = 3200; // Level 32
else if (messagefetch == 3300) messages = 3300; // Level 33
else if (messagefetch == 3400) messages = 3400; // Level 34
else if (messagefetch == 3500) messages = 3500; // Level 35
else if (messagefetch == 3600) messages = 3600; // Level 36
else if (messagefetch == 3700) messages = 3700; // Level 37
else if (messagefetch == 3800) messages = 3800; // Level 38
else if (messagefetch == 3900) messages = 3900; // Level 39
else if (messagefetch == 4000) messages = 4000; // Level 40
else if (messagefetch == 4100) messages = 4100; // Level 41
else if (messagefetch == 4200) messages = 4200; // Level 42
else if (messagefetch == 4300) messages = 4300; // Level 43
else if (messagefetch == 4400) messages = 4400; // Level 44
else if (messagefetch == 4500) messages = 4500; // Level 45
else if (messagefetch == 4600) messages = 4600; // Level 46
else if (messagefetch == 4700) messages = 4700; // Level 47
else if (messagefetch == 4800) messages = 4800; // Level 48
else if (messagefetch == 4900) messages = 4900; // Level 49
else if (messagefetch == 5000) messages = 5000; // level 50
if (!isNaN(messages)) {
db.add(`level_${message.guild.id}_${message.author.id}`, 1)
let levelfetch = db.fetch(`level_${message.guild.id}_${message.author.id}`)
let levelembed = new MessageEmbed()
.setColor('#f5ce42')
.setDescription(`**${message.author}, You Have Leveled Up To Level ${levelfetch}**`)
.setFooter(`${prefix}disablexp To Disable Level Up Messages`)
message.channel.send(levelembed);
};
});
// bot.on('message', async message => {
// let prefix = PREFIX;
// try {
// let fetched = await db.fetch(`prefix_${message.guild.id}`);
// if (fetched == null) {
// prefix = PREFIX
// } else {
// prefix = fetched
// }
// } catch (e) {
// console.log(e)
// };
// try {
// if (message.mentions.has(bot.user) && !message.mentions.has(message.guild.id)) {
// let menprefix = new MessageEmbed()
// .setAuthor(`${message.guild.me.displayName} `, bot.user.displayAvatarURL())
// .setThumbnail(message.guild.iconURL())
// .setColor('#f5ce42')
// .setDescription(`${message.author} **My Prefix In This Server is - \`${prefix}\`**`) .setImage('https://media.discordapp.net/attachments/999522063683440692/1001851329297264720/standard.gif')
// .setFooter(`All right reserved by [ Coding ] 👑 Venom#6969` , bot.user.displayAvatarURL())
// .setTimestamp()
// message.channel.send(menprefix).then(msg => {
// msg.delete({ timeout: 10000 });
// });
// }
// } catch {
// return;
// };
//});
hook.send('I am now alive!')
bot.on('message', async message => {
try {
const hasText = Boolean(message.content);
const hasImage = message.attachments.size !== 0;
const hasEmbed = message.embeds.length !== 0;
if (message.author.bot || (!hasText && !hasImage && !hasEmbed)) return;
const origin = bot.phone.find(call => call.origin.id === message.channel.id);
const recipient = bot.phone.find(call => call.recipient.id === message.channel.id);
if (!origin && !recipient) return;
const call = origin || recipient;
if (!call.active) return;
await call.send(origin ? call.recipient : call.origin, message, hasText, hasImage, hasEmbed);
} catch {
return;
};
});
bot.on('guildMemberAdd', async member => {
let wChan = db.fetch(`welcome_${member.guild.id}`)
if (wChan == null) return;
if (!wChan) return;
let font64 = await jimp.loadFont(jimp.FONT_SANS_64_WHITE)
let bfont64 = await jimp.loadFont(jimp.FONT_SANS_64_BLACK)
let mask = await jimp.read('https://i.imgur.com/552kzaW.png')
let welcome = await jimp.read('https://t.wallpaperweb.org/wallpaper/nature/1920x1080/greenroad1920x1080wallpaper3774.jpg')
jimp.read(member.user.displayAvatarURL({ format: 'png' })).then(avatar => {
avatar.resize(200, 200)
mask.resize(200, 200)
avatar.mask(mask)
welcome.resize(1000, 300)
welcome.print(font64, 265, 55, `Welcome ${member.user.username}`)
welcome.print(bfont64, 265, 125, `To ${member.guild.name}`)
welcome.print(font64, 265, 195, `There are now ${member.guild.memberCount} users`)
welcome.composite(avatar, 40, 55).write('Welcome2.png')
try {
member.guild.channels.cache.get(wChan).send(``, { files: ["Welcome2.png"] })
} catch (e) {
}
})
var r = member.guild.roles.cache.find(r => r.name === 'Community');
if (!r) return;
member.roles.add(r)
});
const express = require("express");
const app = express();
const dreams = [
"Find and count some sheep",
"Climb a really tall mountain",
"Wash the dishes"
];
app.use(express.static("public"));
app.get("/", (request, response) => {
response.sendFile(__dirname + "/views/index.html");
});
app.get("/dreams", (request, response) => {
response.json(dreams);
});
const listener = app.listen(process.env.PORT, () => {
console.log("Your app is listening on port " + listener.address().port);
});
require('./keepAlive')();
bot.login(process.env.TOKEN)&& uptime.client(process.env.TOKEN, PREFIX);