From 6310e5aef3c6f058bf880d0b37d2a314d51d5433 Mon Sep 17 00:00:00 2001 From: Hirzi <64255651+HirziDevs@users.noreply.github.com> Date: Tue, 29 Jun 2021 12:40:59 +0700 Subject: [PATCH] Create index.js --- index.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..ffdc124 --- /dev/null +++ b/index.js @@ -0,0 +1,27 @@ +const { Client, Collection } = require('discord.js'); +const fs = require('fs'); +const client = new Client(); +require("discord-buttons")(client); + +fs.readdir('./events/', (err, files) => { + if (err) return console.error(err); + files.forEach(file => { + const event = require(`./events/${file}`); + const eventName = file.split('.')[0]; + client.on(eventName, event.bind(null, client)); + }); +}); + +client.commands = new Collection(); + +fs.readdir('./commands/', (err, files) => { + if (err) return console.error(err); + files.forEach(file => { + if (!file.endsWith('.js')) return; + const props = require(`./commands/${file}`); + const commandName = file.split('.')[0]; + client.commands.set(commandName, props); + }); +}); + +client.login("ODE2MjE5NjM0MzkwNjYzMjMw.YD3xxQ.jU2Nv4acN-_E6elyRf9dAXGPlJM");