From e87be791eb47906648b45ff6e4a7a5bbb8bf27b9 Mon Sep 17 00:00:00 2001 From: Nix Krystik Date: Wed, 14 Oct 2026 11:46:48 +0800 Subject: [PATCH] (buttons): Implement `records-next` & `records-previous` buttons. --- src/buttons/records-next.ts | 15 +++++++++------ src/buttons/records-previous.ts | 17 ++++++++++------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/buttons/records-next.ts b/src/buttons/records-next.ts index 9d909f0..5e89d76 100644 --- a/src/buttons/records-next.ts +++ b/src/buttons/records-next.ts @@ -1,15 +1,18 @@ import { ButtonInteraction, Client } from 'discord.js'; +import { Button } from '../types'; import { getRecordMessageFromDiscordId } from '../utils'; -export default { - name: 'records-next', - handler: async function (client: Client, interaction: ButtonInteraction, userId: string, page: string) { +class RecordsNextButton implements Button { + id = 'records-next'; + + async execute(context: Client, interaction: ButtonInteraction, userId: string, page: string): Promise { await interaction.deferUpdate(); const message = await getRecordMessageFromDiscordId(userId, parseInt(page) + 1, interaction.guild!); - if (!message) return; - interaction.editReply(message); + await interaction.editReply(message); } -}; \ No newline at end of file +} + +export default new RecordsNextButton(); \ No newline at end of file diff --git a/src/buttons/records-previous.ts b/src/buttons/records-previous.ts index 67b47e2..84c4a75 100644 --- a/src/buttons/records-previous.ts +++ b/src/buttons/records-previous.ts @@ -1,15 +1,18 @@ -import { ButtonInteraction, Client} from 'discord.js'; +import { ButtonInteraction, Client } from 'discord.js'; +import { Button } from '../types'; import { getRecordMessageFromDiscordId } from '../utils'; -export default { - name: 'records-previous', - handler: async function (client: Client, interaction: ButtonInteraction, userId: string, page: string) { +class RecordsPreviousButton implements Button { + id = 'records-previous'; + + async execute(context: Client, interaction: ButtonInteraction, userId: string, page: string): Promise { await interaction.deferUpdate(); const message = await getRecordMessageFromDiscordId(userId, parseInt(page) - 1, interaction.guild!); - if (!message) return; - interaction.editReply(message); + await interaction.editReply(message); } -}; \ No newline at end of file +} + +export default new RecordsPreviousButton(); \ No newline at end of file