diff --git a/src/buttons/note-next.ts b/src/buttons/note-next.ts index dcca15f..5599f88 100644 --- a/src/buttons/note-next.ts +++ b/src/buttons/note-next.ts @@ -1,15 +1,18 @@ import { ButtonInteraction, Client } from 'discord.js'; +import { Button } from '../types'; import { getNoteMessage } from '../utils'; -export default { - name: 'note-next', - handler: async function (client: Client, interaction: ButtonInteraction, userId: string, page: string) { +class NoteNextButton implements Button { + id = 'note-next'; + + async execute(context: Client, interaction: ButtonInteraction, userId: string, page: string): Promise { await interaction.deferUpdate(); const message = await getNoteMessage(userId, parseInt(page) + 1); - if (!message) return; - interaction.editReply(message); + await interaction.editReply(message); } -}; \ No newline at end of file +} + +export default new NoteNextButton(); \ No newline at end of file diff --git a/src/buttons/note-previous.ts b/src/buttons/note-previous.ts index 8e4b547..aa7857a 100644 --- a/src/buttons/note-previous.ts +++ b/src/buttons/note-previous.ts @@ -1,15 +1,18 @@ -import { ButtonInteraction, Client} from 'discord.js'; +import { ButtonInteraction, Client } from 'discord.js'; +import { Button } from '../types'; import { getNoteMessage } from '../utils'; -export default { - name: 'note-previous', - handler: async function (client: Client, interaction: ButtonInteraction, userId: string, page: string) { +class NotePreviousButton implements Button { + id = 'note-previous'; + + async execute(context: Client, interaction: ButtonInteraction, userId: string, page: string): Promise { await interaction.deferUpdate(); const message = await getNoteMessage(userId, parseInt(page) - 1); - if (!message) return; - interaction.editReply(message); + await interaction.editReply(message); } -}; \ No newline at end of file +} + +export default new NotePreviousButton(); \ No newline at end of file