separated out commands to be more easily testable and added functionality for aliases

This commit is contained in:
Aster Fialla
2026-02-23 15:10:48 -05:00
parent bb99ee7ef1
commit 7dfc949b63
3 changed files with 150 additions and 54 deletions

View File

@@ -44,14 +44,20 @@ export const handleMessageCreate = async function(message) {
}
const commandName = content.slice(messageHelper.prefix.length).split(" ")[0];
// If there's no command name (ie just the prefix)
if (!commandName) return await message.reply(enums.help.SHORT_DESC_PLURALFLUX);
const args = messageHelper.parseCommandArgs(content, commandName);
const command = commands.get(commandName);
let command = commands.commandsMap.get(commandName)
if (!command) {
const commandFromAlias = commands.aliasesMap.get(commandName);
command = commandFromAlias ? commands.commandsMap.get(commandFromAlias.command) : null;
}
if (command) {
await command.execute(message, client, args).catch(e => {
await command.execute(message, args).catch(e => {
throw e
});
}