Browse Source

Fix crash when rcg or inspire fails

ghorsington 3 years ago
parent
commit
b1705d98a7
2 changed files with 14 additions and 4 deletions
  1. 7 2
      bot/src/plugins/inspire.ts
  2. 7 2
      bot/src/plugins/rcg.ts

+ 7 - 2
bot/src/plugins/inspire.ts

@@ -20,8 +20,13 @@ export class Inspire {
             await message.reply("sorry, couldn't get inspiration :(.");
             return;
         }
-        message.reply("here is a piece of my wisdom:", {
+
+        const messagePostResult = await tryDo(message.reply("here is a piece of my wisdom:", {
             files: [ result.result.body ]
-        });
+        }));
+        if (!messagePostResult.ok) {
+            logger.error("Failed to get inspiration, error %s", messagePostResult.error);
+            await message.reply("sorry, couldn't get inspiration :(.");
+        }
     }
 }

+ 7 - 2
bot/src/plugins/rcg.ts

@@ -46,8 +46,13 @@ export class Rcg {
             return;
         }
 
-        await message.reply("I find this very funny:", {
+        const messagePostResult = await tryDo(message.reply("I find this very funny:", {
             files: [ regexResult[1].trim() ]
-        });
+        }));
+
+        if (!messagePostResult.ok) {
+            logger.error("Failed to get RCG. Got error: %s", messagePostResult.error);
+            await this.sendErrorMessage(message);
+        }
     }
 }