From 8ec9b94879700e9b2dd314321300d8fbff7d5cf6 Mon Sep 17 00:00:00 2001 From: smueller Date: Wed, 22 Jul 2026 13:08:58 +0200 Subject: [PATCH] Refactor reaction handling and tag response types for improved type safety - Updated the event handler for message reaction removal to enhance type safety by specifying user types. - Changed the return type of the buildTagReply function from MessageReplyOptions to InteractionReplyOptions for better compatibility with interaction responses. - Adjusted embed handling in tag creation and update functions to use undefined instead of null for consistency. --- apps/bot/src/modules/selfroles/reactions.ts | 2 +- apps/bot/src/modules/tags/service.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/bot/src/modules/selfroles/reactions.ts b/apps/bot/src/modules/selfroles/reactions.ts index 3244366..821d925 100644 --- a/apps/bot/src/modules/selfroles/reactions.ts +++ b/apps/bot/src/modules/selfroles/reactions.ts @@ -104,7 +104,7 @@ export function registerSelfRoleEvents(client: Client, context: BotContext): voi } }); - client.on(Events.MessageReactionRemove, async (reaction: PartialMessageReaction, user: PartialUser) => { + client.on(Events.MessageReactionRemove, async (reaction, user: User | PartialUser) => { try { if (user.bot || !reaction.message.guildId) { return; diff --git a/apps/bot/src/modules/tags/service.ts b/apps/bot/src/modules/tags/service.ts index 4fc17e2..d9a05ce 100644 --- a/apps/bot/src/modules/tags/service.ts +++ b/apps/bot/src/modules/tags/service.ts @@ -1,4 +1,4 @@ -import { EmbedBuilder, type Guild, type GuildMember, type MessageReplyOptions } from 'discord.js'; +import { EmbedBuilder, type Guild, type GuildMember, type InteractionReplyOptions } from 'discord.js'; import { applyTagPlaceholders, TagResponseTypeSchema, @@ -69,7 +69,7 @@ export function buildTagReply( member: GuildMember | null, guild: Guild, args: string -): MessageReplyOptions { +): InteractionReplyOptions { const vars = buildTagPlaceholderVars(member, guild, args); const responseType = TagResponseTypeSchema.parse(tag.responseType); @@ -154,7 +154,7 @@ export async function createTag( name, responseType: params.responseType, content: params.content ?? null, - embed: params.embed ?? null, + embed: params.embed ?? undefined, triggerWord: params.triggerWord?.trim() || null, allowedRoleIds: params.allowedRoleIds ?? [], allowedChannelIds: params.allowedChannelIds ?? [],