Create base pagination helper
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e96f173533
commit
a213e727c1
10 changed files with 194 additions and 5 deletions
46
src/commands/dev/paginationtest.ts
Normal file
46
src/commands/dev/paginationtest.ts
Normal file
|
@ -0,0 +1,46 @@
|
|||
import { ButtonInteraction, CacheType, CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import PaginatedEmbed from "../../helpers/PaginatedEmbed";
|
||||
import TestPage from "../../helpers/Pagination/TestPage";
|
||||
import { PaginatedCommand } from "../../type/paginatedCommand";
|
||||
|
||||
export default class Paginationtest extends PaginatedCommand {
|
||||
public paginatedEmbed: PaginatedEmbed<TestPage>;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
super.CommandBuilder = new SlashCommandBuilder()
|
||||
.setName('paginationtest')
|
||||
.setDescription('Test the pagination functionality');
|
||||
|
||||
this.paginatedEmbed = new PaginatedEmbed<TestPage>("paginationtest");
|
||||
|
||||
this.InitialisePages();
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction<CacheType>) {
|
||||
const page = this.paginatedEmbed.GetCurrentPage();
|
||||
|
||||
await page!.sendCommandEmbed(interaction);
|
||||
}
|
||||
|
||||
public override async nextPage(interaction: ButtonInteraction<CacheType>) {
|
||||
const page = this.paginatedEmbed.NextPage();
|
||||
|
||||
await page!.sendButtonEmbed(interaction);
|
||||
}
|
||||
|
||||
public override async previousPage(interaction: ButtonInteraction<CacheType>) {
|
||||
const page = this.paginatedEmbed.PreviousPage();
|
||||
|
||||
await page!.sendButtonEmbed(interaction);
|
||||
}
|
||||
|
||||
private InitialisePages() {
|
||||
const page0 = new TestPage("paginationtest", 0, 2);
|
||||
const page1 = new TestPage("paginationtest", 1, 2);
|
||||
const page2 = new TestPage("paginationtest", 2, 2);
|
||||
|
||||
this.paginatedEmbed.AddPages(page0, page1, page2);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue