From c5223e9fa0c3c72b1e04307fb3bd6d39afa037c2 Mon Sep 17 00:00:00 2001
From: Will Hunt <will@half-shot.uk>
Date: Mon, 19 Feb 2018 15:01:21 +0000
Subject: [PATCH] Fix emoji sizes

---
 src/messageprocessor.ts       | 3 ++-
 test/test_messageprocessor.ts | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/messageprocessor.ts b/src/messageprocessor.ts
index 283b401..b02e07d 100644
--- a/src/messageprocessor.ts
+++ b/src/messageprocessor.ts
@@ -6,6 +6,7 @@ import * as escapeStringRegexp from "escape-string-regexp";
 
 const USER_REGEX = /<@!?([0-9]*)>/g;
 const CHANNEL_REGEX = /<#?([0-9]*)>/g;
+const EMOJI_SIZE = "1em";
 const EMOJI_REGEX = /<:\w+:?([0-9]*)>/g;
 const MATRIX_TO_LINK = "https://matrix.to/#/";
 
@@ -93,7 +94,7 @@ export class MessageProcessor {
           const id = results[1];
           try {
               const mxcUrl = await this.bot.GetGuildEmoji(msg.guild, id);
-              content = content.replace(results[0], `![${id}](${mxcUrl})`);
+              content = content.replace(results[0], `<img alt="${id}" src="${mxcUrl}" style="height: ${EMOJI_SIZE};"/>`);
           } catch (ex) {
               log.warn("MessageProcessor",
               `Could not insert emoji ${id} for msg ${msg.id} in guild ${msg.guild.id}: ${ex}`,
diff --git a/test/test_messageprocessor.ts b/test/test_messageprocessor.ts
index bc75679..9a678ad 100644
--- a/test/test_messageprocessor.ts
+++ b/test/test_messageprocessor.ts
@@ -111,7 +111,7 @@ describe("MessageProcessor", () => {
             const msg = new Discord.Message(channel, null, null);
             let content = "Hello <:hello:3333333>";
             content = await processor.ReplaceEmoji(content, msg);
-            Chai.assert.equal(content, "Hello ![3333333](mxc://image)");
+            Chai.assert.equal(content, "Hello <img alt=\"3333333\" src=\"mxc://image\" style=\"height: 1em;\"/>");
         });
     });
     describe("FindMentionsInPlainBody", () => {
-- 
GitLab