diff --git a/src/messageprocessor.ts b/src/messageprocessor.ts index 8142611f14b457a8946706bd6128c8736ee51d94..3d186bf98fd105f22996ca0b0a64fad172354180 100644 --- a/src/messageprocessor.ts +++ b/src/messageprocessor.ts @@ -48,9 +48,14 @@ export class MessageProcessor { public InsertEmbeds(content: string, msg: Discord.Message): string { for (const embed of msg.embeds) { - let embedContent = "\n----\n"; // Horizontal rule. + let embedContent = "\n\n----"; // Horizontal rule. Two to make sure the content doesn't become a title. const embedTitle = embed.url ? `[${embed.title}](${embed.url})` : embed.title; - embedContent += embedTitle != null ? `#### ${embedTitle}\n\n${embed.description}` : embed.description; + if (embedTitle) { + embedContent += "\n##### " + embedTitle; // h5 is probably best. + } + if (embed.description) { + embedContent += "\n" + embed.description; + } content += embedContent; } return content; diff --git a/test/test_messageprocessor.ts b/test/test_messageprocessor.ts index 71b527e44d2a2431fa7fcb3a4e2b7305cbfe6945..a793d3af14f068542258ec475e6bbc2e2e45183d 100644 --- a/test/test_messageprocessor.ts +++ b/test/test_messageprocessor.ts @@ -175,7 +175,7 @@ describe("MessageProcessor", () => { ]; const inContent = ""; const content = processor.InsertEmbeds(inContent, msg); - Chai.assert.equal(content, "\n----\nTestDescription"); + Chai.assert.equal(content, "\n\n----\nTestDescription"); }); it("processes urlless embeds properly", () => { const processor = new MessageProcessor(new MessageProcessorOpts("localhost"), <DiscordBot> bot); @@ -188,7 +188,7 @@ describe("MessageProcessor", () => { ]; const inContent = ""; const content = processor.InsertEmbeds(inContent, msg); - Chai.assert.equal(content, "\n----\n#### TestTitle\n\nTestDescription"); + Chai.assert.equal(content, "\n\n----\n##### TestTitle\nTestDescription"); }); it("processes linked embeds properly", () => { const processor = new MessageProcessor(new MessageProcessorOpts("localhost"), <DiscordBot> bot); @@ -202,7 +202,7 @@ describe("MessageProcessor", () => { ]; const inContent = ""; const content = processor.InsertEmbeds(inContent, msg); - Chai.assert.equal(content, "\n----\n#### [TestTitle](testurl)\n\nTestDescription"); + Chai.assert.equal(content, "\n\n----\n##### [TestTitle](testurl)\nTestDescription"); }); it("processes multiple embeds properly", () => { const processor = new MessageProcessor(new MessageProcessorOpts("localhost"), <DiscordBot> bot); @@ -223,7 +223,7 @@ describe("MessageProcessor", () => { const content = processor.InsertEmbeds(inContent, msg); Chai.assert.equal( content, -"\n----\n#### [TestTitle](testurl)\n\nTestDescription\n----\n#### [TestTitle2](testurl2)\n\nTestDescription2", +"\n\n----\n##### [TestTitle](testurl)\nTestDescription\n\n----\n##### [TestTitle2](testurl2)\nTestDescription2", ); }); it("inserts embeds properly", () => { @@ -240,7 +240,11 @@ describe("MessageProcessor", () => { const content = processor.InsertEmbeds(inContent, msg); Chai.assert.equal( content, - "Content that goes in the message\n----\n#### [TestTitle](testurl)\n\nTestDescription", +`Content that goes in the message + +---- +##### [TestTitle](testurl) +TestDescription`, ); }); });