MCPcopy Create free account
hub / github.com/ArrowM/Queue-Bot / ButtonHandler

Class ButtonHandler

src/handlers/button.handler.ts:11–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9import { LoggingUtils } from "../utils/message-utils/logging.utils.ts";
10
11export class ButtonHandler implements Handler {
12 private readonly inter: ButtonInteraction;
13
14 constructor(inter: AnyInteraction) {
15 this.inter = inter as ButtonInteraction;
16 }
17
18 async handle() {
19 await this.inter.deferReply({ ephemeral: true });
20 const button = BUTTONS.get(this.inter.customId);
21 if (button) {
22 const isAdmin = button.adminOnly;
23
24 this.inter.respond = (message: (InteractionReplyOptions | string), log = false) =>
25 InteractionUtils.respond(this.inter, isAdmin, message, log);
26
27 this.inter.log = (originalMessage: Message | string) =>
28 LoggingUtils.log(this.inter.store, isAdmin, originalMessage);
29
30 if (isAdmin) {
31 AdminUtils.verifyIsAdmin(this.inter.store, this.inter.member);
32 }
33
34 incrementGuildStat(this.inter.guildId, "buttonsReceived");
35 await button.handle(this.inter);
36 }
37 }
38}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected