mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: better not tracked checks
This commit is contained in:
1 parent
6cd135f7d4
commit
774d6dc9f5
2 files changed
+21
-11
No files matched your search
@@ -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>,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -13,18 +13,26 @@ export default async function getBlitzStarsAccount(
|
|||||||
ign: string,
|
ign: string,
|
||||||
callback: (account: PlayerStatistics) => void,
|
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}`)
|
fetch(`https://www.blitzstars.com/api/top/player/${accountId}`)
|
||||||
.then(async (response) => {
|
.then(async (response) => {
|
||||||
callback((await response.json()) as PlayerStatistics);
|
const data = (await response.json()) as PlayerStatistics;
|
||||||
|
|
||||||
|
if (data.statistics) {
|
||||||
|
callback(data);
|
||||||
|
} else {
|
||||||
|
notTracked();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(notTracked);
|
||||||
interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new EmbedBuilder()
|
|
||||||
.setTitle('No data to display')
|
|
||||||
.setDescription(`${ign} is not tracked by BlitzStars.`)
|
|
||||||
.setColor(NEGATIVE_COLOR),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user