-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAIOBot.js
111 lines (94 loc) · 3.22 KB
/
AIOBot.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
// console.clear();
require('events').defaultMaxListeners = 15;
const Discord = require('discord.js');
const { createConnection } = require('mysql');
const http = require('http');
const express = require("express");
const config = require('./JSON/config.json')
const app = express();
const server = http.createServer(app);
const { GiveawaysManager } = require("discord-giveaways");
// const { con } = require('./mysql.js')
const client = new Discord.Client({
restTimeOffset: 0,
allowedMentions: {
parse: ["roles", "users", /*"everyone"*/ ],
repliedUser: false,
},
intents: [
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MEMBERS,
Discord.Intents.FLAGS.GUILD_BANS,
Discord.Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
Discord.Intents.FLAGS.GUILD_INTEGRATIONS,
Discord.Intents.FLAGS.GUILD_WEBHOOKS,
Discord.Intents.FLAGS.GUILD_INVITES,
Discord.Intents.FLAGS.GUILD_VOICE_STATES,
Discord.Intents.FLAGS.GUILD_PRESENCES,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Discord.Intents.FLAGS.GUILD_MESSAGE_TYPING,
Discord.Intents.FLAGS.DIRECT_MESSAGES,
Discord.Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
Discord.Intents.FLAGS.DIRECT_MESSAGE_TYPING,
],
disableEveryone: true,
partials: ["USER", "CHANNEL", "MESSAGE", "GUILD_MEMBERS", "REACTION"]
});
module.exports = client;
// import
const fs = require('fs');
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
client.categories = fs.readdirSync("./commands/");
client.cooldowns = new Discord.Collection();
client.logger = require('./Utils/Logger');
client.slashCommands = new Discord.Collection();
client.delay = ms => new Promise(res => setTimeout(res, ms));
client.embedCollection = new Discord.Collection();
client.interactions = new Discord.Collection();
client.snipes = new Discord.Collection();
["command", "event"].forEach(handler => {
require(`./handlers/${handler}`)(client);
});
let con = createConnection(config.mysql);
con.connect(err => {
if (err) return console.log(err);
console.log(`MySQL has been connected as ${config.mysql.user}!`);
});
console.log(`Command count ${client.commands.size}`)
client.giveawaysManager = new GiveawaysManager(client, {
storage: ".file database",
updateCountdownEvery: 3000,
default: {
botsCanWin: false,
embedColor: "#FF0000",
reaction: "<a:congratulation:918701219789307915>"
}
});
process.on('unhandledRejection', err => {
client.logger.error(`Have an error: ${err.message}.`);
console.log(err);
});
// app.set('dashboard', __dirname + '/dashboard')
// app.set('view engine', 'pug');
// app.get("/", (req, res) => {
// res.render('index')
// });
// app.get("/docs", (req, res) => {
// res.render('docs')
// });
// app.get("/status", (req, res) => {
// res.render('docs')
// });
// app.get("/src-code", (req, res) => {
// res.render('src-code')
// });
// const listener = server.listen(config.port, function () {
// console.log(`Stating AIO Bot website......`)
// console.log(`IP: ${config.domain} Port: ${config.port}`)
// })
process.on('warning', (warning) => {
console.log(warning.stack);
});
client.login(config.token).catch(e => client.logger.error(e.message));