-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
102 lines (80 loc) · 3.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
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
/*
╔════════════════════════════════════════════════════════════════════════╗
║ ║
║ ## Created by UltraBot! ║
║ ## Feel free to utilize any portion of the code ║
║ ║
╚════════════════════════════════════════════════════════════════════════╝
*/
const { Client, GatewayIntentBits } = require("discord.js");
const config = require("./config.js");
const fs = require("fs");
const path = require('path');
const { printWatermark } = require('./util/pw');
const { initializePlayer } = require('./player');
const client = new Client({
intents: Object.keys(GatewayIntentBits).map((a) => {
return GatewayIntentBits[a];
}),
});
client.config = config;
initializePlayer(client);
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}`);
client.riffy.init(client.user.id);
});
client.config = config;
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}`)];
});
});
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);
}
});
});
client.on("raw", (d) => {
const { GatewayDispatchEvents } = require("discord.js");
if (![GatewayDispatchEvents.VoiceStateUpdate, GatewayDispatchEvents.VoiceServerUpdate].includes(d.t)) return;
client.riffy.updateVoiceState(d);
});
client.login(config.TOKEN || process.env.TOKEN).catch((e) => {
console.log('TOKEN ERROR❌ - Turn On Intents or Reset New Token');
});
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 GlaceYT : http://localhost:${port}`);
});
printWatermark();
/*
╔════════════════════════════════════════════════════════════════════════╗
║ ║
║ ## Created by UltraBot! ║
║ ## Feel free to utilize any portion of the code ║
║ ║
╚════════════════════════════════════════════════════════════════════════╝
*/