From 339407644b179e688c89fcd53cbc4352c7c3d7e9 Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Sat, 1 Feb 2020 20:56:29 +0100 Subject: [PATCH] Add files via upload --- index.js | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..2635d45 --- /dev/null +++ b/index.js @@ -0,0 +1,62 @@ +const Discord = require("discord.js") +const fs = require("fs") +const client = new Discord.Client() + +const settings = require ("./config/bot.json") //The bot connects using the configuration file + +const emotes = require ("./config/emojis.json") + +const { Player } = require("discord-player"); //Create a new Player (Youtube API key is your Youtube Data v3 key) + +const player = new Player(client, settings.youtube_api); //To easily access the player + +client.player = player; + +client.on("ready", () => { + + console.log("The bot is ready to play music"); + +}); + +client.login(settings.token_bot); //The bot connects thanks to the token + +client.on('message', async message => { + + let prefix = settings.prefix + + let messageArray = message.content.split(" ") + let cmd = messageArray[0].toLowerCase(); + let args = messageArray.slice(1); + + + if(!message.content.startsWith(prefix)) return; + let commandfile = client.commands.get(cmd.slice(prefix.length)) || client.commands.get(client.aliases.get(cmd.slice(prefix.length))) + if(commandfile) commandfile.run(client,message,args) + + + +}) + + client.commands = new Discord.Collection(); + client.aliases = new Discord.Collection(); + + fs.readdir("./commands/", (err, files) => { + + let jsfile = files.filter(f => f.split(".").pop() === "js") + + if(jsfile.length <= 0) { + return console.log("Couldn't Find Commands !"); + } + + jsfile.forEach((f, i) => { + + console.log(`Run command ${f}`); + + let pull = require(`./commands/${f}`); + + client.commands.set(pull.config.name, pull); + pull.config.aliases.forEach(alias => { + client.aliases.set(alias, pull.config.name) + + }); +})}); \ No newline at end of file