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 {
if (user.bot || !reaction.message.guildId) {
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 {
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 ?? [],