From 88e6c8c300b4e78389beab6d4715c133051f2db9 Mon Sep 17 00:00:00 2001
From: Will Hunt <will@half-shot.uk>
Date: Thu, 25 Oct 2018 21:36:35 +0100
Subject: [PATCH] Fix replies not showing for ghosts

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

diff --git a/src/bot.ts b/src/bot.ts
index f4c6b32..deed4d7 100644
--- a/src/bot.ts
+++ b/src/bot.ts
@@ -267,7 +267,7 @@ export class DiscordBot {
         msg = await hook.send(embed.description, {
             username: embed.author.name,
             avatarURL: embed.author.icon_url,
-            file: opts.file,
+            files: opts.file ? [opts.file] : undefined,
             embeds: embedSet.replyEmbed ? [embedSet.replyEmbed] : undefined,
         } as any);
       } else {
diff --git a/src/matrixeventprocessor.ts b/src/matrixeventprocessor.ts
index 5ffd4ca..93db395 100644
--- a/src/matrixeventprocessor.ts
+++ b/src/matrixeventprocessor.ts
@@ -239,6 +239,7 @@ export class MatrixEventProcessor {
                 sourceEvent.sender,
             );
         } catch (ex) {
+            log.warn("Failed to handle reply, showing a unknown embed:", ex);
             // For some reason we failed to get the event, so using fallback.
             embed.setDescription("Reply with unknown content");
             embed.setAuthor("Unknown");
@@ -254,7 +255,7 @@ export class MatrixEventProcessor {
         // Are they a discord user.
         if (this.bridge.getBot().isRemoteUser(sender)) {
             const localpart = new MatrixUser(sender.replace("@", "")).localpart;
-            const userOrMember = await this.discord.GetDiscordUserOrMember(localpart.substring("_discord_".length));
+            const userOrMember = await this.discord.GetDiscordUserOrMember(localpart.substring("_discord".length));
             if (userOrMember instanceof Discord.User) {
                 embed.setAuthor(
                     userOrMember.username,
-- 
GitLab