-
Notifications
You must be signed in to change notification settings - Fork 3
/
bot.js
72 lines (59 loc) · 2.55 KB
/
bot.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
const { Client, Collection, GatewayIntentBits, WebhookClient } = require("discord.js");
const { DisTube } = require('distube');
const { SoundCloudPlugin } = require('@distube/soundcloud');
const { SpotifyPlugin } = require('@distube/spotify');
const { YtDlpPlugin } = require("@distube/yt-dlp");
const { I18n } = require("@hammerhq/localization");
const Logger = require("./src/helpers/Logger");
const { initializeMongoose } = require("./src/Database/mongoose");
const { LINKS, TOKEN, MUSIC } = require("./settings/config.js");
class MainClient extends Client {
constructor() {
super({
shards: "auto",
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
],
allowedMentions: {
parse: ["roles", "users", "everyone"],
repliedUser: false
},
});
// find unhandled Rejections and Uncaught Exception
process.on("unhandledRejection", (err) => client.logger.error(`Unhandled exception`, err));
process.on("uncaughtException", (err) => client.logger.error(`Uncaught Exception`, err));
this.config = require('./settings/config.js');
this.owner = this.config.OWNER_ID;
// Language is future feature...
this.i18n = new I18n(this.config.LANGUAGE);
this.logger = Logger;
this.joinLeaveWebhook = LINKS.JOIN_LEAVE_LOGS ? new WebhookClient({ url: LINKS.JOIN_LEAVE_LOGS }) : undefined;
// initialize the database
initializeMongoose();
const client = this;
this.distube = new DisTube(client, {
searchSongs: MUSIC.searchSongs,
searchCooldown: MUSIC.searchCooldown,
leaveOnEmpty: MUSIC.leaveOnEmpty,
emptyCooldown: MUSIC.emptyCooldown,
leaveOnFinish: MUSIC.leaveOnFinish,
leaveOnStop: MUSIC.leaveOnStop,
plugins: [
new SoundCloudPlugin(),
new SpotifyPlugin({
emitEventsAfterFetching: true
}),
new YtDlpPlugin()],
});
["aliases", "commands"].forEach(x => client[x] = new Collection());
["loadCommands", "loadEvents", "loadDistube"].forEach(x => require(`./src/handlers/${x}`)(client));
}
connect() {
return super.login(TOKEN);
};
};
module.exports = MainClient;