-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
42 lines (35 loc) · 1.22 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
require('dotenv').config();
const {Client} = require('revolt.js')
const Collection = require("revolt.js/dist/maps/Collection");
const {join} = require('node:path');
const {readdirSync} = require('node:fs')
let client = new Client();
// Command Handler
const commands = [];
const folderPath = readdirSync(join(__dirname, 'commands'));
for(const folder of folderPath) {
let command = require(join(__dirname, `commands/${folder}`));
// commands Schema: {name: 'ping', command: 'path/to/command.js'} {name: 'help', command: 'path/to/command.js'}
commands.push({...command})
}
// Event Handler
const eventsPath = join(__dirname, 'events');
const eventFiles = readdirSync(eventsPath).filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const filePath = join(eventsPath, file);
const event = require(filePath);
client.on(event.name, async (...args) => event.execute(...args, client,commands));
}
const start = client.loginBot(process.env.BOT_TOKEN).then(() => {
console.info(`The bot is starting up...`);
}).catch((error) => {
console.error(`An error occurred while starting the bot: ${error}`);
setTimeout(() => {
start;
}, 5000)
})
start;
module.exports = [
client,
commands
];