mirror of
https://github.com/nx-bat/discordbot-ng.git
synced 2026-11-11 07:13:37 -05:00
(buttons): Implement records-next & records-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 { getRecordMessageFromDiscordId } from '../utils';
|
import { getRecordMessageFromDiscordId } from '../utils';
|
||||||
|
|
||||||
export default {
|
class RecordsNextButton implements Button<Client> {
|
||||||
name: 'records-next',
|
id = 'records-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 getRecordMessageFromDiscordId(userId, parseInt(page) + 1, interaction.guild!);
|
const message = await getRecordMessageFromDiscordId(userId, parseInt(page) + 1, interaction.guild!);
|
||||||
|
|
||||||
if (!message) return;
|
if (!message) return;
|
||||||
|
|
||||||
interaction.editReply(message);
|
await interaction.editReply(message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default new RecordsNextButton();
|
||||||
@@ -1,15 +1,18 @@
|
|||||||
import { ButtonInteraction, Client } from 'discord.js';
|
import { ButtonInteraction, Client } from 'discord.js';
|
||||||
|
import { Button } from '../types';
|
||||||
import { getRecordMessageFromDiscordId } from '../utils';
|
import { getRecordMessageFromDiscordId } from '../utils';
|
||||||
|
|
||||||
export default {
|
class RecordsPreviousButton implements Button<Client> {
|
||||||
name: 'records-previous',
|
id = 'records-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 getRecordMessageFromDiscordId(userId, parseInt(page) - 1, interaction.guild!);
|
const message = await getRecordMessageFromDiscordId(userId, parseInt(page) - 1, interaction.guild!);
|
||||||
|
|
||||||
if (!message) return;
|
if (!message) return;
|
||||||
|
|
||||||
interaction.editReply(message);
|
await interaction.editReply(message);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default new RecordsPreviousButton();
|
||||||
Reference in New Issue
Block a user