mirror of
https://github.com/nx-bat/discordbot-ng.git
synced 2026-11-11 07:13:37 -05:00
(buttons): Implement note-next & note-previous buttons.
This commit is contained in:
@@ -1,15 +1,18 @@
|
|||||||
import { ButtonInteraction, Client } from 'discord.js';
|
import { ButtonInteraction, Client } from 'discord.js';
|
||||||
|
import { Button } from '../types';
|
||||||
import { getNoteMessage } from '../utils';
|
import { getNoteMessage } from '../utils';
|
||||||
|
|
||||||
export default {
|
class NoteNextButton implements Button<Client> {
|
||||||
name: 'note-next',
|
id = 'note-next';
|
||||||
handler: async function (client: Client, interaction: ButtonInteraction, userId: string, page: string) {
|
|
||||||
|
async execute(context: Client<boolean>, interaction: ButtonInteraction, userId: string, page: string): Promise<void> {
|
||||||
await interaction.deferUpdate();
|
await interaction.deferUpdate();
|
||||||
|
|
||||||
const message = await getNoteMessage(userId, parseInt(page) + 1);
|
const message = await getNoteMessage(userId, parseInt(page) + 1);
|
||||||
|
|
||||||
if (!message) return;
|
if (!message) return;
|
||||||
|
|
||||||
interaction.editReply(message);
|
await interaction.editReply(message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default new NoteNextButton();
|
||||||
@@ -1,15 +1,18 @@
|
|||||||
import { ButtonInteraction, Client } from 'discord.js';
|
import { ButtonInteraction, Client } from 'discord.js';
|
||||||
|
import { Button } from '../types';
|
||||||
import { getNoteMessage } from '../utils';
|
import { getNoteMessage } from '../utils';
|
||||||
|
|
||||||
export default {
|
class NotePreviousButton implements Button<Client> {
|
||||||
name: 'note-previous',
|
id = 'note-previous';
|
||||||
handler: async function (client: Client, interaction: ButtonInteraction, userId: string, page: string) {
|
|
||||||
|
async execute(context: Client<boolean>, interaction: ButtonInteraction, userId: string, page: string): Promise<void> {
|
||||||
await interaction.deferUpdate();
|
await interaction.deferUpdate();
|
||||||
|
|
||||||
const message = await getNoteMessage(userId, parseInt(page) - 1);
|
const message = await getNoteMessage(userId, parseInt(page) - 1);
|
||||||
|
|
||||||
if (!message) return;
|
if (!message) return;
|
||||||
|
|
||||||
interaction.editReply(message);
|
await interaction.editReply(message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default new NotePreviousButton();
|
||||||
Reference in New Issue
Block a user