UNPKG

@notoiro/djs-button-pages

Version:

A simple yet powerful module for implementing customizable embed pages with buttons in Discord chat. Works only with Discord.js.

57 lines (56 loc) 1.92 kB
import { ButtonBuilder } from "discord.js"; import ButtonAction from "../Types/ButtonAction"; import ButtonSwitch from "../Types/ButtonSwitch"; import ButtonData from "./ButtonData"; /** * Class that wraps button's functionality. */ export default class ButtonWrapper { private _data; private _action; private _switch; /** * Class that wraps button's functionality. * @param {Partila<ButtonData> | ButtonWrapper} data Either an interface for button styling or the class to be built from. */ constructor(data?: Partial<ButtonData> | ButtonWrapper); /** * @returns {Partial<ButtonData>} Button's styling. */ get data(): Partial<ButtonData>; /** * @returns {ButtonACtion} Action that is called after the button is pressed. */ get action(): ButtonAction; /** * @returns {ButtonSwitch} Action that is called to switch button's state. */ get switch(): ButtonSwitch; /** * @returns {ButtonBuilder} Ready button builder. */ get builtComponent(): ButtonBuilder; /** * Sets buttons data. * @param {Partial<ButtonData> | ButtonWrapper} data Either an interface for button styling or the class to be built from. * @returns {this} */ setData(data: Partial<ButtonData> | ButtonWrapper): this; /** * Sets action that is called after the button is pressed. * @param {ButtonAction} action Action that is called after the button is pressed. * @returns {this} */ setAction(action: ButtonAction): this; /** * Sets action that is called to switch button's state. * @param switchFunction Action that is called to switch button's state. * @returns {this} */ setSwitch(switchFunction: ButtonSwitch): this; /** * Converts button styling to JSON-like object. * @returns {ButtonData} JSON-like object. */ toJSON(): ButtonData; }