-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
185 lines (145 loc) · 6.41 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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
MADE BY RTX!! FEEL FREE TO USE ANY PART OF CODE
██████╗░████████╗██╗░░██╗
██╔══██╗╚══██╔══╝╚██╗██╔╝
██████╔╝░░░██║░░░░╚███╔╝░
██╔══██╗░░░██║░░░░██╔██╗░
██║░░██║░░░██║░░░██╔╝╚██╗
╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚═╝
FOR EMOJIS EITHER YOU CAN EDIT OR JOIN OUR DISCORD SERVER
SO WE ADD BOT TO OUR SERVER SO YOU GET ANIMATED EMOJIS.
DISCORD SERVER : https://discord.gg/FUEHs7RCqz
YOUTUBE : https://www.youtube.com/channel/UCPbAvYWBgnYhliJa1BIrv0A
FOR HELP CONTACT ME ON DISCORD
## Contact [ DISCORD SERVER : https://discord.gg/c4kaW2sSbm ]
*/
const { Client, GatewayIntentBits, ActivityType } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const fs = require('fs');
const path = require('path');
const { Player } = require('discord-player');
const express = require('express');
require('dotenv').config();
const ytdl = require('ytdl-core');
const { DisTube } = require('distube');
const client = new Client({
intents: Object.keys(GatewayIntentBits).map((a) => {
return GatewayIntentBits[a];
}),
});
const { printWatermark } = require('./functions/handlers');const distube = new DisTube(client, {
searchSongs: 0,
emitNewSongOnly: true,
leaveOnEmpty: true,
leaveOnFinish: true,
leaveOnStop: true,
});
const prefixData = require('./prefix.json');
const prefix = prefixData.prefix;
const config = require('./config.json');
const youtubeApiKey = config.youtubeAPIKey;
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}`);
});
printWatermark();
client.commands = new Map();
const funCommandsPath = path.join(__dirname, 'funCommands');
const musicCommandsPath = path.join(__dirname, 'musicCommands');
const animeCommandsPath = path.join(__dirname, 'AnimeCommands');
const utilityCommandsPath = path.join(__dirname, 'utilityCommands');
const imageCommandsPath = path.join(__dirname, 'imageCommands');
const basicCommandsPath = path.join(__dirname, 'basicCommands');
const animeCommandFiles = fs.readdirSync(animeCommandsPath).filter((file) => file.endsWith('.js'));
const funCommandFiles = fs.readdirSync(funCommandsPath).filter((file) => file.endsWith('.js'));
const musicCommandFiles = fs.readdirSync(musicCommandsPath).filter((file) => file.endsWith('.js'));
const utilityCommandFiles = fs.readdirSync(utilityCommandsPath).filter((file) => file.endsWith('.js'));
const imageCommandFiles = fs.readdirSync(imageCommandsPath).filter((file) => file.endsWith('.js'));
const basicCommandFiles = fs.readdirSync(basicCommandsPath).filter((file) => file.endsWith('.js'));
for (const file of funCommandFiles) {
const command = require(path.join(funCommandsPath, file));
client.commands.set(command.name, command);
}
for (const file of musicCommandFiles) {
const command = require(path.join(musicCommandsPath, file));
client.commands.set(command.name, command);
}
for (const file of animeCommandFiles) {
const command = require(path.join(animeCommandsPath, file));
client.commands.set(command.name, command);
}
for (const file of utilityCommandFiles) {
const command = require(path.join(utilityCommandsPath, file));
client.commands.set(command.name, command);
}
for (const file of imageCommandFiles) {
const command = require(path.join(imageCommandsPath, file));
client.commands.set(command.name, command);
}
for (const file of basicCommandFiles) {
const command = require(path.join(basicCommandsPath, file));
client.commands.set(command.name, command);
}
client.on('messageCreate', (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
const command = client.commands.get(commandName);
if (!command) return;
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('There was an error trying to execute that command!');
}
});
async function login() {
try {
await client.login(process.env.TOKEN);
console.log('\x1b[32m%s\x1b[0m', '| 🍔 Bot logged in successfully!');
console.log('\x1b[36m%s\x1b[0m', '| 🚀 Commands Loaded successfully!');
console.log('\x1b[32m%s\x1b[0m', `| 🌼 Logged in as ${client.user.username}`);
console.log('\x1b[36m%s\x1b[0m', `| 🏡 Bot is in ${client.guilds.cache.size} servers`);
} catch (error) {
console.error('\x1b[31m%s\x1b[0m', '❌ Failed to log in:', error);
console.log('\x1b[31m%s\x1b[0m', '❌ Client Not Login, Restarting Process...');
process.kill(1);
}
}
client.once('ready', () => {
setTimeout(() => {
console.log('\x1b[32m%s\x1b[0m', `| 🎯 Activity sucessfully set!`);
client.user.setPresence({
activities: [{ name: `Update Out [email protected]`, type: ActivityType.Watching }],
status: 'idle',
});
}, 2000);
});
login();
setInterval(() => {
if (!client || !client.user) {
console.log('\x1b[31m%s\x1b[0m', '❌ Client Not Logged in, Restarting Process...');
process.kill(1);
}
}, 15000);
module.exports = client;
/*
MADE BY RTX!! FEEL FREE TO USE ANY PART OF CODE
██████╗░████████╗██╗░░██╗
██╔══██╗╚══██╔══╝╚██╗██╔╝
██████╔╝░░░██║░░░░╚███╔╝░
██╔══██╗░░░██║░░░░██╔██╗░
██║░░██║░░░██║░░░██╔╝╚██╗
╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚═╝
FOR EMOJIS EITHER YOU CAN EDIT OR JOIN OUR DISCORD SERVER
SO WE ADD BOT TO OUR SERVER SO YOU GET ANIMATED EMOJIS.
DISCORD SERVER : https://discord.gg/FUEHs7RCqz
YOUTUBE : https://www.youtube.com/channel/UCPbAvYWBgnYhliJa1BIrv0A
FOR HELP CONTACT ME ON DISCORD
## Contact [ DISCORD SERVER : https://discord.gg/c4kaW2sSbm ]
*/