mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +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;
|
||||
|
||||
export const inDev = true;
|
||||
|
||||
export async function execute(
|
||||
interaction: ChatInputCommandInteraction<CacheType>,
|
||||
) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user