diff --git a/src/commands/rush-duel.ts b/src/commands/rush-duel.ts index c6eb119..8a35f89 100644 --- a/src/commands/rush-duel.ts +++ b/src/commands/rush-duel.ts @@ -411,11 +411,15 @@ export class RushDuelCommand extends AutocompletableCommand { }); return replyLatency(reply, interaction); } + await interaction.deferReply(); const url = videoGameIllustrationURL(card); const hasVideoGameIllustration = await this.checkYugipediaRedirect(url, interaction); const switcher = new ArtSwitcher(card.images, hasVideoGameIllustration ? url : null); - const reply = await switcher.reply(interaction, resultLanguage); - return replyLatency(reply, interaction); + const end = Date.now(); + await switcher.editReply(interaction, resultLanguage); + // When using deferReply, editedTimestamp is null, as if the reply was never edited, so provide a best estimate + const latency = end - interaction.createdTimestamp; + return latency; } } @@ -484,8 +488,8 @@ class ArtSwitcher { this.labelButton.setLabel(this.label); } - async reply(parentInteraction: ChatInputCommandInteraction, resultLanguage: Locale): Promise { - const reply = await parentInteraction.reply({ ...this.replyOptions, fetchReply: true }); + async editReply(parentInteraction: ChatInputCommandInteraction, resultLanguage: Locale): Promise { + const reply = await parentInteraction.editReply(this.replyOptions); const filter = (childInteraction: ButtonInteraction): boolean => { this.logger.info(serialiseInteraction(parentInteraction), `click: ${childInteraction.user.id}`); if (childInteraction.user.id === parentInteraction.user.id) { diff --git a/test/contract/link.test.ts b/test/contract/link.test.ts index e8d5a5d..f5c4bf1 100644 --- a/test/contract/link.test.ts +++ b/test/contract/link.test.ts @@ -14,7 +14,7 @@ describe("Healthcheck for /link URLs", () => { // Skip Discord CDN links as they are no longer accessible outside Discord after the Authenticated Attachment URL change test.each( - Object.values(LinkCommand.links).filter(({ result }) => !result.startsWith("https://cdn.discordapp.com")) + Object.values(LinkCommand.links).filter(({ result }) => !result.startsWith("https://cdn.discordapp.com/")) )("$name", async ({ result }) => { for (const url of result.split("\n")) { const response = await got(url);