| 9 | import { LoggingUtils } from "../utils/message-utils/logging.utils.ts"; |
| 10 | |
| 11 | export 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected