From b1045782597bda6eb871b7d276c35074d2585e15 Mon Sep 17 00:00:00 2001 From: Slincnik Date: Thu, 16 Jan 2025 18:23:51 +0300 Subject: [PATCH] fix: fixing extenders func types --- src/helpers/extenders.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/helpers/extenders.ts b/src/helpers/extenders.ts index cb1aae20..1724f301 100644 --- a/src/helpers/extenders.ts +++ b/src/helpers/extenders.ts @@ -2,7 +2,7 @@ import { BaseInteraction, CacheType, Interaction, InteractionReplyOptions, Messa import useClient from "@/utils/use-client.js"; interface Options extends InteractionReplyOptions { - prefixEmoji: string; + prefixEmoji?: string; locale?: string; edit?: boolean; mention?: boolean; @@ -20,7 +20,7 @@ const getAppEmojis = () => { return client.application.emojis.cache; }; -const formatReply = (prefixEmoji: string, message: string) => { +const formatReply = (message: string, prefixEmoji?: string) => { const emojis = getAppEmojis(); const emoji = emojis.find(emoji => emoji.name === prefixEmoji); return prefixEmoji ? `${emoji?.toString()} ${message}` : `${message}`; @@ -28,7 +28,7 @@ const formatReply = (prefixEmoji: string, message: string) => { export const getUsername = (user: User) => (user.discriminator === "0" ? user.username : user.tag); -export const replyTranslated = async (context: Interaction | Message, key: string, args: unknown[], options: Options) => { +export const replyTranslated = async (context: Interaction | Message, key: string, args: Record | null, options: Options) => { const client = useClient(); const locale = options.locale || client.configService.get("defaultLang"); const translated = client.translate(key, { @@ -36,7 +36,7 @@ export const replyTranslated = async (context: ...args, }); - const content = formatReply(options.prefixEmoji, translated); + const content = formatReply(translated, options.prefixEmoji); if (context instanceof BaseInteraction) { if (!context.isRepliable()) return; @@ -65,12 +65,10 @@ export const replyTranslated = async (context: }); }; -export const replySuccess = async (context: Interaction | Message, key: string, args: unknown[], options: Options) => { - options.prefixEmoji = "success"; - return await replyTranslated(context, key, args, options); -}; +export const replySuccess = async +(context: Interaction | Message, key: string, args: Record | null, + options: Options = { prefixEmoji: "success" }) => await replyTranslated(context, key, args, options); -export const replyError = async (context: Interaction | Message, key: string, args: unknown[], options: Options) => { - options.prefixEmoji = "error"; - return await replyTranslated(context, key, args, options); -}; +export const replyError = async +(context: Interaction | Message, key: string, args: Record | null, + options: Options = { prefixEmoji: "error" }) => await replyTranslated(context, key, args, options);