UNPKG

sheweny

Version:

The powerful framework for create discord bots

56 lines (55 loc) 1.88 kB
import { BaseStructure } from './BaseStructure.js'; import { ShewenyError } from '../helpers/index.js'; import type { ShewenyClient } from '../client/Client.js'; import type { ButtonInteraction } from 'discord.js'; import type { Awaitable, ButtonData, CustomId } from '../typescript/index.js'; /** * Represents an Button structure * @extends {BaseStructure} */ export declare abstract class Button extends BaseStructure { /** * Cooldown of a button in seconds * @type {number} */ cooldown: number; /** * Custom id for one or more buttons * @type {CustomId} */ customId: CustomId; /** * Constructor for build a Button * @param {ShewenyClient} [client] Client framework * @param {CustomId} [customId] Custom id for one or more buttons * @param {ButtonData | undefined} [options] The options of the button */ constructor(client: ShewenyClient, customId: CustomId, options?: ButtonData); /** * This function is executed before executing the `execute` function * @param {ButtonInteraction} interaction Button interaction * @returns {any | Promise<any>} */ before?(interaction: ButtonInteraction): Awaitable<unknown>; /** * Main function `execute` for the buttons * @param {ButtonInteraction} interaction Button interaction * @returns {any | Promise<any>} */ abstract execute(interaction: ButtonInteraction): Awaitable<unknown>; /** * Register a button in collections * @returns {Collection<CustomId, Button>} */ register(): Promise<Button | ShewenyError>; /** * Reload a button * @returns {Promise<Collection<CustomId, Button> | ShewenyError>} */ reload(): Promise<Button | ShewenyError>; /** * Unregister a button from collections * @returns {boolean} */ unregister(): boolean; }