mirror of
https://github.com/ION606/selmerBot.git
synced 2026-05-14 21:26:54 +00:00
Changed the file structure to make the command reading process clearer and improve organization
This commit is contained in:
@@ -44,39 +44,25 @@ bot.on("guildCreate", guild => {
|
|||||||
|
|
||||||
bot.commands = new Discord.Collection();
|
bot.commands = new Discord.Collection();
|
||||||
|
|
||||||
bot.commNames = new Discord.Collection();
|
|
||||||
|
|
||||||
bot.econ = new Discord.Collection();
|
|
||||||
|
|
||||||
bot.anime = new Discord.Collection();
|
|
||||||
|
|
||||||
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
|
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
|
||||||
|
|
||||||
|
|
||||||
|
bot.commands = new Discord.Collection();
|
||||||
let i = 0;
|
fs.readdirSync('./commands')
|
||||||
for (const file of commandFiles) {
|
.forEach(dir => {
|
||||||
const command = require(`./commands/${file}`);
|
fs.readdirSync(`./commands/${dir}`)
|
||||||
|
.filter(file => file.endsWith('.js'))
|
||||||
bot.commands.set(command.name, command);
|
.forEach(file => {
|
||||||
bot.commNames.set(i, [command.name, command.description]);
|
const command = require(`./commands/${dir}/${file}`);
|
||||||
i ++;
|
bot.commands.set(command.name, command);
|
||||||
}
|
});
|
||||||
|
});
|
||||||
//Anime/manga section
|
|
||||||
const afiles = fs.readdirSync('./commands/anime').filter(file => file.endsWith('.js'));
|
|
||||||
for (const file of afiles) {
|
|
||||||
const command = require(`./commands/anime/${file}`);
|
|
||||||
bot.anime.set(command.name, command);
|
|
||||||
}
|
|
||||||
|
|
||||||
// const econFiles = fs.readdirSync('./commands/inventory').filter(file => file.endsWith('.js'));;
|
// const econFiles = fs.readdirSync('./commands/inventory').filter(file => file.endsWith('.js'));;
|
||||||
// const currency = new Discord.Collection();
|
// const currency = new Discord.Collection();
|
||||||
// const { Users } = require('./commands/currency/dbObjects.js');
|
// const { Users } = require('./commands/currency/dbObjects.js');
|
||||||
// i++;
|
// i++;
|
||||||
|
|
||||||
bot.commNames.set('length', i);
|
|
||||||
|
|
||||||
//XP Table section
|
//XP Table section
|
||||||
let xp_collection = new Map();
|
let xp_collection = new Map();
|
||||||
let items;
|
let items;
|
||||||
@@ -122,21 +108,10 @@ bot.on('messageCreate', (message) => {
|
|||||||
|
|
||||||
//Check if the user has sufficient permission
|
//Check if the user has sufficient permission
|
||||||
//Performes the command
|
//Performes the command
|
||||||
//Anime uses if/else, all else uses switch (can't make a multi-case case)
|
|
||||||
if (command.indexOf('anime') != -1) {
|
|
||||||
console.log("Anime");
|
|
||||||
bot.anime.get(command).execute(message, args);
|
|
||||||
switch(command) {
|
|
||||||
case 'top_anime': bot.anime.get('top_anime').execute(message, args);
|
|
||||||
}
|
|
||||||
} else if (command.indexOf('MANGA') != -1) {
|
|
||||||
console.log("Manga");
|
|
||||||
//Do nothing for now
|
|
||||||
} else {
|
|
||||||
if(bot.commands.has(command)) { bot.commands.get(command).execute(message, args, Discord, Client, bot); }
|
|
||||||
|
|
||||||
else { bot.commands.get('ECON').execute(bot, message, args, command, Discord, mongouri, items, xp_collection); }
|
if(bot.commands.has(command)) { bot.commands.get(command).execute(message, args, Discord, Client, bot); }
|
||||||
}
|
|
||||||
|
else { bot.commands.get('ECON').execute(bot, message, args, command, Discord, mongouri, items, xp_collection); }
|
||||||
})
|
})
|
||||||
|
|
||||||
//Look into integrating MySQL into SelmerBot instead of SQLite
|
//Look into integrating MySQL into SelmerBot instead of SQLite
|
||||||
|
|||||||
Reference in New Issue
Block a user