This commit is contained in:
Isaac
2021-02-21 15:58:06 +00:00
parent ed12120f1b
commit 2910a2a201
10 changed files with 171 additions and 29 deletions

View File

@@ -139,10 +139,11 @@ module.exports = class CommandManager {
/**
* Execute a command
* @param {string} cmd_name - Name of the command
* @param {Interaction} interaction - Command interaction
*/
async execute(cmd_name, interaction) {
async handle(interaction) {
const cmd_name = interaction.data.name;
if (!this.commands.has(cmd_name))
throw new Error(`Received "${cmd_name}" command invocation, but the command manager does not have a "${cmd_name}" command`);
@@ -175,11 +176,11 @@ module.exports = class CommandManager {
}
try {
await cmd.deferResponse(interaction, true);
await cmd.acknowledge(interaction, true); // respond to discord
this.client.log.commands(`Executing "${cmd_name}" command (invoked by ${data.member.user.tag})`);
let res = await cmd.execute(data, interaction); // run the command
if (typeof res === 'object' || typeof res === 'string')
cmd.sendResponse(interaction, res, res.secret);
/* let res = */await cmd.execute(data, interaction); // run the command
// if (typeof res === 'object' || typeof res === 'string')
// cmd.sendResponse(interaction, res, res.secret);
} catch (e) {
this.client.log.warn(`[COMMANDS] An error occurred whilst executed the ${cmd} command`);
this.client.log.error(e);