Add some error handling for commands

main
Mari 7 months ago
parent 834f6adb71
commit 74d43b5fe6
  1. 7
      src/commands/base.ts

@ -231,6 +231,11 @@ export abstract class AbstractCharacterStatusCommand extends SlashCommand {
} }
} }
const loadedCharacters = await this.loadCharacters(neededCharacters); const loadedCharacters = await this.loadCharacters(neededCharacters);
for (const char of loadedCharacters) {
if (!char.success) {
console.error(`While loading ${char.name}: `, char.error)
}
}
const characterMap = new Map<string, GameCharacterData>(); const characterMap = new Map<string, GameCharacterData>();
for (const character of loadedCharacters) { for (const character of loadedCharacters) {
characterMap.set(character.name, character); characterMap.set(character.name, character);
@ -349,7 +354,7 @@ export abstract class AbstractCharacterStatusCommand extends SlashCommand {
} }
await Promise.all(pendingSaves); await Promise.all(pendingSaves);
return ctx.send({ return ctx.send({
content: message ?? undefined, content: message ?? (resultImage ? undefined : "Uh... OK? There's kind of nothing to say..."),
attachments: resultImage attachments: resultImage
? [ ? [
{ {

Loading…
Cancel
Save