feat: better not tracked checks

This commit is contained in:
TresAbhi committed 2023-04-24 00:18:17 +00:00
1 parent 6cd135f7d4
commit 774d6dc9f5
2 files changed
+16 -6

No files matched your search

+2
View File
@@ -12,6 +12,8 @@ import { CLANS } from './eligible.js';
const DEFAULT_THRESHOLD = 7; const DEFAULT_THRESHOLD = 7;
export const inDev = true;
export async function execute( export async function execute(
interaction: ChatInputCommandInteraction<CacheType>, interaction: ChatInputCommandInteraction<CacheType>,
) { ) {
+14 -6
View File
@@ -13,11 +13,7 @@ export default async function getBlitzStarsAccount(
ign: string, ign: string,
callback: (account: PlayerStatistics) => void, callback: (account: PlayerStatistics) => void,
) { ) {
fetch(`https://www.blitzstars.com/api/top/player/${accountId}`) function notTracked() {
.then(async (response) => {
callback((await response.json()) as PlayerStatistics);
})
.catch(() => {
interaction.reply({ interaction.reply({
embeds: [ embeds: [
new EmbedBuilder() new EmbedBuilder()
@@ -26,5 +22,17 @@ export default async function getBlitzStarsAccount(
.setColor(NEGATIVE_COLOR), .setColor(NEGATIVE_COLOR),
], ],
}); });
}); }
fetch(`https://www.blitzstars.com/api/top/player/${accountId}`)
.then(async (response) => {
const data = (await response.json()) as PlayerStatistics;
if (data.statistics) {
callback(data);
} else {
notTracked();
}
})
.catch(notTracked);
} }