Skip to content

Commit 1a501e5

Browse files
committed
feat: get custom emoji
1 parent 9d2f936 commit 1a501e5

4 files changed

Lines changed: 35 additions & 20 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"globals": "^17.7.0",
5353
"jiti": "^2.7.0",
5454
"prettier": "^3.9.5",
55-
"tsdown": "^0.22.11",
55+
"tsdown": "^0.22.12",
5656
"typescript": "^7.0.2",
5757
"typescript-eslint": "^8.64.0"
5858
}

pnpm-lock.yaml

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/StelliaClient.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from "node:fs";
22
import path from "node:path";
33
import { pathToFileURL } from "node:url";
4-
import { Client, type ClientOptions, type Interaction } from "discord.js";
4+
import { type ApplicationEmoji, Client, type ClientOptions, type Interaction } from "discord.js";
55
import { StelliaUtils } from "@client/index.js";
66
import {
77
AutoCompleteManager,
@@ -91,6 +91,10 @@ export class StelliaClient<
9191
await this.utils.initializeCustomEmojis();
9292
};
9393

94+
public getCustomEmoji = (emojiName: keyof EmojiEnum): ApplicationEmoji | undefined => {
95+
return this.utils.getCustomEmoji(String(emojiName));
96+
};
97+
9498
public getGuildsConfiguration = async (): Promise<TGuildsConfig> => {
9599
const chosenEnvironment = process.argv.find((arg) => arg.startsWith("--config"))?.split("=")[1];
96100
if (!chosenEnvironment) {

src/client/StelliaUtils.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
type AnySelectMenuInteraction,
33
ApplicationCommandType,
4+
type ApplicationEmoji,
45
type AutocompleteInteraction,
56
type ButtonInteraction,
67
type ChatInputCommandInteraction,
@@ -115,7 +116,13 @@ export class StelliaUtils<EmojiEnum extends Record<string, string> = Record<stri
115116
}
116117
};
117118

118-
public getGuildConfiguration = <CustomGuildConfiguration extends GuildConfiguration>(guildId: string): CustomGuildConfiguration | null => {
119+
public getCustomEmoji = (emojiName: string): ApplicationEmoji | undefined => {
120+
return this.client.customEmojis[emojiName];
121+
};
122+
123+
public getGuildConfiguration = <CustomGuildConfiguration extends GuildConfiguration>(
124+
guildId: string
125+
): CustomGuildConfiguration | null => {
119126
if (!this.client.environment?.areGuildsConfigurationEnabled || !this.guildsConfiguration) {
120127
return null;
121128
}
@@ -297,7 +304,9 @@ export class StelliaUtils<EmojiEnum extends Record<string, string> = Record<stri
297304
return;
298305
}
299306

300-
const selectMenu = selectMenuManager.getByCustomId(selectMenuInteraction.customId) || selectMenuManager.getByRegex(selectMenuInteraction.customId);
307+
const selectMenu =
308+
selectMenuManager.getByCustomId(selectMenuInteraction.customId) ||
309+
selectMenuManager.getByRegex(selectMenuInteraction.customId);
301310
if (!selectMenu) {
302311
return;
303312
}
@@ -320,7 +329,9 @@ export class StelliaUtils<EmojiEnum extends Record<string, string> = Record<stri
320329
}
321330
};
322331

323-
private readonly handleMessageContextMenuInteraction = async (interaction: MessageContextMenuCommandInteraction<"cached">): Promise<void> => {
332+
private readonly handleMessageContextMenuInteraction = async (
333+
interaction: MessageContextMenuCommandInteraction<"cached">
334+
): Promise<void> => {
324335
try {
325336
const contextMenuManager = this.client.managers.contextMenus;
326337
if (!contextMenuManager) {

0 commit comments

Comments
 (0)