Help.ts
unknown
typescript
4 years ago
1.7 kB
6
Indexable
import { ButtonInteraction, CommandInteraction } from "discord.js";
import { ButtonComponent, Discord, Slash, SlashGroup } from "discordx";
import { Book } from "../../classes/pagination/Book.js";
import { Page } from "../../classes/pagination/Page.js";
@Discord()
@SlashGroup({ name: "help", description: "Comando de ajuda sobre o bot." })
@SlashGroup("help")
class Help {
@Slash("commands")
async commands(interaction: CommandInteraction) {
const book = new Book(interaction);
book.addPages(
new Page({
title: "A command",
description: "A",
color: "AQUA",
}),
new Page({
title: "B command",
description: "B",
color: "RED",
})
);
await interaction.reply({
embeds: [book.currentPage.content],
components: [book.row],
});
const collector = await interaction.channel.createMessageComponentCollector({
filter: inter => inter.user.id === interaction.user.id,
componentType: "BUTTON",
time: 30000,
});
collector.on("collect", async button => {
button.deferReply();
switch (button.customId) {
case "left_button":
book.previousPage();
break;
case "right_button":
book.nextPage();
break;
case "close_button":
await interaction.deleteReply();
break;
}
});
}
}
Editor is loading...