some improvement to error logging

This commit is contained in:
Erik 2022-04-30 22:10:19 +03:00
parent dcbda13b2a
commit 971ea2f6f4
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -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}`);
}