-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathindex.js
120 lines (104 loc) · 4.27 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
const { SQLiteDatabase } = require('@tfadev/easy-sqlite');
const { CommandsHandler, EventsHandler } = require('horizon-handler');
const {
Client,
GatewayIntentBits,
Partials,
Collection,
WebhookClient
} = require('discord.js');
require('colors');
require('dotenv').config();
const config = require("./config.js");
const projectVersion = require('./package.json').version || "v0.0.0";
const client = new Client({
intents: [
Object.keys(GatewayIntentBits)
],
partials: [
Partials.Message,
Partials.Channel,
Partials.GuildMember,
Partials.User
],
presence: {
activities: [{
name: "DM me to create a mail!",
type: 1,
url: "https://twitch.tv/discord"
}]
},
shards: "auto"
});
const webhookClient = (config.logs.webhookURL || process.env.WEBHOOK_URL )
? new WebhookClient({ url: config.logs.webhookURL || process.env.WEBHOOK_URL })
: null;
const db = new SQLiteDatabase('./SQL/main.db');
(async () => {
await db.create(
{
name: 'bans',
overwrite: true,
keys: {
id: ['INTEGER', { primary: true, autoincrement: true }],
userId: ['TEXT'],
guildId: ['TEXT'],
reason: ['TEXT', { nullable: true }]
}
},
{
name: 'mails',
overwrite: true,
keys: {
id: ['INTEGER', { primary: true, autoincrement: true }],
authorId: ['TEXT'],
guildId: ['TEXT'],
channelId: ['TEXT'],
closed: ['BOOLEAN', { nullable: true }]
}
}
);
})();
console.log(`
███╗░░░███╗░█████╗░██████╗░███╗░░░███╗░█████╗░██╗██╗░░░░░
████╗░████║██╔══██╗██╔══██╗████╗░████║██╔══██╗██║██║░░░░░
██╔████╔██║██║░░██║██║░░██║██╔████╔██║███████║██║██║░░░░░
██║╚██╔╝██║██║░░██║██║░░██║██║╚██╔╝██║██╔══██║██║██║░░░░░
██║░╚═╝░██║╚█████╔╝██████╔╝██║░╚═╝░██║██║░░██║██║███████╗
╚═╝░░░░░╚═╝░╚════╝░╚═════╝░╚═╝░░░░░╚═╝╚═╝░░╚═╝╚═╝╚══════╝
`.underline.blue + `version ${projectVersion}, by T.F.A#7524.
`.underline.cyan);
client.login(config.client.token || process.env.CLIENT_TOKEN).catch((e) => {
console.error('Unable to connect to the bot, this might be an invalid token or missing required intents!\n'.red, e);
});
const commandshandler = new CommandsHandler('./commands/', false);
const eventshandler = new EventsHandler('./events/', false);
commandshandler.on('fileLoad', (command) => console.log('Loaded new command: ' + command.name));
eventshandler.on('fileLoad', (event) => console.log('Loaded new event: ' + event));
module.exports = {
client,
webhookClient,
db,
commandshandler,
eventshandler
};
(async () => {
await commandshandler.load();
await eventshandler.load(client);
})();
process.on('unhandledRejection', (reason, promise) => {
console.error("[ANTI-CRASH: unhandledRejection] An error has occured and been successfully handled:".yellow);
console.error(promise, reason);
});
process.on("uncaughtException", (err, origin) => {
console.error("[ANTI-CRASH: uncaughtException] An error has occured and been successfully handled:".yellow);
console.error(err, origin);
});
/*
* DiscordJS-V14-ModMail-Bot v7
* Yet Another Discord ModMail Bot made with discord.js v14, built on VSCode and coded by T.F.A#7524.
* Developer: T.F.A#7524
* Support server: https://discord.gg/E6VFACWu5V
* Please DO NOT remove these lines, these are the credits to the developer.
* Sharing this project without giving credits to me (T.F.A) ends in a Copyright warning. (©)
*/