1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- const fs = require('node:fs');
- const path = require('node:path');
- const { Client, Events, Collection, GatewayIntentBits } = require('discord.js');
- const { token } = require('./config.json');
- const client = new Client({ intents: [GatewayIntentBits.Guilds] });
- // EVENTS HANDLER
- const eventsPath = path.join(__dirname, 'events');
- const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
- for (const file of eventFiles) {
- const filePath = path.join(eventsPath, file);
- const event = require(filePath);
- if (event.once) {
- client.once(event.name, (...args) => event.execute(...args));
- } else {
- client.on(event.name, (...args) => event.execute(...args));
- }
- }
- // COMMANDS HANDLER
- client.commands = new Collection();
- const commandsPath = path.join(__dirname, 'commands');
- const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
- for (const file of commandFiles) {
- const filePath = path.join(commandsPath, file);
- const command = require(filePath);
- if ('data' in command && 'execute' in command) {
- client.commands.set(command.data.name, command);
- } else {
- console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
- }
- }
- //LOGIN
- client.login(token);
- //WEB SERVER
- // var http = require('http');
- // http.createServer(function (req, res) {
- // res.write("I'm alive");
- // res.end();
- // }).listen(8080);
|