Advertisement
Guest User

Untitled

a guest
Dec 13th, 2021
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fs = require('fs');
  2. const { Client, Collection, Intents } = require('discord.js');
  3. const { token } = require('./config.json');
  4.  
  5. const bot = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
  6.  
  7. const events = fs.readFileSync("./events").filter(file => file.endsWith(".js"));
  8. for( const file of events) {
  9.     const eventName = file.split(".")[0];
  10.     const event = require(`./events/${file}`)
  11.     bot.on(eventName, event.bind(null, bot));
  12. }
  13.  
  14. const commands = fs.readFileSync("./commands").filter(file => file.endsWith(".js"));
  15. for( const file of commands) {
  16.     const commandName = file.split(".")[0];
  17.     const command = require(`./commands/${file}`);
  18.  
  19.     console.log(`Loading ${commandName}`);
  20.     bot.commands.set(command.name, command);
  21. }
  22.  
  23.  
  24. bot.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement