Commit f6aeaf0573
Unsigned
Layout: unified · split
web/src/utils/fetch-discord-info.ts added +21
| @@ -0,0 +1,21 @@ | ||
| 1 | ||
| 2 | export const fetchDiscordInfo = async (discordInvite: string): Promise<DiscordInfo | null> => { | |
| 3 | const endpoint = `https://discord-invite-info.as93.net/${discordInvite}`; | |
| 4 | try { | |
| 5 | return await fetch(endpoint).then((res) => res.json()); | |
| 6 | } catch (error) { | |
| 7 | console.error('Error fetching discord data:', error); | |
| 8 | return null; | |
| 9 | } | |
| 10 | }; | |
| 11 | ||
| 12 | export interface DiscordInfo { | |
| 13 | inviteCode: string; | |
| 14 | name: string; | |
| 15 | memberCount: number; | |
| 16 | memberOnlineCount: number; | |
| 17 | channel: string; | |
| 18 | icon: string; | |
| 19 | banner: string; | |
| 20 | inviter: string | null; | |
| 21 | } | |