diff --git a/src/bot.ts b/src/bot.ts index a44459c3bd89c1af379abeb4f24dd67893fa0667..2c7ec056e84340912f46988dd067875841472b48 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -81,7 +81,7 @@ export class DiscordBot { /* Handles messages queued up to be sent to matrix from discord. */ private discordMessageQueue: { [channelId: string]: Promise<void> }; - private channelLocks: Map<string,{i: NodeJS.Timeout|null, r: (() => void)|null}>; + private channelLocks: Map<string, {i: NodeJS.Timeout|null, r: (() => void)|null}>; private channelLockPromises: Map<string, Promise<{}>>; constructor( private botUserId: string, @@ -445,7 +445,7 @@ export class DiscordBot { try { this.lockChannel(chan); if (!botUser) { - opts.embed = embedSet.replyEmbed; + // NOTE: Don't send replies to discord if we are a puppet. msg = await chan.send(embed.description, opts); } else if (hook) { msg = await hook.send(embed.description, { diff --git a/test/test_discordbot.ts b/test/test_discordbot.ts index 4117d250597ba833a82c2b80669e369d82440cf0..769c9eeb6eade5cf98651c140abe6b4883188572 100644 --- a/test/test_discordbot.ts +++ b/test/test_discordbot.ts @@ -426,32 +426,34 @@ describe("DiscordBot", () => { ) as DiscordBot; const chan = new MockChannel("123") as any; const t = Date.now(); - await bot.lockChannel(chan); + bot.lockChannel(chan); await bot.waitUnlock(chan); const diff = Date.now() - t; expect(diff).to.be.greaterThan(config.limits.discordSendDelay - 1); }); it("should lock and unlock a channel early, if unlocked", async () => { + const discordSendDelay = 500; + const SHORTDELAY = 100; const bot = new modDiscordBot.DiscordBot( "", - { - limits: { - discordSendDelay: 500, - }, + { bridge: { domain: "localhost", - } + }, + limits: { + discordSendDelay, + }, }, mockBridge, {}, ) as DiscordBot; const chan = new MockChannel("123") as any; - setTimeout(() => bot.unlockChannel(chan), 100); + setTimeout(() => bot.unlockChannel(chan), SHORTDELAY); const t = Date.now(); bot.lockChannel(chan); await bot.waitUnlock(chan); const diff = Date.now() - t; - expect(diff).to.be.lessThan(110); + expect(diff).to.be.greaterThan(SHORTDELAY); }); }); // });