-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
78 lines (66 loc) · 2.33 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
const { Client, Collection, GatewayIntentBits } = require("discord.js");
const { DisTube } = require('distube');
const { SoundCloudPlugin } = require('@distube/soundcloud');
const { SpotifyPlugin } = require('@distube/spotify');
const { DeezerPlugin } = require('@distube/deezer');
const { YouTubePlugin } = require('@distube/youtube');
const { YtDlpPlugin } = require('@distube/yt-dlp');
/// Call Config
const { TOKEN, PREFIX, OWNER_ID } = require("./settings/config.json");
process.on('unhandledRejection', error => console.log(error));
process.on('uncaughtException', error => console.log(error));
/// Multi bot login support
for (let i = 0; i < TOKEN.length ; i++) {
const client = new Client({
shards: "auto",
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
],
allowedMentions: { parse: ["users", "roles"] },
});
client.config = require('./settings/config.json');
client.owner = client.config.OWNER_ID;
client.dev = client.config.DEV_ID;
client.color = client.config.EMBED_COLOR;
client.prefix = PREFIX[i];
client.owner = OWNER_ID;
// Print bot token
if (!client.token) client.token = TOKEN[i];
client.distube = new DisTube(client, {
savePreviousSongs: true,
emitAddListWhenCreatingQueue: true,
emitAddSongWhenCreatingQueue: true,
plugins: [
new SoundCloudPlugin(),
new DeezerPlugin(),
new YouTubePlugin(),
new YtDlpPlugin({ update: false }),
checkSpotify(client)
],
});
["aliases", "commands"].forEach(x => client[x] = new Collection());
["loadCommands", "loadEvents", "loadPlayer", "loadDatabase"].forEach(x => require(`./handlers/${x}`)(client));
client.login(client.token);
}
function checkSpotify(client) {
if (client.config.SPOTIFY_TRACKS) {
return spotifyOn(client);
} else {
return spotifyOff();
}
}
function spotifyOn(client) {
return new SpotifyPlugin({
api: {
clientId: client.config.SPOTIFY_ID,
clientSecret: client.config.SPOTIFY_SECRET
}
})
}
function spotifyOff() {
return new SpotifyPlugin({})
}