From 0d1da68a2cbbd40c60a3d7cbdfdbc2b6c7a2e30b Mon Sep 17 00:00:00 2001
From: "Andrew Morgan andrew@amorgan.xyz" <andrew@amorgan.xyz>
Date: Mon, 21 May 2018 23:46:38 +0200
Subject: [PATCH] Correct promise handling

---
 src/bot.ts              | 6 ++++--
 src/messageprocessor.ts | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/bot.ts b/src/bot.ts
index 6ce62ff..8ddcf13 100644
--- a/src/bot.ts
+++ b/src/bot.ts
@@ -458,7 +458,7 @@ export class DiscordBot {
     });
 
     // Sending was a success
-    return Promise.resolve(true);
+    return true;
   }
 
   private AddGuildMember(guildMember: Discord.GuildMember) {
@@ -623,7 +623,9 @@ export class DiscordBot {
     const editedMsg = await this.msgProcessor.FormatEdit(oldMsg, newMsg);
 
     // Send the message to all bridged matrix rooms
-    this.SendMatrixMessage(editedMsg, newMsg.channel, newMsg.guild, newMsg.author, newMsg.id);
+    if (!await this.SendMatrixMessage(editedMsg, newMsg.channel, newMsg.guild, newMsg.author, newMsg.id)) {
+      log.error("DiscordBot", "Unable to announce message edit for msg id:", newMsg.id);
+    }
   }
 
     private async DeleteDiscordMessage(msg: Discord.Message) {
diff --git a/src/messageprocessor.ts b/src/messageprocessor.ts
index 5a24615..f028933 100644
--- a/src/messageprocessor.ts
+++ b/src/messageprocessor.ts
@@ -74,7 +74,7 @@ export class MessageProcessor {
     public async FormatEdit(oldMsg: Discord.Message, newMsg: Discord.Message): Promise<MessageProcessorMatrixResult> {
         // TODO: Produce a nice, colored diff between the old and new message content
         oldMsg.content = "*edit:* ~~" + oldMsg.content + "~~ -> " + newMsg.content;
-        return await this.FormatDiscordMessage(oldMsg);
+        return this.FormatDiscordMessage(oldMsg);
     }
 
     public InsertEmbeds(content: string, msg: Discord.Message): string {
-- 
GitLab