forked from GlaceYT/Distube-Music-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
144 lines (124 loc) · 4.7 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
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
137
138
139
140
141
142
143
144
/*
██████╗░████████╗██╗░░██╗
██╔══██╗╚══██╔══╝╚██╗██╔╝
██████╔╝░░░██║░░░░╚███╔╝░
██╔══██╗░░░██║░░░░██╔██╗░
██║░░██║░░░██║░░░██╔╝╚██╗
╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚═╝
# MADE BY RTX!! FEEL FREE TO USE ANY PART OF CODE
## FOR HELP CONTACT ME ON DISCORD
## Contact [ DISCORD SERVER : https://discord.gg/FUEHs7RCqz ]
## YT : https://www.youtube.com/channel/UCPbAvYWBgnYhliJa1BIrv0A
*/
const { Client, GatewayIntentBits, Partials } = require("discord.js");
const { DisTube } = require("distube");
const { SpotifyPlugin } = require("@distube/spotify");
const { SoundCloudPlugin } = require("@distube/soundcloud");
const { DeezerPlugin } = require("@distube/deezer");
const { YtDlpPlugin } = require("@distube/yt-dlp");
const { printWatermark } = require('./util/pw');
const config = require("./config.js");
const fs = require("fs");
const path = require('path');
const client = new Client({
intents: Object.keys(GatewayIntentBits).map((a) => {
return GatewayIntentBits[a];
}),
});
client.config = config;
client.player = new DisTube(client, {
leaveOnStop: config.opt.voiceConfig.leaveOnStop,
leaveOnFinish: config.opt.voiceConfig.leaveOnFinish,
leaveOnEmpty: config.opt.voiceConfig.leaveOnEmpty.status,
emitNewSongOnly: true,
emitAddSongWhenCreatingQueue: false,
emitAddListWhenCreatingQueue: false,
plugins: [
new SpotifyPlugin(),
new SoundCloudPlugin(),
new YtDlpPlugin(),
new DeezerPlugin(),
],
});
const player = client.player;
fs.readdir("./events", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
delete require.cache[require.resolve(`./events/${file}`)];
});
});
fs.readdir("./events/player", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
const player_events = require(`./events/player/${file}`);
let playerName = file.split(".")[0];
player.on(playerName, player_events.bind(null, client));
delete require.cache[require.resolve(`./events/player/${file}`)];
});
});
client.commands = [];
fs.readdir(config.commandsDir, (err, files) => {
if (err) throw err;
files.forEach(async (f) => {
try {
if (f.endsWith(".js")) {
let props = require(`${config.commandsDir}/${f}`);
client.commands.push({
name: props.name,
description: props.description,
options: props.options,
});
}
} catch (err) {
console.log(err);
}
});
});
if (config.TOKEN || process.env.TOKEN) {
client.login(config.TOKEN || process.env.TOKEN).catch((e) => {
console.log('TOKEN ERROR❌❌');
});
} else {
setTimeout(() => {
console.log('TOKEN ERROR❌❌');
}, 2000);
}
if(config.mongodbURL || process.env.MONGO){
const mongoose = require("mongoose")
mongoose.connect(config.mongodbURL || process.env.MONGO, {
useNewUrlParser: true,
useUnifiedTopology: true,
}).then(async () => {
console.log('\x1b[32m%s\x1b[0m', `| 🍔 Connected MongoDB!`)
}).catch((err) => {
console.log('\x1b[32m%s\x1b[0m', `| 🍔 Failed to connect MongoDB!`)})
} else {
console.log('\x1b[32m%s\x1b[0m', `| 🍔 Error MongoDB!`)
}
const express = require("express");
const app = express();
const port = 3000;
app.get('/', (req, res) => {
const imagePath = path.join(__dirname, 'index.html');
res.sendFile(imagePath);
});
app.listen(port, () => {
console.log(`🔗 Listening to RTX: http://localhost:${port}`);
console.log(`✨ Happy New Year Welcome To 2024`);
});
printWatermark();
/*
██████╗░████████╗██╗░░██╗
██╔══██╗╚══██╔══╝╚██╗██╔╝
██████╔╝░░░██║░░░░╚███╔╝░
██╔══██╗░░░██║░░░░██╔██╗░
██║░░██║░░░██║░░░██╔╝╚██╗
╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚═╝
# MADE BY RTX!! FEEL FREE TO USE ANY PART OF CODE
## FOR HELP CONTACT ME ON DISCORD
## Contact [ DISCORD SERVER : https://discord.gg/FUEHs7RCqz ]
## YT : https://www.youtube.com/channel/UCPbAvYWBgnYhliJa1BIrv0A
*/