diff --git a/src/matrixeventprocessor.ts b/src/matrixeventprocessor.ts
index 673d23436dff5081ec4a2eca6f6b8b24d400c7c6..fb49a2fe08de37027baf57aaab57a62d232c46a8 100644
--- a/src/matrixeventprocessor.ts
+++ b/src/matrixeventprocessor.ts
@@ -10,6 +10,7 @@ import * as log from "npmlog";
 
 const MaxFileSize = 8000000;
 const MIN_NAME_LENGTH = 2;
+const MAX_NAME_LENGTH = 32;
 export class MatrixEventProcessorOpts {
     constructor(
         readonly config: DiscordBridgeConfig,
@@ -47,7 +48,9 @@ export class MatrixEventProcessor {
         let displayName = event.sender;
         let avatarUrl = undefined;
         if (profile) {
-            if (profile.displayname && profile.displayname.length > MIN_NAME_LENGTH) {
+            if (profile.displayname &&
+                profile.displayname.length >= MIN_NAME_LENGTH &&
+                profile.displayname.length <= MAX_NAME_LENGTH) {
                 displayName = profile.displayname;
             }
 
@@ -67,7 +70,7 @@ export class MatrixEventProcessor {
         }
         return new Discord.RichEmbed({
             author: {
-                name: displayName,
+                name: displayName.substr(0, MAX_NAME_LENGTH),
                 icon_url: avatarUrl,
                 url: `https://matrix.to/#/${event.sender}`,
             },
diff --git a/test/test_matrixeventprocessor.ts b/test/test_matrixeventprocessor.ts
index f8e104d5f63bc1ad362407163a69813ed7225c38..7565571a805a6a0a4dd8ec250b3bf8ff8295d04f 100644
--- a/test/test_matrixeventprocessor.ts
+++ b/test/test_matrixeventprocessor.ts
@@ -112,7 +112,7 @@ describe("MatrixEventProcessor", () => {
             Chai.assert.equal(evt.author.url, "https://matrix.to/#/@test:localhost");
         });
 
-        it("Should should contain the users userid if the displayname is too short", () => {
+        it("Should use the userid when the displayname is too short", () => {
             const processor = createMatrixEventProcessor();
             const evt = processor.EventToEmbed({
                 sender: "@test:localhost",
@@ -124,6 +124,30 @@ describe("MatrixEventProcessor", () => {
             Chai.assert.equal(evt.author.name, "@test:localhost");
         });
 
+        it("Should use the userid when displayname is too long", () => {
+            const processor = createMatrixEventProcessor();
+            const evt = processor.EventToEmbed({
+                sender: "@test:localhost",
+                content: {
+                    body: "testcontent",
+                },
+            }, {
+                displayname: "this is a very very long displayname that should be capped",
+            }, mockChannel as any);
+            Chai.assert.equal(evt.author.name, "@test:localhost");
+        });
+
+        it("Should cap the sender name if it is too long", () => {
+            const processor = createMatrixEventProcessor();
+            const evt = processor.EventToEmbed({
+                sender: "@testwithalottosayaboutitselfthatwillgoonandonandonandon:localhost",
+                content: {
+                    body: "testcontent",
+                },
+            }, null, mockChannel as any);
+            Chai.assert.equal(evt.author.name, "@testwithalottosayaboutitselftha");
+        });
+
         it("Should should contain the users avatar if it exists", () => {
             const processor = createMatrixEventProcessor();
             const evt = processor.EventToEmbed({