From fce16a6975c2797a7de4ff3bec7c151ee48c8f30 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Thu, 27 Apr 2023 01:23:41 +0000 Subject: [PATCH] feat: blitz stars defer compat --- src/commands/eligible.ts | 55 ++++++++++++--------------- src/commands/stats.ts | 2 +- src/utilities/getBlitzStarsAccount.ts | 6 +-- 3 files changed, 28 insertions(+), 35 deletions(-) diff --git a/src/commands/eligible.ts b/src/commands/eligible.ts index e3d1ee8e6..eb7c0ec74 100644 --- a/src/commands/eligible.ts +++ b/src/commands/eligible.ts @@ -116,37 +116,30 @@ export default { const eligible = issues.length === 0; - await interaction - .reply({ - embeds: [ - poweredByBlitzStars( - new EmbedBuilder() - .setTitle( - `${data.nickname} is ${ - eligible ? '' : 'not ' - }eligible for ${CLANS[clan].name}`, - ) - .setColor(eligible ? POSITIVE_COLOR : NEGATIVE_COLOR) - .setDescription( - `${ - eligible - ? `${data.nickname} meets all the requirements set for ${CLANS[clan].name}.` - : `${data.nickname}'s shortcomings for ${ - CLANS[clan].name - } (${ - clan === 'sklld' - ? '30 days stats' - : 'career stats' - }):\n\n${issues.join('\n')}` - }\n\n${blitzLinks(data)}`, - ), - ), - ], - }) - .catch((e) => { - console.log('nooooooooooooooooooooooooo'); - console.log(e); - }); + await interaction.editReply({ + embeds: [ + poweredByBlitzStars( + new EmbedBuilder() + .setTitle( + `${data.nickname} is ${ + eligible ? '' : 'not ' + }eligible for ${CLANS[clan].name}`, + ) + .setColor(eligible ? POSITIVE_COLOR : NEGATIVE_COLOR) + .setDescription( + `${ + eligible + ? `${data.nickname} meets all the requirements set for ${CLANS[clan].name}.` + : `${data.nickname}'s shortcomings for ${ + CLANS[clan].name + } (${ + clan === 'sklld' ? '30 days stats' : 'career stats' + }):\n\n${issues.join('\n')}` + }\n\n${blitzLinks(data)}`, + ), + ), + ], + }); console.log( `Showing ${data.nickname}'s eligibility for ${CLANS[clan].name}`, diff --git a/src/commands/stats.ts b/src/commands/stats.ts index 6b16b0bbc..1fe37c73f 100644 --- a/src/commands/stats.ts +++ b/src/commands/stats.ts @@ -62,7 +62,7 @@ export default { const stats = period === 'career' ? data.statistics : data[`period${period}d`]; - await interaction.reply({ + await interaction.editReply({ embeds: [ poweredByBlitzStars( new EmbedBuilder() diff --git a/src/utilities/getBlitzStarsAccount.ts b/src/utilities/getBlitzStarsAccount.ts index abac8f4b5..57ad2e56e 100644 --- a/src/utilities/getBlitzStarsAccount.ts +++ b/src/utilities/getBlitzStarsAccount.ts @@ -13,10 +13,10 @@ export default async function getBlitzStarsAccount( name: string, callback: (account: PlayerStatistics) => void, ) { - await interaction.deferReply(); - + if (!interaction.deferred) await interaction.deferReply(); + async function notTracked() { - await interaction.reply({ + await interaction.editReply({ embeds: [ new EmbedBuilder() .setTitle('No data to display')