Browse Source

Fix regression in inspire

ghorsington 4 năm trước cách đây
mục cha
commit
2ab893a83c
1 tập tin đã thay đổi với 7 bổ sung1 xóa
  1. 7 1
      bot/src/commands/inspire.ts

+ 7 - 1
bot/src/commands/inspire.ts

@@ -1,14 +1,20 @@
 import { Message } from "discord.js";
 import { CommandSet, Command } from "src/model/command";
 import got from "got";
+import { logger } from "src/logging";
 
 @CommandSet
 export class Inspire {
 
     async doInspire(msg: Message): Promise<void> {
         const result = await got.get("https://inspirobot.me/api?generate=true");
+        if(result.statusCode != 200) {
+            logger.error("Failed to get inspiration, status code: %s", result.statusCode);
+            await msg.channel.send(`${msg.author.toString()} Sorry, couldn't get inspiration :(.`);
+            return;
+        }
         msg.channel.send(`${msg.author.toString()} Here is a piece of my wisdom:`, {
-            files: [ result ]
+            files: [ result.body ]
         });
     }