From 8ffdcf9f3d7084acd8ae075b3cf7f50055f2ca5b Mon Sep 17 00:00:00 2001 From: alfianchii Date: Mon, 29 Dec 2025 21:01:47 +0700 Subject: [PATCH 1/3] chore: file rename --- src/bot/commands/checkin/handlers/{checkin.ts => index.ts} | 0 src/bot/events/interaction-create/checkin/validators/index.ts | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/bot/commands/checkin/handlers/{checkin.ts => index.ts} (100%) diff --git a/src/bot/commands/checkin/handlers/checkin.ts b/src/bot/commands/checkin/handlers/index.ts similarity index 100% rename from src/bot/commands/checkin/handlers/checkin.ts rename to src/bot/commands/checkin/handlers/index.ts diff --git a/src/bot/events/interaction-create/checkin/validators/index.ts b/src/bot/events/interaction-create/checkin/validators/index.ts index bff1464..146bdcd 100644 --- a/src/bot/events/interaction-create/checkin/validators/index.ts +++ b/src/bot/events/interaction-create/checkin/validators/index.ts @@ -6,7 +6,7 @@ import type { CheckinStreak } from '@type/checkin-streak' import type { User } from '@type/user' import type { Attachment, Client, EmbedBuilder, Guild, GuildMember, Interaction, Message, TextChannel } from 'discord.js' import crypto from 'node:crypto' -import { CheckinError } from '@commands/checkin/handlers/checkin' +import { CheckinError } from '@commands/checkin/handlers' import { AURA_FARMING_CHANNEL, CHECKIN_CHANNEL, GRINDER_ROLE } from '@config/discord' import { SubmittedCheckinError } from '@events/message-reaction-add/checkin/handlers/submitted' import { createEmbed, decodeSnowflakes, encodeSnowflake, getCustomId } from '@utils/component' From 8164df27c4dc5c5c24e8dfe67c80a88e714f0247 Mon Sep 17 00:00:00 2001 From: alfianchii Date: Mon, 29 Dec 2025 23:48:45 +0700 Subject: [PATCH 2/3] feat: remove unused buttons after review a checkin --- .../checkin/validators/index.ts | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/bot/events/interaction-create/checkin/validators/index.ts b/src/bot/events/interaction-create/checkin/validators/index.ts index 146bdcd..09118ae 100644 --- a/src/bot/events/interaction-create/checkin/validators/index.ts +++ b/src/bot/events/interaction-create/checkin/validators/index.ts @@ -4,7 +4,7 @@ import type { Attachment as AttachmentType } from '@type/attachment' import type { CheckinAllowedEmojiType, CheckinColumn, CheckinStatusType, Checkin as CheckinType } from '@type/checkin' import type { CheckinStreak } from '@type/checkin-streak' import type { User } from '@type/user' -import type { Attachment, Client, EmbedBuilder, Guild, GuildMember, Interaction, Message, TextChannel } from 'discord.js' +import type { ActionRow, Attachment, ButtonComponent, Client, EmbedBuilder, Guild, GuildMember, Interaction, Message, TextChannel } from 'discord.js' import crypto from 'node:crypto' import { CheckinError } from '@commands/checkin/handlers' import { AURA_FARMING_CHANNEL, CHECKIN_CHANNEL, GRINDER_ROLE } from '@config/discord' @@ -38,6 +38,12 @@ export class Checkin extends CheckinMessage { '🔥': 'APPROVED', } + static readonly CHECKIN_DELETED_BUTTONS = [ + CHECKIN_APPROVE_BUTTON_ID, + CHECKIN_REJECT_BUTTON_ID, + CHECKIN_CUSTOM_BUTTON_ID, + ] + static REVERSED_EMOJI_STATUS = Object.fromEntries( Object.entries(this.EMOJI_STATUS).map(([emoji, status]) => [status, emoji]), ) as Record @@ -439,7 +445,7 @@ export class Checkin extends CheckinMessage { const message = await checkinChannel.messages.fetch(messageId) await this.validateCheckinHandleToUser(guild, flamewarden, updatedCheckin.user!.discord_id, updatedCheckin) - await message.react(this.REVERSED_EMOJI_STATUS[checkinStatus]) + await this.editSubmittedCheckinMessage(message, checkinStatus) return updatedCheckin } @@ -457,6 +463,26 @@ export class Checkin extends CheckinMessage { await this.sendCheckinStatusToMember(flamewarden, member, updatedCheckin) } + static async editSubmittedCheckinMessage(message: Message, checkinStatus: CheckinStatusType) { + await message.react(this.REVERSED_EMOJI_STATUS[checkinStatus]) + + const newRows = this.getNewButtons(message.components as ActionRow[]) + await message.edit({ components: newRows }) + } + + static getNewButtons(components: readonly ActionRow[]): ActionRowBuilder[] { + return components + .map((row) => { + const buttons = row.components + .filter(btn => btn.customId && !this.CHECKIN_DELETED_BUTTONS.some(id => btn.customId!.startsWith(id))) + .map(btn => ButtonBuilder.from(btn)) + const newRow = new ActionRowBuilder().addComponents(...buttons) + + return buttons.length ? newRow : null + }) + .filter((row): row is ActionRowBuilder => row !== null) + } + static async updateCheckinMsgLink(interaction: Interaction, prisma: PrismaClient, checkin: CheckinType, msg: Message): Promise { const msgLink = messageLink(interaction.channelId!, msg.id, interaction.guildId!) From b9004771f16e456a22c3cb8efdba6ba67d09b4ab Mon Sep 17 00:00:00 2001 From: alfianchii Date: Tue, 30 Dec 2025 12:45:16 +0700 Subject: [PATCH 3/3] fix: remove unnecessary message --- .../events/interaction-create/checkin/validators/index.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/bot/events/interaction-create/checkin/validators/index.ts b/src/bot/events/interaction-create/checkin/validators/index.ts index 09118ae..df8ad63 100644 --- a/src/bot/events/interaction-create/checkin/validators/index.ts +++ b/src/bot/events/interaction-create/checkin/validators/index.ts @@ -175,13 +175,6 @@ export class Checkin extends CheckinMessage { allowedMentions: { users: [member.id], roles: [] }, }) } - else { - const checkinChannel = await getChannel(guild, CHECKIN_CHANNEL) as TextChannel - await sendAsBot(null, checkinChannel, { - content: `Hey, <@${member.id}>. You already have <@&${newRole.id}>`, - allowedMentions: { users: [member.id], roles: [] }, - }, true) - } } static assertCheckinToday(user: User) {