/[sudobot]/branches/5.x/src/utils/user.ts
ViewVC logotype

Annotation of /branches/5.x/src/utils/user.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (hide annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 1525 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 rakinar2 577 import { User, UserFlags } from "discord.js";
2     import Client from "../core/Client";
3     import { getEmoji } from "./utils";
4    
5     const map: Record<string, [string, string]> = {
6     BugHunterLevel1: ["bughunter", "Bughunter Level 1"],
7     BugHunterLevel2: ["golden_bughunter", "Bughunter Level 2"],
8     CertifiedModerator: ["certified_mod", "Discord Certified Moderator"],
9     Staff: ["discord_staff", "Discord Staff"],
10     PremiumEarlySupporter: ["early_supporter", "Early Nitro Supporter"],
11     VerifiedDeveloper: ["verified_bot_developer", "Early Verified Bot Developer"],
12     HypeSquadOnlineHouse1: ["bravery", "HypeSquad Bravery"],
13     HypeSquadOnlineHouse2: ["brilliance", "HypeSquad Brilliance"],
14     HypeSquadOnlineHouse3: ["balance", "HypeSquad Balance"],
15     Hypesquad: ["hypesquad_events", "HypeSquad Events"],
16     Partner: ["partnered_server_owner", "Partnered Server Owner"],
17     VerifiedBot: ["verified_bot", "Verified Bot"],
18     BotHTTPInteractions: ["supports_interactions", "Supports Interactions"],
19     ActiveDeveloper: ["active_developer", "Active Developer"]
20     };
21    
22     export const getUserBadges = (client: Client, user: User) => {
23     const badges = [];
24    
25     for (const flagString in map) {
26     const [emojiName, badgeTitle] = map[flagString];
27     const flag = UserFlags[flagString as keyof typeof UserFlags];
28    
29     if (flag && user.flags?.has(flag)) {
30     const emoji = getEmoji(client, emojiName);
31     badges.push(`${emoji.toString()} ${badgeTitle}`);
32     }
33     }
34    
35     return badges;
36     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26