From c73b8725c1667b51185eeaef7d3fa4a91b211c34 Mon Sep 17 00:00:00 2001 From: creations <creations@creations.works> Date: Sat, 19 Apr 2025 22:46:35 -0400 Subject: [PATCH] add discord badges from https://git.creations.works/seth pr, fixed a few things --- .env.example | 3 + README.md | 3 + config/discordBadges.ts | 87 +++++++++++++++++++ config/environment.ts | 6 ++ public/badges/discord/ACTIVE_DEVELOPER.svg | 3 + public/badges/discord/BUG_HUNTER_LEVEL_1.svg | 1 + public/badges/discord/BUG_HUNTER_LEVEL_2.svg | 1 + public/badges/discord/CERTIFIED_MODERATOR.svg | 1 + public/badges/discord/HYPESQUAD.svg | 1 + .../discord/HYPESQUAD_ONLINE_HOUSE_1.svg | 1 + .../discord/HYPESQUAD_ONLINE_HOUSE_2.svg | 1 + .../discord/HYPESQUAD_ONLINE_HOUSE_3.svg | 1 + public/badges/discord/NITRO.svg | 1 + public/badges/discord/PARTNER.svg | 1 + .../discord/PREMIUM_EARLY_SUPPORTER.svg | 1 + public/badges/discord/STAFF.svg | 1 + public/badges/discord/SUPPORTS_COMMANDS.svg | 1 + public/badges/discord/USES_AUTOMOD.svg | 19 ++++ public/badges/discord/VERIFIED_DEVELOPER.svg | 1 + src/helpers/badges.ts | 36 +++++++- src/routes/[id].ts | 13 ++- 21 files changed, 178 insertions(+), 5 deletions(-) create mode 100644 config/discordBadges.ts create mode 100644 public/badges/discord/ACTIVE_DEVELOPER.svg create mode 100644 public/badges/discord/BUG_HUNTER_LEVEL_1.svg create mode 100644 public/badges/discord/BUG_HUNTER_LEVEL_2.svg create mode 100644 public/badges/discord/CERTIFIED_MODERATOR.svg create mode 100644 public/badges/discord/HYPESQUAD.svg create mode 100644 public/badges/discord/HYPESQUAD_ONLINE_HOUSE_1.svg create mode 100644 public/badges/discord/HYPESQUAD_ONLINE_HOUSE_2.svg create mode 100644 public/badges/discord/HYPESQUAD_ONLINE_HOUSE_3.svg create mode 100644 public/badges/discord/NITRO.svg create mode 100644 public/badges/discord/PARTNER.svg create mode 100644 public/badges/discord/PREMIUM_EARLY_SUPPORTER.svg create mode 100644 public/badges/discord/STAFF.svg create mode 100644 public/badges/discord/SUPPORTS_COMMANDS.svg create mode 100644 public/badges/discord/USES_AUTOMOD.svg create mode 100644 public/badges/discord/VERIFIED_DEVELOPER.svg diff --git a/.env.example b/.env.example index 21aae90..25f8efe 100644 --- a/.env.example +++ b/.env.example @@ -4,3 +4,6 @@ PORT=8080 REDIS_URL=redis://username:password@localhost:6379 REDIS_TTL=3600 # seconds + +# if you wish to get discord badges +DISCORD_TOKEN=discord_bot_token diff --git a/README.md b/README.md index ab230e9..5084653 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,9 @@ REDIS_URL=redis://username:password@localhost:6379 # Value is in seconds REDIS_TTL=3600 + +#only use this if you want to show discord badges +DISCORD_TOKEN=discord_bot_token ``` ## Endpoint diff --git a/config/discordBadges.ts b/config/discordBadges.ts new file mode 100644 index 0000000..7e0e258 --- /dev/null +++ b/config/discordBadges.ts @@ -0,0 +1,87 @@ +export const discordBadges = { + // User badges + HYPESQUAD: 2 << 2, + HYPESQUAD_ONLINE_HOUSE_1: 2 << 6, + HYPESQUAD_ONLINE_HOUSE_2: 2 << 7, + HYPESQUAD_ONLINE_HOUSE_3: 2 << 8, + + STAFF: 2 << 0, + PARTNER: 2 << 1, + CERTIFIED_MODERATOR: 2 << 18, + + VERIFIED_DEVELOPER: 2 << 17, + ACTIVE_DEVELOPER: 2 << 22, + + PREMIUM_EARLY_SUPPORTER: 2 << 9, + + BUG_HUNTER_LEVEL_1: 2 << 3, + BUG_HUNTER_LEVEL_2: 2 << 14, + + // Bot badges + SUPPORTS_COMMANDS: 2 << 23, + USES_AUTOMOD: 2 << 24, +}; + +export const discordBadgeDetails = { + HYPESQUAD: { + tooltip: "HypeSquad Events", + icon: "/public/badges/discord/HYPESQUAD.svg", + }, + HYPESQUAD_ONLINE_HOUSE_1: { + tooltip: "HypeSquad Bravery", + icon: "/public/badges/discord/HYPESQUAD_ONLINE_HOUSE_1.svg", + }, + HYPESQUAD_ONLINE_HOUSE_2: { + tooltip: "HypeSquad Brilliance", + icon: "/public/badges/discord/HYPESQUAD_ONLINE_HOUSE_2.svg", + }, + HYPESQUAD_ONLINE_HOUSE_3: { + tooltip: "HypeSquad Balance", + icon: "/public/badges/discord/HYPESQUAD_ONLINE_HOUSE_3.svg", + }, + + STAFF: { + tooltip: "Discord Staff", + icon: "/public/badges/discord/STAFF.svg", + }, + PARTNER: { + tooltip: "Discord Partner", + icon: "/public/badges/discord/PARTNER.svg", + }, + CERTIFIED_MODERATOR: { + tooltip: "Certified Moderator", + icon: "/public/badges/discord/CERTIFIED_MODERATOR.svg", + }, + + VERIFIED_DEVELOPER: { + tooltip: "Verified Bot Developer", + icon: "/public/badges/discord/VERIFIED_DEVELOPER.svg", + }, + ACTIVE_DEVELOPER: { + tooltip: "Active Developer", + icon: "/public/badges/discord/ACTIVE_DEVELOPER.svg", + }, + + PREMIUM_EARLY_SUPPORTER: { + tooltip: "Premium Early Supporter", + icon: "/public/badges/discord/PREMIUM_EARLY_SUPPORTER.svg", + }, + + BUG_HUNTER_LEVEL_1: { + tooltip: "Bug Hunter (Level 1)", + icon: "/public/badges/discord/BUG_HUNTER_LEVEL_1.svg", + }, + BUG_HUNTER_LEVEL_2: { + tooltip: "Bug Hunter (Level 2)", + icon: "/public/badges/discord/BUG_HUNTER_LEVEL_2.svg", + }, + + SUPPORTS_COMMANDS: { + tooltip: "Supports Commands", + icon: "/public/badges/discord/SUPPORTS_COMMANDS.svg", + }, + USES_AUTOMOD: { + tooltip: "Uses AutoMod", + icon: "/public/badges/discord/USES_AUTOMOD.svg", + }, +}; diff --git a/config/environment.ts b/config/environment.ts index 7591352..6b056d6 100644 --- a/config/environment.ts +++ b/config/environment.ts @@ -34,4 +34,10 @@ export const badgeServices: badgeURLMap[] = [ `https://raw.githubusercontent.com/enmity-mod/badges/main/data/${id}.json`, }), }, + { + service: "Discord", + url: (userId: string) => `https://discord.com/api/v10/users/${userId}`, + }, ]; + +export const botToken: string | undefined = process.env.DISCORD_TOKEN; diff --git a/public/badges/discord/ACTIVE_DEVELOPER.svg b/public/badges/discord/ACTIVE_DEVELOPER.svg new file mode 100644 index 0000000..80aa677 --- /dev/null +++ b/public/badges/discord/ACTIVE_DEVELOPER.svg @@ -0,0 +1,3 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" width="140" height="140" viewBox="0 0 24 24" fill="none"> +<path d="M6.47213 4L4 6.47213V17.5279L6.47217 20H17.5278L20 17.5279V6.47213L17.5279 4H6.47213ZM10.8582 16.4255H8.64551C8.64551 14.5952 7.1567 13.1064 5.32642 13.1064V10.8936C7.1567 10.8936 8.64551 9.40483 8.64551 7.57454H10.8582C10.8582 9.39042 9.96684 10.9908 8.61129 12C9.96684 13.0093 10.8582 14.6096 10.8582 16.4255ZM18.6667 13.1064C16.8364 13.1064 15.3476 14.5952 15.3476 16.4255H13.1348C13.1348 14.6096 14.0263 13.0093 15.3818 12C14.0263 10.9908 13.1348 9.39042 13.1348 7.57454H15.3476C15.3476 9.40483 16.8364 10.8936 18.6667 10.8936V13.1064V13.1064Z" fill="#2EA967"/> +</svg> \ No newline at end of file diff --git a/public/badges/discord/BUG_HUNTER_LEVEL_1.svg b/public/badges/discord/BUG_HUNTER_LEVEL_1.svg new file mode 100644 index 0000000..ca75a4e --- /dev/null +++ b/public/badges/discord/BUG_HUNTER_LEVEL_1.svg @@ -0,0 +1 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="140" viewBox="0 0 24 24" width="140"><path d="m16.5822 2.63812s7.6721 5.23623 4.7567 12.58868c-2.9154 7.3525-8.7142 5.313-6.5469 3.1648 2.1674-2.1482-2.5573-3.6059-5.58143-6.3935l7.36523-9.35998" fill="#3ba55c"/><path d="m16.1155 9.83717c-1.6175 2.05873-3.9 3.08803-5.6646 2.71723l-6.15684 7.8447c-.10362.1324-.23231.243-.37871.3256-.1464.0825-.30764.1354-.47451.1556-.16686.0202-.33606.0073-.49793-.038-.16187-.0452-.31322-.122-.44541-.2258-.13374-.1032-.2457-.2319-.32942-.3786s-.13754-.3086-.15834-.4762c-.02081-.1677-.00819-.3378.03712-.5005s.12242-.3149.22687-.4476l6.12492-7.832c-.81197-1.62394-.36443-4.11099 1.27869-6.18886 2.03946-2.58295 5.11476-3.54836 6.89856-2.15459 1.7837 1.39377 1.5664 4.61607-.4604 7.19902z" fill="#b4e1cd"/></svg> \ No newline at end of file diff --git a/public/badges/discord/BUG_HUNTER_LEVEL_2.svg b/public/badges/discord/BUG_HUNTER_LEVEL_2.svg new file mode 100644 index 0000000..1c80182 --- /dev/null +++ b/public/badges/discord/BUG_HUNTER_LEVEL_2.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="140" viewBox="0 0 24 24" width="140"><mask id="a" height="19" maskUnits="userSpaceOnUse" width="16" x="2" y="2"><path d="m16.1438 9.84735c-1.6048 2.04975-3.9088 3.08265-5.7044 2.70125l-6.14926 7.8813c-.44491.572-1.22351.6356-1.79554.1907-.57203-.445-.63558-1.2235-.25423-1.7956l6.1493-7.8177c-.82626-1.60486-.38135-4.09954 1.28707-6.21286 2.04976-2.57413 5.11646-3.52751 6.91196-2.19278 1.7956 1.33473 1.5413 4.6239-.4449 7.24569z" fill="#ffd56c"/></mask><path d="m16.5888 2.60168s7.6906 5.25949 4.7351 12.63232c-2.9555 7.3728-8.7235 5.323-6.5307 3.1461s-2.5582-3.591-5.57726-6.4194z" fill="#ffeac0"/><path d="m16.1438 9.84735c-1.6048 2.04975-3.9088 3.08265-5.7044 2.70125l-6.14926 7.8813c-.44491.572-1.22351.6356-1.79554.1907-.57203-.445-.63558-1.2235-.25423-1.7956l6.1493-7.8177c-.82626-1.60486-.38135-4.09954 1.28707-6.21286 2.04976-2.57413 5.11646-3.52751 6.91196-2.19278 1.7956 1.33473 1.5413 4.6239-.4449 7.24569z" fill="#ffd56c"/><g fill="#fff" mask="url(#a)"><path d="m13.0389-1.26782.7405.09754-3.1567 23.96118-.74043-.0976z"/><path d="m14.2822-1.51801 1.6226.21377-3.1566 23.96114-1.6226-.2137z"/></g></svg> \ No newline at end of file diff --git a/public/badges/discord/CERTIFIED_MODERATOR.svg b/public/badges/discord/CERTIFIED_MODERATOR.svg new file mode 100644 index 0000000..6f634b2 --- /dev/null +++ b/public/badges/discord/CERTIFIED_MODERATOR.svg @@ -0,0 +1 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="140" viewBox="0 0 24 24" width="140"><path d="m17.2719 3h-9.54383c-.14912 1.9386-1.78947 3.42982-3.72807 3.42982v.89474c0 4.39914 2.08772 8.50004 5.74123 11.40794l2.75877 2.1622 2.7588-2.1622c3.6535-2.8334 5.7412-7.0088 5.7412-11.40794v-.89474c-1.9386 0-3.5044-1.49122-3.7281-3.42982zm-6.4868 12.8991c-2.23685-1.7895-3.57896-4.3245-3.57896-7.08331v-.52193c1.19298 0 2.23684-.89474 2.3114-2.08772h2.98246v11.10966z" fill="#FC964B"/></svg> \ No newline at end of file diff --git a/public/badges/discord/HYPESQUAD.svg b/public/badges/discord/HYPESQUAD.svg new file mode 100644 index 0000000..85bec04 --- /dev/null +++ b/public/badges/discord/HYPESQUAD.svg @@ -0,0 +1 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="140" viewBox="0 0 24 24" width="140"><g fill="#fbb848"><path d="m21.5912 6.84349-7.8694 5.16551c-.1351.088-.2444.2103-.317.3543l-1.1997 2.4056c-.0174.0399-.0461.0739-.0825.0977-.0364.0239-.079.0366-.1226.0366s-.0862-.0127-.1226-.0366c-.0364-.0238-.0651-.0578-.0825-.0977l-1.1997-2.4056c-.0726-.144-.1819-.2663-.317-.3543l-7.86944-5.16551c-.03957-.04698-.09618-.07632-.15738-.08157-.0612-.00524-.12198.01404-.16896.0536-.04698.03957-.07633.09618-.08157.15738-.00525.0612.01403.12198.0536.16896l3.28825 6.39624c.01598.0335.02385.0703.02297.1074s-.01049.0734-.02804.1061c-.01756.0327-.04257.0608-.07301.082-.03043.0212-.06544.035-.10219.0402h-1.97668c-.04881-.0005-.0965.0146-.13617.043-.03967.0285-.06926.0688-.08449.1152s-.0153.0964-.00022.1428c.01509.0464.04455.0869.08413.1154l8.8142 6.3155c.0403.0275.088.0422.1368.0422s.0965-.0147.1368-.0422l8.8142-6.3155c.0396-.0285.069-.069.0841-.1154s.015-.0964-.0002-.1428-.0448-.0867-.0845-.1152c-.0396-.0284-.0873-.0435-.1362-.043h-1.9766c-.0389-.0015-.0769-.0126-.1105-.0323-.0335-.0197-.0617-.0474-.082-.0806s-.0321-.071-.0343-.1098c-.0022-.0389.0052-.0777.0216-.113l3.3132-6.39624c.0395-.04698.0588-.10776.0536-.16896-.0053-.0612-.0346-.11781-.0816-.15738-.047-.03956-.1078-.05884-.169-.0536-.0612.00525-.1178.03459-.1574.08157z"/><path d="m12.1741 2.10696.8081 1.64723c.0143.02721.0346.05084.0594.06913.0247.01829.0533.03078.0835.03654l1.8213.26107c.0356.00524.0691.02036.0966.04366s.0479.05383.0589.08814.0122.07102.0034.10595c-.0089.03494-.0273.06671-.0532.0917l-1.3178 1.28049c-.0213.02203-.0373.04854-.047.07758s-.0127.05988-.009.09025l.3108 1.80885c.0069.03487.0036.07096-.0094.10404-.013.03307-.0351.06174-.0639.08264-.0287.0209-.0628.03315-.0983.03532-.0354.00217-.0708-.00584-.1019-.02309l-1.6285-.85159c-.0265-.01527-.0565-.02331-.0871-.02331-.0305 0-.0605.00804-.087.02331l-1.6286.85159c-.031.01725-.0664.02526-.1019.02309-.0354-.00217-.0695-.01442-.0983-.03532-.0287-.0209-.0509-.04957-.0639-.08264-.0129-.03308-.0162-.06917-.0094-.10404l.3108-1.80885c.0038-.03037.0008-.06121-.0089-.09025s-.0258-.05555-.047-.07758l-1.31781-1.28049c-.02595-.02499-.04438-.05676-.05318-.0917-.00881-.03493-.00764-.07164.00336-.10595s.03141-.06484.05889-.08814c.02749-.0233.06095-.03842.0966-.04366l1.82124-.25485c.0303-.00576.0588-.01825.0836-.03654.0247-.01829.045-.04192.0594-.06913l.8081-1.64723c.015-.03321.0392-.06147.0696-.08149.0305-.02003.066-.03101.1025-.03166.0364-.00065.0723.00905.1035.02798.0311.01893.0563.0463.0725.07895z"/></g></svg> \ No newline at end of file diff --git a/public/badges/discord/HYPESQUAD_ONLINE_HOUSE_1.svg b/public/badges/discord/HYPESQUAD_ONLINE_HOUSE_1.svg new file mode 100644 index 0000000..91fd024 --- /dev/null +++ b/public/badges/discord/HYPESQUAD_ONLINE_HOUSE_1.svg @@ -0,0 +1 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="140" viewBox="0 0 24 24" width="140"><path clip-rule="evenodd" d="m5.01502 4h13.97008c.1187 0 .215.09992.215.22305v9.97865c0 .0697-.0312.1343-.0837.1767l-6.985 5.5752c-.0389.0313-.0847.0464-.1314.0464-.0466 0-.0924-.0151-.1313-.0464l-6.985-5.5752c-.05252-.0424-.08365-.107-.08365-.1767v-9.97865c0-.12313.0963-.22305.21497-.22305zm7.82148 7.0972 4.1275-2.71296c.1039-.06863.2299.04542.1725.15644l-1.7114 3.36192c-.0403.0807.0182.1756.1079.1756h1.0246c.118 0 .1664.1504.0706.219l-4.6267 3.3175c-.0414.0303-.0978.0303-.1402 0l-4.6267-3.3175c-.0948-.0686-.04639-.219.07059-.219h1.02356c.09076 0 .14925-.0949.10791-.1756l-1.71132-3.36293c-.05648-.11001.06958-.22305.17345-.15543l4.12851 2.71296c.0716.0474.1291.112.1674.1887l.6293 1.2636c.0444.0888.1714.0888.2158 0l.6293-1.2636c.0383-.0767.0958-.1423.1674-.1887z" fill="#9c84ef" fill-rule="evenodd"/></svg> \ No newline at end of file diff --git a/public/badges/discord/HYPESQUAD_ONLINE_HOUSE_2.svg b/public/badges/discord/HYPESQUAD_ONLINE_HOUSE_2.svg new file mode 100644 index 0000000..d0713bb --- /dev/null +++ b/public/badges/discord/HYPESQUAD_ONLINE_HOUSE_2.svg @@ -0,0 +1 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="140" viewBox="0 0 24 24" width="140"><path clip-rule="evenodd" d="m12 20c4.4183 0 8-3.5817 8-8 0-4.41828-3.5817-8-8-8-4.41828 0-8 3.58172-8 8 0 4.4183 3.58172 8 8 8zm.7921-8.275 3.6146-2.3738c.0909-.05916.2013.03974.151.136l-1.4986 2.9416c-.0354.0707.0158.1537.0944.1537h.8973c.1033 0 .1457.1315.0618.1916l-4.0517 2.9027c-.0362.0265-.0856.0265-.1227 0l-4.05168-2.9027c-.08301-.0601-.04062-.1916.06182-.1916h.89634c.07948 0 .1307-.083.09449-.1537l-1.49862-2.9416c-.04945-.09626.06094-.19516.1519-.136l3.61545 2.3738c.0627.0415.113.098.1465.1651l.5511 1.1057c.0389.0777.1501.0777.189 0l.551-1.1057c.0336-.0671.0839-.1245.1466-.1651z" fill="#f47b67" fill-rule="evenodd"/></svg> \ No newline at end of file diff --git a/public/badges/discord/HYPESQUAD_ONLINE_HOUSE_3.svg b/public/badges/discord/HYPESQUAD_ONLINE_HOUSE_3.svg new file mode 100644 index 0000000..01e4805 --- /dev/null +++ b/public/badges/discord/HYPESQUAD_ONLINE_HOUSE_3.svg @@ -0,0 +1 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="140" viewBox="0 0 24 24" width="140"><path clip-rule="evenodd" d="m11.8622 4.05696c.076-.07595.1996-.07595.2756 0l7.8048 7.80474c.0371.0362.0574.0865.0574.1377 0 .0513-.0212.1016-.0574.1378l-7.8048 7.8047c-.038.038-.0883.0574-.1378.0574s-.0998-.0194-.1378-.0574l-7.8048-7.8047c-.03709-.0362-.0574-.0857-.0574-.1378s.02031-.1015.0574-.1377zm.9299 8.29474 3.6146-2.37377c.0909-.05917.2013.03977.151.13597l-1.4986 2.9416c-.0354.0707.0158.1537.0944.1537h.8973c.1033 0 .1457.1316.0618.1916l-4.0517 2.9028c-.0362.0265-.0856.0265-.1227 0l-4.05168-2.9028c-.08301-.06-.04062-.1916.06182-.1916h.89634c.07948 0 .1307-.083.09449-.1537l-1.49862-2.9416c-.04945-.0962.06094-.19514.1519-.13597l3.61545 2.37377c.0627.0415.113.098.1465.1651l.5511 1.1057c.0389.0777.1501.0777.189 0l.551-1.1057c.0336-.0671.0839-.1245.1466-.1651z" fill="#45ddc0" fill-rule="evenodd"/></svg> \ No newline at end of file diff --git a/public/badges/discord/NITRO.svg b/public/badges/discord/NITRO.svg new file mode 100644 index 0000000..98b54ab --- /dev/null +++ b/public/badges/discord/NITRO.svg @@ -0,0 +1 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="140" viewBox="0 0 24 24" width="140"><circle cx="15" cy="12" fill="#fff" r="6"/><path clip-rule="evenodd" d="m2.20812 10.124c.42636 0 .7816-.34817.7816-.76611 0-.41793-.35524-.76615-.7816-.76615h-.42635c-.42636 0-.78177.34822-.78177.76615 0 .41794.35541.76611.78177.76611zm16.13038 9.2643c4.0504-1.811 5.7558-6.4083 3.9083-10.23937-1.2791-2.71657-3.9793-4.31859-6.8217-4.45801h-8.02965c-.71065 0-1.20812.55735-1.20812 1.18425 0 .69645.56859 1.18409 1.20812 1.18409h2.06067c.42635 0 .78158.34822.78158.76616 0 .41793-.35523.76632-.78158.76632h-5.04517c-.42635 0-.78176.34822-.78176.76615 0 .41794.35541.76611.78176.76611h3.62404c.42635 0 .78159.3484.78159.7664 0 .4179-.35524.7661-.78159.7661h-2.27402c-.42636 0-.7816.3482-.7816.7662 0 .4179.35524.7663.7816.7663h1.56336c.07112.8359.2843 1.6717.63954 2.4379 1.77654 3.8311 6.46643 5.5028 10.37463 3.7614zm-7.2725-5.1884c-1.0318-2.2025-.0466-4.80794 2.2003-5.81933 2.2469-1.0114 4.9049-.04564 5.9366 2.15683 1.0318 2.2025.0468 4.8079-2.2003 5.8193-2.2469 1.0114-4.9048.0457-5.9366-2.1568z" fill="#4f5d7f" fill-rule="evenodd"/><path d="m16.8142 9.86662 1.4212 2.36838c.0711.1392.0711.2089 0 .3482l-1.4212 2.3683c-.0711.1393-.2131.1393-.2842.1393h-2.7714c-.142 0-.2131-.0697-.2841-.1393l-1.4213-2.3683c-.0709-.1393-.0709-.209 0-.3482l1.4213-2.36838c.071-.13926.2132-.13926.2841-.13926h2.7714c.1422-.06971.2131 0 .2842.13926z" fill="#c5cedd"/></svg> \ No newline at end of file diff --git a/public/badges/discord/PARTNER.svg b/public/badges/discord/PARTNER.svg new file mode 100644 index 0000000..35facaf --- /dev/null +++ b/public/badges/discord/PARTNER.svg @@ -0,0 +1 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="140" viewBox="0 0 24 24" width="140"><g fill="#5865f2"><path d="m16.6033 9.15179-2.4908 1.66051c-.249.2491-.6642.1661-.7472 0-.2491-.2491-.6642-.4151-.9133-.4982-.6642-.166-1.2454 0-1.7435.2491l-.83027.5812-4.64945 2.9889c-.99631.6642-2.2417.4152-2.9059-.6642-.66421-1.0793-.24908-2.2417.74723-2.8228l5.31365-3.65318c1.49447-.83026 3.23804-1.24539 4.89854-.83026 1.4114.24907 2.6568.99631 3.4871 2.15867.249.16605.249.66421-.1661.83026z"/><path d="m22 11.6425c0 .7473-.4152 1.4115-.9963 1.7436l-5.4797 3.5701c-.9964.6642-2.2417.9963-3.4041.9963-.4982 0-.9963 0-1.4114-.166-1.41148-.2491-2.49081-1.1624-3.48712-2.1587-.16606-.1661-.16606-.6642.16605-.7473l2.49077-1.6605c.2491-.249.6642-.166.7472 0 .2491.2491.4982.4152.9133.4982.6642.166 1.2454 0 1.7436-.2491l1.2453-.7472 3.7362-2.4908.4982-.41513c.9963-.6642 2.2417-.41512 2.9059.66423.166.4151.3321.7472.3321 1.1623z"/></g></svg> \ No newline at end of file diff --git a/public/badges/discord/PREMIUM_EARLY_SUPPORTER.svg b/public/badges/discord/PREMIUM_EARLY_SUPPORTER.svg new file mode 100644 index 0000000..8cd0cda --- /dev/null +++ b/public/badges/discord/PREMIUM_EARLY_SUPPORTER.svg @@ -0,0 +1 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="140" viewBox="0 0 24 24" width="140"><path d="m16.4823 15.6364h-1.2218c-.7028-.0096-1.3731-.2975-1.8639-.8006s-.7621-1.1803-.7543-1.8831v-1.2509c-.0019-.2803.1071-.5501.3033-.7504s.4636-.3148.744-.3187h5.7382v-1.49815h-10.18186c-.92363 2.08005-1.86909 4.24725-2.18181 5.09095-.20109.4955-.54642.9193-.99121 1.2162-.44479.297-.96854.4535-1.50334.4492v.8946c.40174.4023.87908.7212 1.40455.9384s1.08869.3283 1.65727.327h9.1564c.7008 0 1.373-.2779 1.8693-.7728s.776-1.1663.7779-1.8672v-.1891c-.4132.2695-.8957.4135-1.3891.4146zm-6.1309-2.0437c-.1802.0013-.35663-.0514-.50658-.1513-.14996-.0999-.26654-.2424-.33472-.4092-.06819-.1668-.08484-.3502-.04782-.5265.03702-.1764.12602-.3376.25552-.4629s.2936-.2089.471-.2401c.1775-.0312.3603-.0084.5247.0652.1644.0737.3031.1949.398.3481.0949.1531.1417.3312.1344.5113-.0093.2315-.1074.4506-.274.6118-.1665.1611-.3888.252-.6205.2536z" fill="#9cb8ff"/><path d="m19.617 10.6327h-5.92c-.1394.001-.2773.0294-.4057.0836-.1285.0543-.245.1333-.343.2326-.0979.0992-.1753.2168-.2278.346-.0524.1292-.079.2675-.078.4069v1.2509c-.0078.7028.2635 1.38.7543 1.8831s1.1611.791 1.8639.8006h2.7854c.4934-.0011.9759-.1451 1.3891-.4146l.0728-.0436c.3531-.2533.6404-.5876.8378-.9748s.2991-.8161.2967-1.2507v-1.2509c.0039-.2772-.1015-.5448-.2934-.7449s-.4549-.3166-.7321-.3242zm-2.6109 3.8327h-1.1563c-.0626.0081-.1261.0027-.1864-.0157s-.1159-.0495-.1633-.0911c-.0473-.0416-.0853-.0929-.1112-.1503-.026-.0575-.0395-.1198-.0395-.1829 0-.063.0135-.1253.0395-.1828.0259-.0574.0639-.1087.1112-.1503.0474-.0416.103-.0727.1633-.0911s.1238-.0238.1864-.0158h1.1563c.0626-.008.1261-.0026.1864.0158s.1159.0495.1633.0911c.0473.0416.0853.0929.1112.1503.026.0575.0395.1198.0395.1828 0 .0631-.0135.1254-.0395.1829-.0259.0574-.0639.1087-.1112.1503-.0474.0416-.103.0727-.1633.0911s-.1238.0238-.1864.0157zm2.0728 0h-.4437c-.1069-.0137-.2052-.066-.2764-.147s-.1105-.1851-.1105-.293c0-.1078.0393-.2119.1105-.2929s.1695-.1333.2764-.1471h.4437c.0625-.008.126-.0026.1863.0158s.116.0495.1633.0911c.0474.0416.0853.0929.1113.1503.0259.0575.0394.1198.0394.1828 0 .0631-.0135.1254-.0394.1829-.026.0574-.0639.1087-.1113.1503-.0473.0416-.103.0727-.1633.0911s-.1238.0238-.1863.0157z" fill="#cbdaf7"/><path d="m17.0061 13.5855h-1.1564c-.0625-.0081-.1261-.0027-.1864.0157s-.1159.0495-.1633.0911c-.0473.0417-.0852.0929-.1112.1503-.026.0575-.0394.1198-.0394.1829 0 .063.0134.1253.0394.1828.026.0574.0639.1087.1112.1503.0474.0416.103.0727.1633.0911s.1239.0238.1864.0158h1.1564c.0625.008.126.0026.1863-.0158s.116-.0495.1633-.0911c.0474-.0416.0853-.0929.1113-.1503.0259-.0575.0394-.1198.0394-.1828 0-.0631-.0135-.1254-.0394-.1829-.026-.0574-.0639-.1086-.1113-.1503-.0473-.0416-.103-.0727-.1633-.0911s-.1238-.0238-.1863-.0157zm2.0581 0h-.4436c-.107.0137-.2052.066-.2765.147-.0712.081-.1105.1851-.1105.293 0 .1078.0393.2119.1105.2929.0713.081.1695.1333.2765.1471h.4436c.0626.008.1261.0026.1864-.0158s.1159-.0495.1633-.0911c.0473-.0416.0853-.0929.1112-.1503.026-.0575.0395-.1198.0395-.1828 0-.0631-.0135-.1254-.0395-.1829-.0259-.0574-.0639-.1086-.1112-.1503-.0474-.0416-.103-.0727-.1633-.0911s-.1238-.0238-.1864-.0157z" fill="#9cb8ff"/><path d="m2.62786 15.1709c-.10957-.05-.21639-.1058-.32-.1673v4.2037l1.13455.7927 1.12727-.7927v-3.3164c-.71689.0255-1.41481-.2333-1.94182-.72z" fill="#ff903e"/><path d="m6.3152 13.7455c-.1373.345-.34381.6583-.6068.9205-.26298.2622-.57687.4677-.92232.604-.34546.1363-.71516.2004-1.08632.1883-.37117-.012-.73594-.0999-1.07183-.2583.52585.4893 1.22391.7508 1.94182.7273.53666-.0108 1.05762-.1831 1.49485-.4945s.77041-.7473.95606-1.251c.32727-.8291 1.27272-2.9963 2.18182-5.09089h-.92364s-1.25818 2.85819-1.96364 4.65459z" fill="#d0d9ea"/><path d="m11.5298 4 .6182.05091z" fill="#ebeff7"/><path d="m16.897 7.11273c.8756.02248 1.7483.11 2.6109.26182-.5673-.67636-2.7782-2.90909-7.3527-3.30909 3.309.79273 4.5309 2.67636 4.7418 3.04727zm-10.58184 6.63277c.70545-1.7964 1.96363-4.61095 1.96363-4.61095s2.24001-1.69454 6.85091-1.98545c-1.6073-2.18182-4.2473-2.90909-5.87636-3.08364-5.62182.60364-8.24727 4.87273-8.24727 8.27634-.033091.5186.06957 1.0368.29786 1.5036s.57432.866 1.00396 1.1582c.1036.0615.21042.1173.32.1673.33408.1592.69713.2485 1.06693.2625.36979.014.73856-.0476 1.08372-.181.34517-.1335.65948-.3359.92369-.595.26422-.2591.47278-.5694.61293-.9119zm-4.74909-2.0655c.02458-.5434.26177-1.0553.66042-1.4254.39864-.37006.92678-.5686 1.47049-.55278.53236.11535.99792.43568 1.29598.89158s.40466 1.0109.29674 1.5448c-.02451.5382-.25765 1.0458-.65 1.415-.39235.3693-.91308.5713-1.45181.5632-.26672-.053-.52036-.1581-.74635-.3094-.22599-.1512-.41989-.3456-.57057-.572-.15069-.2263-.25519-.4802-.30751-.7471-.05232-.2668-.05144-.5414.00261-.8079z" fill="#fff"/><path d="m16.1552 7.10544c-.3564 0-.7273 0-1.0328.04363-4.6109.29091-6.84359 1.98546-6.84359 1.98546h15.60729c-1.29-.93245-2.7877-1.53654-4.3637-1.76-.8626-.15183-1.7353-.23934-2.6109-.26182z" fill="#7687b2"/><path d="m3.18792 14.1164c.54495.0178 1.07495-.1799 1.47517-.5502.40023-.3703.63843-.8833.66301-1.428.10697-.5391-.00456-1.0986-.31006-1.5555s-.77995-.77374-1.31903-.88086c-.5437-.01583-1.07184.18271-1.47049.55276-.39864.3701-.63583.882-.66042 1.4254-.05404.2665-.05493.5411-.0026.8079.05232.2669.15682.5208.30751.7471.15068.2264.34458.4208.57057.572.22599.1513.47962.2564.74634.3094zm-1.28-2.3564c.00742-.1825.05112-.3617.12857-.5271s.18709-.3137.32251-.4363c.13542-.1225.29391-.2168.4662-.2775.1723-.0606.35494-.0862.53727-.0754.35402.0768.6634.2902.86088.5939.19747.3037.26707.6731.19366 1.0279-.01513.3614-.17287.7021-.43868.9475-.26581.2453-.61802.3753-.9795.3616-.35825-.0704-.67407-.2798-.87847-.5823-.20441-.3025-.28078-.6736-.21244-1.0323z" fill="#7687b2"/><path d="m2.96248 13.3745c.36148.0138.71369-.1162.9795-.3616.2658-.2453.42355-.586.43868-.9474.0734-.3548.0038-.7242-.19367-1.0279-.19748-.3037-.50686-.5171-.86088-.594-.36217-.0118-.71436.1199-.97995.3664s-.42308.588-.43823.95c-.06934.3535.00209.7201.19907 1.0216.19698.3016.50394.5144.85548.5929zm12.16002-6.21814h1.7527c-.2182-.37818-1.4545-2.25454-4.7345-3.04727l-.611-.10909h-.9163c-.4521.0002-.90378.02691-1.35274.08 1.62184.19636 4.25454.86545 5.86184 3.07636z" fill="#ff903e"/><circle cx="10.28" cy="12.75" fill="#040405" r="1"/></svg> \ No newline at end of file diff --git a/public/badges/discord/STAFF.svg b/public/badges/discord/STAFF.svg new file mode 100644 index 0000000..d65b724 --- /dev/null +++ b/public/badges/discord/STAFF.svg @@ -0,0 +1 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="140" viewBox="0 0 24 24" width="140"><g fill="#5865f2"><path d="m5.92127 6.03526s.22115-.33086.31286-.47743c.09172-.14657-.23743-.49286-.36514-.60257-.12772-.10971-.32914-.05486-.32914-.05486-1.60715.71229-2.41115 2.17372-2.52086 2.466-.10972.29229.27943.61115.56657.76715.132.072.342-.08743.47143-.20572l.04371-.04457.06772-.06857.00085-.00086 4.37229 4.35517.59743-.5975 1.09801-1.098-4.32173-4.43224z"/><path d="m16.2505 10.6294.2306-.2194 2.0717 2.052c.0146.0129.03.018.0437.018.0395 0 .072-.036.072-.036s2.2937-2.2757 2.3015-2.2834c.0677-.0669 0-.1037 0-.1037l-1.7692-1.78119-.0026.00258-.2425-.23743.1354-.13029.2897.03343-.0548-.384.0728-.07371-.1088-.55372c-.378-.53571-1.4135-1.39371-1.4135-1.39371l-.5417-.09772-.0548.07286-.408-.06086.0394.348.0257.02572-.1209.12171-.6685-.654s-3.8795-2.10686-4.086-2.20457c-.1166-.054-.2023-.09-.2846-.09-.0634 0-.1251.02143-.1963.072-.1646.11571-.0677.34886-.0677.34886l2.412 4.45714.4826.47829-.1509.15085-.0557.05572-.3857-.05315.0591.38229-.1114.11143-.0197-.01972c-.018-.018-.0429-.02742-.0669-.02742s-.048.00942-.0668.02742c-.0369.03686-.0369.09686 0 .13372l.0197.01971-.0532.054-.0137-.01457c-.0188-.018-.0428-.02743-.0668-.02743-.0249 0-.0489.00943-.0669.02743-.0368.03686-.0368.09686 0 .13372l.0146.01457-1.0149 1.02004-.0231-.0232c-.0189-.018-.0429-.0274-.0669-.0274s-.048.0094-.0668.0274c-.0369.0369-.0369.0969 0 .1337l.024.0232-.054.054-.018-.0172c-.018-.0188-.0429-.0283-.066-.0283-.0249 0-.0489.0095-.0677.0283-.036.0369-.036.096 0 .1329l.018.018-.132.1337-.018.1697.0694.0712-.0017.0008-.084.0857-5.47632 5.4755-.07114-.0592-.22714.0326-.12858.1303-.00857-.0086c-.01885-.0189-.04285-.0283-.06685-.0283s-.04886.0094-.06686.0283c-.03686.0369-.03686.096 0 .1329l.01028.0102-.05314.0549-.00514-.0051c-.018-.0189-.04286-.0283-.06686-.0283s-.048.0094-.06686.0283c-.036.0368-.036.096 0 .1328l.006.0069-1.002 1.0191-.02057-.0206c-.01885-.0188-.042-.0274-.06685-.0274-.024 0-.048.0086-.06686.0274-.03686.0369-.03686.0969 0 .1338l.02228.0214-.05314.054-.01628-.0163c-.01886-.018-.04286-.0274-.06772-.0274-.02314 0-.048.0094-.066.0274-.03686.0369-.03686.0969 0 .1337l.01714.018-.07457.0763-.38828-.0694.02914.4337-.12257.1251.10628.5846s.16286.5091.498.8469c.32486.3274.82029.4842.84172.5005l.55971.0977.138-.1354.38572.0626-.06343-.3814.11743-.1149.054.054c.018.018.042.0274.066.0274s.04885-.0094.06685-.0274c.03686-.0377.03686-.0969 0-.1337l-.05314-.0532.05486-.0531.04628.0463c.018.0188.04286.0283.06686.0283s.048-.0095.06686-.0283c.03686-.0369.03686-.096 0-.1329l-.04543-.0463 1.01743-1.0037.04457.0446c.018.0189.04286.0274.06686.0274s.048-.0085.06685-.0274c.036-.0369.036-.0969 0-.1337l-.04371-.0429.054-.054.03771.0377c.018.018.042.0275.066.0275.02486 0 .04886-.0095.06686-.0275.03686-.0368.03686-.0968 0-.1337l-.03686-.0368.114-.1115.04115-.2442-.06086-.0609.00086-.0009.11057-.1097 5.43946-5.4411-.0026-.0052.1063.1098.1706-.0189.1534-.1543.0248.0249c.0189.018.0429.0274.0669.0274s.0489-.0094.0669-.0274c.0368-.0369.0368-.0969 0-.1337l-.0249-.0249.054-.0531.0189.0188c.018.018.042.0274.0668.0274.024 0 .048-.0094.066-.0274.0369-.0368.0369-.0968 0-.1337l-.0188-.0197 1.0165-1.0183.0266.0266c.018.018.042.0274.066.0274.0249 0 .0489-.0094.0669-.0274.0368-.0369.0368-.0969 0-.1337l-.0266-.0266.054-.054.0206.0214c.0188.018.0428.0274.0668.0274s.048-.0094.0669-.0274c.0368-.0377.0368-.0968 0-.1337l-.0206-.0214.1131-.1132.378.0592z"/><path d="m17.0057 16.7793-2.4111-1.8274-.4294-.4423-1.6637 1.6637.4183.3995 1.5711 2.3562 2.1188 2.3203 2.4421-2.2783z"/></g></svg> \ No newline at end of file diff --git a/public/badges/discord/SUPPORTS_COMMANDS.svg b/public/badges/discord/SUPPORTS_COMMANDS.svg new file mode 100644 index 0000000..55e0c7b --- /dev/null +++ b/public/badges/discord/SUPPORTS_COMMANDS.svg @@ -0,0 +1 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="140" height="140" ><g fill="#2ea967"><path d="m8.1176653 16.0847263 4.8330812-8.1694527h2.9315882l-4.8330812 8.1694527z"/><path d="m20.4189453 9.4038086v-2.4311524c0-1.9775391-1.0825195-3.1118164-2.9697266-3.1118164h-1.5581055v1.7802734l.9594727-.0014648c.8540039 0 1.34375.5683594 1.34375 1.5585938v2.3969727c0 .8300781.1806641 1.8422852 1.5893555 2.3100586l.2856445.0947265-.2856445.0947266c-1.4086914.4677734-1.5893555 1.4799804-1.5893555 2.3100586v2.3964844c0 .9907227-.4897461 1.559082-1.34375 1.559082l-.9594727-.0014648v1.7802734h1.5581055c1.887207 0 2.9697266-1.1342773 2.9697266-3.1118164v-2.4316406c0-1.2583008.3432617-1.6264648 1.5810547-1.6445312v-1.9023438c-1.237793-.0180665-1.5810547-.3862305-1.5810547-1.6450196z"/><path d="m5.8061523 7.1982422c0-.9760742.5024414-1.5585938 1.3432617-1.5585938l.9594727.0014648v-1.7802734h-1.5576172c-1.887207 0-2.9697266 1.1342773-2.9697266 3.1118164v2.4311523c0 1.2587891-.3432617 1.6269531-1.581543 1.6450195v1.9023438c1.2382812.0180664 1.581543.3862305 1.581543 1.6445312v2.4316406c0 1.9775391 1.0825195 3.1118164 2.9697266 3.1118164h1.5576172v-1.7802734l-.9594727.0014648c-.8408203 0-1.3432617-.5830078-1.3432617-1.559082v-2.3964844c0-.8300781-.1806641-1.8422852-1.5898438-2.3100586l-.2856444-.0947264.2856445-.0947266c1.4091797-.4677734 1.5898437-1.4799804 1.5898437-2.3100586z"/></g></svg> \ No newline at end of file diff --git a/public/badges/discord/USES_AUTOMOD.svg b/public/badges/discord/USES_AUTOMOD.svg new file mode 100644 index 0000000..e220934 --- /dev/null +++ b/public/badges/discord/USES_AUTOMOD.svg @@ -0,0 +1,19 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" width="140" height="140" viewBox="0 0 220 220" fill="none"> +<path d="M180.722 58.0798C175.506 46.1379 169.055 36.6667 146.132 36.6667H36.8694C29.5944 36.6667 18.7723 41.3596 17.8068 58.0798C15.3012 101.469 16.2781 126.993 20.2049 146.583C24.2831 166.929 44.1677 178.981 64.9184 178.981H187.564C196.322 178.981 205.018 174.782 208.004 166.549C216.319 143.631 206.034 117.876 180.722 58.0798Z" fill="url(#paint0_linear_22_1025)"/> +<path d="M90.6762 144.86H191.447C198.128 144.86 200.541 141.52 197.386 130.756C189.471 104.369 179.863 78.5194 168.62 53.369C160.826 36.6667 155.259 36.6667 139.67 36.6667H35.6316C58.7794 36.6667 59.5827 36.6667 70.2622 130.756C73.2315 144.86 77.4999 144.86 90.6762 144.86Z" fill="url(#paint1_linear_22_1025)"/> +<path d="M157.91 86.3648C162.376 84.8532 163.891 77.4104 161.295 69.7408C158.699 62.0713 152.975 57.0792 148.509 58.5908C144.043 60.1024 142.527 67.5452 145.123 75.2148C147.719 82.8843 153.444 87.8764 157.91 86.3648Z" fill="#57F287"/> +<path d="M91.6027 86.6163C96.1379 84.9924 97.5738 77.4181 94.8098 69.6985C92.0458 61.9789 86.1286 57.0373 81.5933 58.6612C77.058 60.285 75.6221 67.8594 78.3862 75.579C81.1502 83.2985 87.0674 88.2401 91.6027 86.6163Z" fill="#57F287"/> +<path d="M152.846 102.364C153.402 117.024 146.165 127.603 133.916 127.603C121.668 127.603 107.935 117.024 99.7692 102.364H152.846Z" fill="#57F287"/> +<defs> +<linearGradient id="paint0_linear_22_1025" x1="73.3332" y1="220" x2="145.088" y2="55.3344" gradientUnits="userSpaceOnUse"> +<stop offset="0.180208" stop-color="#3442D9"/> +<stop offset="0.747916" stop-color="#737FFF"/> +</linearGradient> +<linearGradient id="paint1_linear_22_1025" x1="103.296" y1="47.3376" x2="125.974" y2="142.151" gradientUnits="userSpaceOnUse"> +<stop/> +<stop offset="0.11" stop-color="#050409"/> +<stop offset="0.7" stop-color="#1B1934"/> +<stop offset="1" stop-color="#242145"/> +</linearGradient> +</defs> +</svg> \ No newline at end of file diff --git a/public/badges/discord/VERIFIED_DEVELOPER.svg b/public/badges/discord/VERIFIED_DEVELOPER.svg new file mode 100644 index 0000000..4ec174f --- /dev/null +++ b/public/badges/discord/VERIFIED_DEVELOPER.svg @@ -0,0 +1 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="140" viewBox="0 0 24 24" width="140"><path d="m21.58 11.4-4.28-7.39-.35-.6h-9.91l-.35.6-4.27 7.39-.35.6.35.6 4.27 7.39.35.6h9.92l.35-.6 4.28-7.39.35-.6zm-13.07-1.03-1.63 1.63 1.63 1.63v2.73l-4.36-4.36 4.37-4.37v2.74zm3.12 6.93-2.04-.63 3.1-9.98 2.04.64zm3.86-.93v-2.73l1.63-1.64-1.63-1.63v-2.74l4.36 4.37z" fill="#3e70dd"/></svg> \ No newline at end of file diff --git a/src/helpers/badges.ts b/src/helpers/badges.ts index fb0208b..68d5ce4 100644 --- a/src/helpers/badges.ts +++ b/src/helpers/badges.ts @@ -1,10 +1,12 @@ -import { badgeServices, redisTtl } from "@config/environment"; +import { discordBadgeDetails, discordBadges } from "@config/discordBadges"; +import { badgeServices, botToken, redisTtl } from "@config/environment"; import { fetch, redis } from "bun"; export async function fetchBadges( userId: string, services: string[], options?: FetchBadgesOptions, + request?: Request, ): Promise<BadgeResult> { const { nocache = false, separated = false } = options ?? {}; const results: Record<string, Badge[]> = {}; @@ -127,6 +129,38 @@ export async function fetchBadges( ); break; } + + case "discord": { + if (!botToken) break; + + const res = await fetch(url as string, { + headers: { + Authorization: `Bot ${botToken}`, + }, + }); + if (!res.ok) break; + + const data = await res.json(); + + if (data.avatar.startsWith("a_")) { + result.push({ + tooltip: "Discord Nitro", + badge: `${request ? new URL(request.url).origin : ""}/public/badges/discord/NITRO.svg`, + }); + } + + for (const [flag, bitwise] of Object.entries(discordBadges)) { + if (data.flags & bitwise) { + const badge = + discordBadgeDetails[flag as keyof typeof discordBadgeDetails]; + result.push({ + tooltip: badge.tooltip, + badge: `${request ? new URL(request.url).origin : ""}${badge.icon}`, + }); + } + } + break; + } } if (result.length > 0) { diff --git a/src/routes/[id].ts b/src/routes/[id].ts index af6a621..4b8421e 100644 --- a/src/routes/[id].ts +++ b/src/routes/[id].ts @@ -58,10 +58,15 @@ async function handler(request: ExtendedRequest): Promise<Response> { validServices = badgeServices.map((b) => b.service); } - const badges: BadgeResult = await fetchBadges(userId, validServices, { - nocache: cache !== "true", - separated: seperated === "true", - }); + const badges: BadgeResult = await fetchBadges( + userId, + validServices, + { + nocache: cache !== "true", + separated: seperated === "true", + }, + request, + ); if (badges instanceof Error) { return Response.json(