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
+21 -11

No files matched your search

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