diff --git a/bot.js b/bot.js index 646eaf2..c8c4e8a 100644 --- a/bot.js +++ b/bot.js @@ -74,20 +74,20 @@ const botProcess = () => { Command.init(); - const help = require("./model/command/help"); + const help = require("./command/help"); bot.ws.on('INTERACTION_CREATE', help.interactionHandler); bot.on('ready', () => { - fs.readdirSync('./event/bot/') + fs.readdirSync('./event/') .filter(filename => filename.endsWith('.js')) .map(filename => filename.substr(0, filename.length - 3)) .forEach(filename => { const event = filename.replace(/([_-][a-z])/gu, character => `${character.substr(1).toUpperCase()}`); if (filename !== 'ready') { - bot.on(event, require(`./event/bot/${filename}`)); + bot.on(event, require(`./event/${filename}`)); } else { - require(`./event/bot/${filename}`)(); + require(`./event/${filename}`)(); } }); }); diff --git a/model/command/avatar.js b/command/avatar.js similarity index 83% rename from model/command/avatar.js rename to command/avatar.js index 52fb064..63a8be6 100644 --- a/model/command/avatar.js +++ b/command/avatar.js @@ -1,18 +1,12 @@ const Logger = require('@lilywonhalf/pretty-logger'); const Discord = require('discord.js'); -const CommandCategory = require('../command-category'); -const CommandPermission = require('../command-permission'); -const Guild = require('../guild'); +const CommandCategory = require('../model/command-category'); +const CommandPermission = require('../model/command-permission'); +const Guild = require('../model/guild'); class Avatar { - static instance = null; - constructor() { - if (Avatar.instance !== null) { - return Avatar.instance; - } - this.aliases = ['av']; this.category = CommandCategory.FUN; this.isAllowedForContext = CommandPermission.yes; diff --git a/model/command/changelog.js b/command/changelog.js similarity index 87% rename from model/command/changelog.js rename to command/changelog.js index 825db46..93c61a3 100644 --- a/model/command/changelog.js +++ b/command/changelog.js @@ -1,20 +1,14 @@ const Logger = require('@lilywonhalf/pretty-logger'); -const Config = require('../../config.json'); -const CommandCategory = require('../command-category'); -const CommandPermission = require('../command-permission'); -const { search } = require('../jira'); +const Config = require('../config.json'); +const CommandCategory = require('../model/command-category'); +const CommandPermission = require('../model/command-permission'); +const { search } = require('../model/jira'); const MAX_CHARACTERS = 1950; class Changelog { - static instance = null; - constructor() { - if (Changelog.instance !== null) { - return Changelog.instance; - } - this.aliases = ['change-log', 'cl']; this.category = CommandCategory.MODERATION; this.isAllowedForContext = CommandPermission.isMemberMod; diff --git a/model/command/clean.js b/command/clean.js similarity index 73% rename from model/command/clean.js rename to command/clean.js index 6e17c69..d9bcb70 100644 --- a/model/command/clean.js +++ b/command/clean.js @@ -1,17 +1,11 @@ const Logger = require('@lilywonhalf/pretty-logger'); -const Config = require('../../config.json'); -const CommandCategory = require('../command-category'); -const CommandPermission = require('../command-permission'); +const Config = require('../config.json'); +const CommandCategory = require('../model/command-category'); +const CommandPermission = require('../model/command-permission'); class Clean { - static instance = null; - constructor() { - if (Clean.instance !== null) { - return Clean.instance; - } - this.aliases = ['clear', 'purge']; this.category = CommandCategory.MODERATION; this.isAllowedForContext = CommandPermission.isMemberMod; diff --git a/model/command/embed.js b/command/embed.js similarity index 97% rename from model/command/embed.js rename to command/embed.js index 03559e6..f70b07c 100644 --- a/model/command/embed.js +++ b/command/embed.js @@ -1,6 +1,6 @@ const { MessageEmbed, Message } = require('discord.js'); -const CommandCategory = require('../command-category'); -const CommandPermission = require('../command-permission'); +const CommandCategory = require('../model/command-category'); +const CommandPermission = require('../model/command-permission'); const RGB_REGEX = /(\d{1,3})\D*,\D*(\d{1,3})\D*,\D*(\d{1,3})\D*/u; diff --git a/model/command/eval.js b/command/eval.js similarity index 80% rename from model/command/eval.js rename to command/eval.js index d99cf72..d6d71b6 100644 --- a/model/command/eval.js +++ b/command/eval.js @@ -1,23 +1,17 @@ const Discord = require('discord.js'); const Logger = require('@lilywonhalf/pretty-logger'); -const Config = require('../../config.json'); -const CommandCategory = require('../command-category'); -const CommandPermission = require('../command-permission'); +const Config = require('../config.json'); +const CommandCategory = require('../model/command-category'); +const CommandPermission = require('../model/command-permission'); // Including every model here so that it's ready to be used by the command -const Guild = require('../guild'); +const Guild = require('../model/guild'); const JAVASCRIPT_LOGO_URL = 'https://i.discord.fr/IEV8.png'; class Eval { - static instance = null; - constructor() { - if (Eval.instance !== null) { - return Eval.instance; - } - this.aliases = []; this.category = CommandCategory.BOT_MANAGEMENT; this.isAllowedForContext = CommandPermission.isMommy; diff --git a/model/command/help.js b/command/help.js similarity index 93% rename from model/command/help.js rename to command/help.js index 4cd45e5..7e266fe 100644 --- a/model/command/help.js +++ b/command/help.js @@ -1,8 +1,8 @@ -const CommandPermission = require('../command-permission'); -const CommandCategory = require('../command-category'); +const CommandPermission = require('../model/command-permission'); +const CommandCategory = require('../model/command-category'); -const commands = require('../command').commandList; -const messages = require('../messages'); +const commands = require('../model/command').commandList; +const messages = require('../model/messages'); const cachelessRequire = (path) => { if (!typeof path === 'string') { @@ -73,7 +73,7 @@ const categoryPage = (cat, id, direct = false) => { data.embeds[0].fields = messages.getList(); else data.embeds[0].fields = Array.from(commands.keys()).map(x => { - const cmd = cachelessRequire(commands.get(x).split("command/").join("")); + const cmd = cachelessRequire(commands.get(x)); if (cleanString(cmd.category)?.toLowerCase() != cat.toLowerCase()) return; return { name: x, value: cmd.description ?? "No description."}; }).filter(x => x); diff --git a/model/command/kill.js b/command/kill.js similarity index 63% rename from model/command/kill.js rename to command/kill.js index 45d9662..e3f23b4 100644 --- a/model/command/kill.js +++ b/command/kill.js @@ -1,17 +1,11 @@ const Logger = require('@lilywonhalf/pretty-logger'); -const Config = require('../../config.json'); -const CommandCategory = require('../command-category'); -const CommandPermission = require('../command-permission'); +const Config = require('../config.json'); +const CommandCategory = require('../model/command-category'); +const CommandPermission = require('../model/command-permission'); class Kill { - static instance = null; - constructor() { - if (Kill.instance !== null) { - return Kill.instance; - } - this.aliases = []; this.category = CommandCategory.BOT_MANAGEMENT; this.isAllowedForContext = CommandPermission.isMemberMod; diff --git a/model/command/reload.js b/command/reload.js similarity index 68% rename from model/command/reload.js rename to command/reload.js index 93bc5d1..897f1fe 100644 --- a/model/command/reload.js +++ b/command/reload.js @@ -1,16 +1,10 @@ const Logger = require('@lilywonhalf/pretty-logger'); -const CommandCategory = require('../command-category'); -const CommandPermission = require('../command-permission'); +const CommandCategory = require('../model/command-category'); +const CommandPermission = require('../model/command-permission'); class Reload { - static instance = null; - constructor() { - if (Reload.instance !== null) { - return Reload.instance; - } - this.aliases = ['reboot']; this.category = CommandCategory.BOT_MANAGEMENT; this.isAllowedForContext = CommandPermission.isMemberMod; diff --git a/model/command/set-avatar.js b/command/set-avatar.js similarity index 76% rename from model/command/set-avatar.js rename to command/set-avatar.js index 3d4959b..bd91a8e 100644 --- a/model/command/set-avatar.js +++ b/command/set-avatar.js @@ -1,16 +1,10 @@ const Logger = require('@lilywonhalf/pretty-logger'); -const CommandCategory = require('../command-category'); -const CommandPermission = require('../command-permission'); +const CommandCategory = require('../model/command-category'); +const CommandPermission = require('../model/command-permission'); class SetAvatar { - static instance = null; - constructor() { - if (SetAvatar.instance !== null) { - return SetAvatar.instance; - } - this.aliases = ['setavatar']; this.category = CommandCategory.BOT_MANAGEMENT; this.isAllowedForContext = CommandPermission.isMemberMod; diff --git a/event/bot/guild-member-add.js b/event/guild-member-add.js similarity index 80% rename from event/bot/guild-member-add.js rename to event/guild-member-add.js index 4401200..0b7011c 100644 --- a/event/bot/guild-member-add.js +++ b/event/guild-member-add.js @@ -1,4 +1,4 @@ -const Guild = require('../../model/guild'); +const Guild = require('../model/guild'); module.exports = async (member) => { if ((member.guild === null || isRightGuild(member.guild.id)) && !member.user.bot) { diff --git a/event/bot/message.js b/event/message.js similarity index 83% rename from event/bot/message.js rename to event/message.js index 698f67d..3fa5deb 100644 --- a/event/bot/message.js +++ b/event/message.js @@ -1,4 +1,4 @@ -const Command = require('../../model/command'); +const Command = require('../model/command'); /** * @param {Message} message diff --git a/event/bot/ready.js b/event/ready.js similarity index 84% rename from event/bot/ready.js rename to event/ready.js index 9982b60..d955764 100644 --- a/event/bot/ready.js +++ b/event/ready.js @@ -1,6 +1,6 @@ const Logger = require('@lilywonhalf/pretty-logger'); -const Config = require('../../config.json'); -const Guild = require('../../model/guild'); +const Config = require('../config.json'); +const Guild = require('../model/guild'); module.exports = async () => { Logger.info('Logged in as ' + bot.user.username + '#' + bot.user.discriminator); diff --git a/model/command.js b/model/command.js index 5d37000..f303dff 100644 --- a/model/command.js +++ b/model/command.js @@ -21,9 +21,9 @@ const Command = { Command.commandList = new Discord.Collection(); Command.commandAliases = {}; - fs.readdirSync('model/command/').forEach(file => { + fs.readdirSync('command/').forEach(file => { if (file.substr(file.lastIndexOf('.')).toLowerCase() === '.js') { - const commandPath = `./command/${file}`; + const commandPath = `../command/${file}`; const commandInstance = cachelessRequire(commandPath); if (commandInstance !== null) {