(buttons): Implement note-next & note-previous buttons.

This commit is contained in:
2026-10-14 10:44:03 +08:00
parent 2f14da099d
commit e0aa68874d
2 changed files with 19 additions and 13 deletions
+9 -6
View File
@@ -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<Client> {
id = 'note-next';
async execute(context: Client<boolean>, interaction: ButtonInteraction, userId: string, page: string): Promise<void> {
await interaction.deferUpdate();
const message = await getNoteMessage(userId, parseInt(page) + 1);
if (!message) return;
interaction.editReply(message);
await interaction.editReply(message);
}
};
}
export default new NoteNextButton();
+9 -6
View File
@@ -1,15 +1,18 @@
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<Client> {
id = 'note-previous';
async execute(context: Client<boolean>, interaction: ButtonInteraction, userId: string, page: string): Promise<void> {
await interaction.deferUpdate();
const message = await getNoteMessage(userId, parseInt(page) - 1);
if (!message) return;
interaction.editReply(message);
await interaction.editReply(message);
}
};
}
export default new NotePreviousButton();