-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvii.bot.js
103 lines (91 loc) · 2.59 KB
/
vii.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
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
// Configuration File
const dotenv = require('dotenv');
dotenv.config();
// Discord Classes
const cron = require('node-cron');
const { DisTube } = require('distube');
const { SpotifyPlugin } = require('@distube/spotify');
const { SoundCloudPlugin } = require('@distube/soundcloud');
const { YtDlpPlugin } = require('@distube/yt-dlp');
const { Client, Collection, GatewayIntentBits, Partials } = require('discord.js');
require('events').EventEmitter.defaultMaxListeners = 16;
const TOKEN = process.env.DISCORD_TOKEN;
// Define Client
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildEmojisAndStickers,
],
partials: [Partials.Message, Partials.Reaction, Partials.Channel],
allowedMentions: {
parse: ['users', 'roles'],
},
});
// Client Properties
client.debug = false;
client.colors = {
vii: '#3cdefc',
starboard: '#eba834',
success: '#00ff00',
error: '#ff0000',
warning: '#ffff00',
};
// Music Client
client.distube = new DisTube(client, {
leaveOnStop: false,
leaveOnEmpty: true,
leaveOnFinish: true,
emitNewSongOnly: true,
emitAddSongWhenCreatingQueue: true,
emitAddListWhenCreatingQueue: false,
plugins: [
new YtDlpPlugin(),
new SoundCloudPlugin(),
new SpotifyPlugin({
emitEventsAfterFetching: true,
}),
],
});
// Giveaway Client
const GiveawaysManager = require('./functions/database/giveaways');
client.giveawayManager = new GiveawaysManager(client, {
default: {
botsCanWin: false,
embedColor: client.colors.vii,
embedColorEnd: client.colors.vii,
reaction: '🎁',
},
});
// Define Collections
client.commands = new Collection();
client.invites = new Collection();
client.events = new Collection();
// Load Database
client.mongoose = require('./core/loaders/mongooseLoader');
require('./functions/helpers/arrayUtils')(client);
require('./functions/helpers/timeFuncs')(client);
require('./functions/database/util')(client);
// Run Loaders
require('./core/loaders/musicEventLoader')(client);
require('./core/loaders/commandLoader')(client);
require('./core/loaders/eventLoader')(client);
require('./core/api/internalAPI')(client);
// Time based functions
// Every Minute
cron.schedule('* * * * *', () => {
client.emit('everyMinute');
});
// Every 5 Minutes
cron.schedule('*/5 * * * *', () => {
client.emit('everyFiveMinutes');
});
// Login
client.login(TOKEN);