diff --git a/src/middleware/rest/SlashCommandManager.js b/src/middleware/rest/SlashCommandManager.js index 1dc2d0e..400f75f 100644 --- a/src/middleware/rest/SlashCommandManager.js +++ b/src/middleware/rest/SlashCommandManager.js @@ -55,12 +55,20 @@ class SlashCommandManager { try { result = await Promise.all(promises); } catch (error) { + this.client.logger.error( + `An issue has occured while updating guild commands. Guild command refresh aborted.\n${error.stack || error}` + ); // Figures out which command and option ran into issues const invalid = error.rawError.errors; const keys = Object.keys(invalid); let str = ''; for (const key of keys) { - const command = commands[parseInt(key)]; + const i = parseInt(key); + const command = commands[i]; + if (!command) { + this.client.logger.warn(`Unable to select command for index ${i} (${key})`); + continue; + } str += `${command.name}: `; const options = Object.keys(invalid[key].options); for (const optKey of options) { @@ -68,9 +76,6 @@ class SlashCommandManager { } str += `\n\n`; } - this.client.logger.error( - `An issue has occured while updating guild commands. Guild command refresh aborted.\n${error.stack || error}` - ); this.client.logger.error(`Failed commands:\n${str}`); }