-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
136 lines (125 loc) · 4.02 KB
/
index.js
File metadata and controls
136 lines (125 loc) · 4.02 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
const
{ Client, Collection, IntentsBitField, Partials } = require('discord.js'),
{ toLog } = require('./system/functions'),
filters = require('./config/filters.json'),
DisTube = require('distube').default,
https = require('https-proxy-agent'),
Enmap = require('enmap');
// Log execution date and time
let
today = new Date(),
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone,
timeArray = today.toLocaleTimeString().split(/[\s]+/),
date = today.toLocaleDateString(),
time = `${timeArray[0]} ${timeArray[1]}`;
console.log(`\n${toLog(`Initializing ${date} ${time} (${timeZone})`, 1, true)}\n`);
// Variable checks (Use .env if present)
let Token, spotifyAPI, nsfw, youtubeCookie;
require('dotenv').config();
if (process.env.token && process.env.spotifyEnabled && process.env.spotifySecret && process.env.spotifyID && process.env.nsfwMusic) {
Token = process.env.token;
nsfw = process.env.nsfwMusic === 'true';
if (process.env.youtubeCookie) youtubeCookie = process.env.youtubeCookie;
spotifyAPI = {
enabled: process.env.spotifyEnabled === 'true',
clientSecret: process.env.spotifySecret,
clientId: process.env.spotifyID
};
} else {
const
{ token } = require('./config/client.json'),
{ spotify_api, ytCookie, nsfwMusic } = require('./config/distube.json');
Token = token;
youtubeCookie = ytCookie;
nsfw = nsfwMusic;
spotifyAPI = spotify_api;
}
const client = new Client({
fetchAllMembers: false,
//restTimeOffset: 0,
//restWsBridgetimeout: 100,
shards: "auto",
//shardCount: 5,
allowedMentions: {
parse: [],
repliedUser: false,
},
failIfNotExists: false,
intents: [new IntentsBitField(3276799)], //131071
presence: {
activities: [{
name: "Deployment",
type: "WATCHING",
}],
status: "idle"
}
});
// DISTUBE
//const proxy = 'http://123.123.123.123:8080';
//const agent = https(proxy);
const
{ SpotifyPlugin } = require('@distube/spotify'),
{ SoundCloudPlugin } = require('@distube/soundcloud'),
{ YtDlpPlugin } = require('@distube/yt-dlp');
let spotifyoptions = {
parallel: true,
emitEventsAfterFetching: true,
}
if (spotifyAPI.enabled) {
spotifyoptions.api = {
clientId: spotifyAPI.clientId,
clientSecret: spotifyAPI.clientSecret,
}
}
client.distube = new DisTube(client, {
emitNewSongOnly: false,
leaveOnEmpty: true,
leaveOnFinish: true,
leaveOnStop: true,
savePreviousSongs: true,
emitAddSongWhenCreatingQueue: false,
//emitAddListWhenCreatingQueue: false,
searchSongs: 0,
youtubeCookie,
nsfw,
emptyCooldown: 25,
ytdlOptions: {
// requestOptions: {
// agent //ONLY USE ONE IF YOU KNOW WHAT YOU DO
// },
highWaterMark: 1024 * 1024 * 64,
quality: "highestaudio",
format: "audioonly",
liveBuffer: 75000,
dlChunkSize: 1024 * 1024 * 4,
},
customFilters: filters,
plugins: [
new SpotifyPlugin(spotifyoptions),
new SoundCloudPlugin(),
new YtDlpPlugin({
updateYouTubeDL: true
})
]
});
// Create client collections
client.commands = new Collection();
client.events = new Collection();
client.distubeSettings = new Enmap({ name: "distubeSettings", dataDir: "./localDB/settings" });
client.infos = new Enmap({ name: "infos", dataDir: "./localDB/infos" });
client.autoresume = new Enmap({ name: "autoresume", dataDir: "./localDB/infos" });
client.usersEmbedArray = [];
client.maps = new Map();
client.cmdOk = false;
client.dbOk = false;
client.evtOk = false;
// Load the Handlers
const
{ loadEvents } = require('./handlers/events'),
{ distubeEvent } = require('./handlers/distubeEvent'),
handlers = [loadEvents, distubeEvent];
// Start the Bot
handlers.forEach(handler => {
handler(client);
});
client.login(Token);