aboutsummaryrefslogtreecommitdiff
path: root/test.js
diff options
context:
space:
mode:
authorTrey <trey6979@gmail.com>2018-04-06 13:37:22 -0400
committerTrey <trey6979@gmail.com>2018-04-06 13:37:22 -0400
commit20b860bb2299d4a45aa9899fcab2b340cbe9a0b5 (patch)
tree4022b84287f9df17854947a6f6ae98665719f209 /test.js
parentb85b686829798f29f5f19fe919ae8807ef9ad69c (diff)
parente39d116465334ce84ee06267e8defb6007dddf22 (diff)
downloadPokeBot-20b860bb2299d4a45aa9899fcab2b340cbe9a0b5.tar.gz
PokeBot-20b860bb2299d4a45aa9899fcab2b340cbe9a0b5.tar.bz2
PokeBot-20b860bb2299d4a45aa9899fcab2b340cbe9a0b5.zip
Merge branch 'master' of https://github.com/PokeWorld/PokeBot
Diffstat (limited to 'test.js')
-rw-r--r--test.js72
1 files changed, 0 insertions, 72 deletions
diff --git a/test.js b/test.js
deleted file mode 100644
index 69b8e71..0000000
--- a/test.js
+++ /dev/null
@@ -1,72 +0,0 @@
-const Discord = require('discord.js');
-const bot = new Discord.Client();
-const fs = require('fs');
-
-bot.commands = new Discord.Collection();
-bot.aliases = new Discord.Collection();
-bot.categories = new Discord.Collection();
-bot.queue = new Discord.Collection();
-bot.plugins = { music : require('./Plugins/Music.js') };
-cmdLoader();
-
-async function cmdLoader() {
- const categories = await fs.readdirSync('./commands');
- console.log(`Loading ${categories.length} categories(s) into memory\n`);
- categories.forEach(x => {
- loadGroup(x);
- });
-}
-async function loadGroup(name) {
- const files = await fs.readdirSync(`./commands/${name}`);
-
- console.log(`Loading the category '${name}' into memory with a total of ${files.length} command(s)`);
-
- bot.commands.set(name, new Map());
- bot.aliases.set(name, new Map());
-
- const commands = [];
- files.forEach(x => {
- loadCmd(name, x);
- commands.push(x.split('.')[0]);
- });
-
- bot.categories.set(name, commands);
- console.log(`The category ${name} has been loaded.\n`);
-}
-
-async function loadCmd(category, cmd) {
- try {
- console.log(`Loading the Command ${cmd.split('.')[0]}`);
- const command = require(`./commands/${category}/${cmd}`);
- bot.commands.get(category).set(command.help.name, command);
- command.conf.aliases.forEach(alias => {
- console.log(`Loading the alias ${alias} for the command ${command.help.name}`);
- bot.aliases.get(category).set(alias, command.help.name);
- });
- }
- catch (err) {
- console.log(`An error has occured trying to load the command '${cmd.split('.')[0]}'`);
- console.log(err.stack);
- }
-}
-
-
-fs.readdir('./events', (err, files) => {
- if (err) console.error(err);
- console.log(`Attempting to load a total of ${files.length} events into the memory.`);
- files.forEach(file => {
- try {
- const eventName = file.split('.')[0];
- const event = require(`./events/${file}`);
- console.log(`Attempting to load the event "${eventName}".`);
- bot.on(eventName, event.bind(null, bot));
- delete require.cache[require.resolve(`./events/${file}`)];
- }
- catch (err) {
- console.log('An error has occured trying to load a event. Here is the error.');
- console.log(err.stack);
- }
- });
- console.log('Event Loading complete!');
- console.log('\n');
-});