From 09819f796360fa009bbcc22ead68d94a82624a90 Mon Sep 17 00:00:00 2001 From: Tweenty Date: Mon, 20 Jul 2026 16:14:13 +0200 Subject: [PATCH] feat: get custom emoji --- package.json | 2 +- pnpm-lock.yaml | 30 +++++++++++++++--------------- src/client/StelliaClient.ts | 6 +++++- src/client/StelliaUtils.ts | 17 ++++++++++++++--- 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 3d99585..648050a 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "globals": "^17.7.0", "jiti": "^2.7.0", "prettier": "^3.9.5", - "tsdown": "^0.22.11", + "tsdown": "^0.22.12", "typescript": "^7.0.2", "typescript-eslint": "^8.64.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b210c5d..c837af2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -43,8 +43,8 @@ importers: specifier: ^3.9.5 version: 3.9.5 tsdown: - specifier: ^0.22.11 - version: 0.22.11(typescript@7.0.2) + specifier: ^0.22.12 + version: 0.22.12(typescript@7.0.2) typescript: specifier: ^7.0.2 version: 7.0.2 @@ -1035,10 +1035,6 @@ packages: natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} - obug@2.1.3: - resolution: {integrity: sha512-9miFgM2OFba7hB+pRgvtV84pYTBaoTHohvmIgiRt6dRIzbwEOIaNaP+dIlGs2fNFoB0SeISs0Jz5WFVRid6Xyg==} - engines: {node: '>=12.20.0'} - obug@2.1.4: resolution: {integrity: sha512-4a+OsYv9UktOJKE+l1A4OufDgdRF9PifWj+tJnHURo/P+WOxpG4GzUFL9qCalmWauao6ogiG+QvnCovwPoyAWA==} engines: {node: '>=12.20.0'} @@ -1148,14 +1144,14 @@ packages: ts-mixer@6.0.4: resolution: {integrity: sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==} - tsdown@0.22.11: - resolution: {integrity: sha512-BERdQpqAltv3vYGC0pE4n+mRGPIN91T/on+Ud73bYRkbptknelFm27tJgBBUz4RJ5d3VNeVH90HfjBo1Ouj8yQ==} + tsdown@0.22.12: + resolution: {integrity: sha512-IzGRfGwSsufXJWOcQ0tmECKMG/dbxhUwDOySTS7JE1AM8pkB9+bpcTPs8bTxxSNrSvGocSczrBlOh97tZObq9Q==} engines: {node: ^22.18.0 || >=24.11.0} hasBin: true peerDependencies: '@arethetypeswrong/core': ^0.18.1 - '@tsdown/css': 0.22.11 - '@tsdown/exe': 0.22.11 + '@tsdown/css': 0.22.12 + '@tsdown/exe': 0.22.12 '@vitejs/devtools': '*' publint: ^0.3.8 tsx: '*' @@ -1221,6 +1217,10 @@ packages: uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + verkit@0.1.2: + resolution: {integrity: sha512-WqkT8n3hqizuCu71W3bUzf5fjBmkbXcudsehe/NbxA8PgqoKnSOY5K0Ba2ckg1qaRaSpSz7as/n9K1R9JXjQKg==} + engines: {node: '>=18.12.0'} + which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} @@ -2079,8 +2079,6 @@ snapshots: natural-compare@1.4.0: {} - obug@2.1.3: {} - obug@2.1.4: {} optionator@0.9.4: @@ -2120,7 +2118,7 @@ snapshots: dependencies: dts-resolver: 3.0.0 get-tsconfig: 5.0.0-beta.5 - obug: 2.1.3 + obug: 2.1.4 rolldown: 1.2.0 yuku-ast: 0.1.7 yuku-codegen: 0.6.1 @@ -2176,7 +2174,7 @@ snapshots: ts-mixer@6.0.4: {} - tsdown@0.22.11(typescript@7.0.2): + tsdown@0.22.12(typescript@7.0.2): dependencies: ansis: 4.3.1 cac: 7.0.0 @@ -2188,11 +2186,11 @@ snapshots: picomatch: 4.0.5 rolldown: 1.2.0 rolldown-plugin-dts: 0.27.9(rolldown@1.2.0)(typescript@7.0.2) - semver: 7.8.5 tinyexec: 1.2.4 tinyglobby: 0.2.17 tree-kill: 1.2.2 unconfig-core: 7.5.0 + verkit: 0.1.2 optionalDependencies: typescript: 7.0.2 transitivePeerDependencies: @@ -2283,6 +2281,8 @@ snapshots: dependencies: punycode: 2.3.1 + verkit@0.1.2: {} + which@2.0.2: dependencies: isexe: 2.0.0 diff --git a/src/client/StelliaClient.ts b/src/client/StelliaClient.ts index 2a8a01d..38c7610 100644 --- a/src/client/StelliaClient.ts +++ b/src/client/StelliaClient.ts @@ -1,7 +1,7 @@ import fs from "node:fs"; import path from "node:path"; import { pathToFileURL } from "node:url"; -import { Client, type ClientOptions, type Interaction } from "discord.js"; +import { type ApplicationEmoji, Client, type ClientOptions, type Interaction } from "discord.js"; import { StelliaUtils } from "@client/index.js"; import { AutoCompleteManager, @@ -91,6 +91,10 @@ export class StelliaClient< await this.utils.initializeCustomEmojis(); }; + public getCustomEmoji = (emojiName: keyof EmojiEnum): ApplicationEmoji | undefined => { + return this.utils.getCustomEmoji(String(emojiName)); + }; + public getGuildsConfiguration = async (): Promise => { const chosenEnvironment = process.argv.find((arg) => arg.startsWith("--config"))?.split("=")[1]; if (!chosenEnvironment) { diff --git a/src/client/StelliaUtils.ts b/src/client/StelliaUtils.ts index 6fe3d6c..5edd3f4 100644 --- a/src/client/StelliaUtils.ts +++ b/src/client/StelliaUtils.ts @@ -1,6 +1,7 @@ import { type AnySelectMenuInteraction, ApplicationCommandType, + type ApplicationEmoji, type AutocompleteInteraction, type ButtonInteraction, type ChatInputCommandInteraction, @@ -115,7 +116,13 @@ export class StelliaUtils = Record(guildId: string): CustomGuildConfiguration | null => { + public getCustomEmoji = (emojiName: string): ApplicationEmoji | undefined => { + return this.client.customEmojis[emojiName]; + }; + + public getGuildConfiguration = ( + guildId: string + ): CustomGuildConfiguration | null => { if (!this.client.environment?.areGuildsConfigurationEnabled || !this.guildsConfiguration) { return null; } @@ -297,7 +304,9 @@ export class StelliaUtils = Record = Record): Promise => { + private readonly handleMessageContextMenuInteraction = async ( + interaction: MessageContextMenuCommandInteraction<"cached"> + ): Promise => { try { const contextMenuManager = this.client.managers.contextMenus; if (!contextMenuManager) {