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.
This commit is contained in:
smueller
2026-07-22 13:08:58 +02:00
parent a583db7a15
commit 8ec9b94879
2 changed files with 4 additions and 4 deletions

View File

@@ -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 { try {
if (user.bot || !reaction.message.guildId) { if (user.bot || !reaction.message.guildId) {
return; return;

View File

@@ -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 { import {
applyTagPlaceholders, applyTagPlaceholders,
TagResponseTypeSchema, TagResponseTypeSchema,
@@ -69,7 +69,7 @@ export function buildTagReply(
member: GuildMember | null, member: GuildMember | null,
guild: Guild, guild: Guild,
args: string args: string
): MessageReplyOptions { ): InteractionReplyOptions {
const vars = buildTagPlaceholderVars(member, guild, args); const vars = buildTagPlaceholderVars(member, guild, args);
const responseType = TagResponseTypeSchema.parse(tag.responseType); const responseType = TagResponseTypeSchema.parse(tag.responseType);
@@ -154,7 +154,7 @@ export async function createTag(
name, name,
responseType: params.responseType, responseType: params.responseType,
content: params.content ?? null, content: params.content ?? null,
embed: params.embed ?? null, embed: params.embed ?? undefined,
triggerWord: params.triggerWord?.trim() || null, triggerWord: params.triggerWord?.trim() || null,
allowedRoleIds: params.allowedRoleIds ?? [], allowedRoleIds: params.allowedRoleIds ?? [],
allowedChannelIds: params.allowedChannelIds ?? [], allowedChannelIds: params.allowedChannelIds ?? [],