Roadmap to becoming a developer in 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1014 B

const formatter = Intl.NumberFormat('en-US', {
notation: 'compact',
});
10 months ago
let discordStats: any = null;
export async function getDiscordInfo(): Promise<{
url: string;
total: number;
totalFormatted: string;
online: number;
onlineFormatted: string;
}> {
10 months ago
if (discordStats) {
return discordStats;
}
const response = await fetch(
10 months ago
'https://discord.com/api/v9/invites/cJpEt5Qbwa?with_counts=true',
);
10 months ago
try {
const json: any = await response.json();
discordStats = {
url: `https://discord.gg/${json.code}`,
total: json.approximate_member_count,
totalFormatted: formatter.format(json.approximate_member_count),
online: json.approximate_presence_count,
onlineFormatted: formatter.format(json.approximate_presence_count),
};
} catch (e) {
discordStats = {
url: `https://discord.gg/cJpEt5Qbwa`,
total: 17000,
totalFormatted: '17k',
online: 0,
onlineFormatted: formatter.format(0),
};
}
return discordStats;
}