feat(events): Adds AcknowledgableEvent
This commit is contained in:
parent
6d7a0e7cfb
commit
b82ab7dbc4
18 changed files with 228 additions and 77 deletions
|
|
@ -14,7 +14,7 @@ import {
|
|||
import {Nullable} from "../types/Nullable";
|
||||
import {IconCache} from "../Icons/IconCache";
|
||||
import {MessageActionRowComponentBuilder} from "@discordjs/builders";
|
||||
import {ComponentInteractionEvent} from "../Events/ComponentInteractionEvent";
|
||||
import {ComponentInteractionEvent} from "../Events/EventClasses/ComponentInteractionEvent";
|
||||
import {MenuTraversal} from "./MenuTraversal";
|
||||
import {Prompt} from "./Modals/Prompt";
|
||||
|
||||
|
|
@ -52,7 +52,9 @@ export class MenuRenderer {
|
|||
}
|
||||
|
||||
public async display(interaction: CommandInteraction) {
|
||||
this.eventId = this.eventHandler?.addHandler<ComponentInteractionEvent>(ComponentInteractionEvent.name, this.handleUIEvents.bind(this));
|
||||
this.eventId = this.eventHandler?.addHandler<ComponentInteractionEvent>(ComponentInteractionEvent.name, {
|
||||
method: this.handleUIEvents.bind(this),
|
||||
});
|
||||
|
||||
await interaction.reply({
|
||||
content: "",
|
||||
|
|
@ -91,12 +93,13 @@ export class MenuRenderer {
|
|||
);
|
||||
}
|
||||
|
||||
return Array.from(Array(rowCount).keys())
|
||||
const rows = Array.from(Array(rowCount).keys())
|
||||
.map((index) => {
|
||||
const childStart = index * MenuRenderer.MAX_BUTTON_PER_ROW;
|
||||
return menuItem.children.toSpliced(childStart, MenuRenderer.MAX_BUTTON_PER_ROW);
|
||||
return menuItem.children.slice(childStart, MenuRenderer.MAX_BUTTON_PER_ROW);
|
||||
})
|
||||
.reverse()
|
||||
|
||||
return rows.reverse()
|
||||
.map((items) => new ActionRowBuilder<ButtonBuilder>()
|
||||
.setComponents(
|
||||
...items.map(item => new ButtonBuilder()
|
||||
|
|
@ -150,6 +153,8 @@ export class MenuRenderer {
|
|||
return;
|
||||
}
|
||||
|
||||
ev.acknowledge();
|
||||
|
||||
const [, action, parameter ] = ev.interaction.customId.split(';')
|
||||
const menuAction = <MenuAction>action;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue