-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
60 lines (49 loc) · 1.73 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
import { Client, Collection, GatewayIntentBits, Partials, REST } from 'discord.js';
import { Guilds, GuildMembers, GuildMessages } from GatewayIntentBits;
import { User, Message, GuildMember, ThreadMember, Channel } from Partials;
const client = new Client({
intents: [Guilds, GuildMembers, GuildMessages],
partials: [User, Message, GuildMember, ThreadMember],
});
process.on('unhandledRejection',(reason, promise) => {
console.log('unhandledRejection At:', promise, 'Reason:',reason);
});
const fs = require('node:fs');
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('error',(error)=>{
console.log("Error: "+error)
console.log("Restarting bot...")
start();
});
function start() {
client.commands = new Collection();
const functions = fs.readdirSync("./functions").filter(file => file.endsWith(".js"));
const eventFiles = fs.readdirSync("./events").filter(file => file.endsWith(".js"));
const commandFolders = fs.readdirSync("./commands");
for (file of functions) {
require(`./functions/${file}`)(client);
}
(async () => {
for (file of functions) {
require(`./functions/${file}`)(client);
}
client.handleEvents(eventFiles, "./events");
client.handleCommands(commandFolders, "./commands");
})();
client.login(process.env.token).then(()=>{
require('./welcomeMessage');
});
module.exports = {
client, // Export the client variable
};
}
module.exports = {
client,
start // Export the client variable
};
const website = require('./website');
const { error } = require('node:console');
website()
start();