@oceanicjs/builders
Version:
Helpful builders for various Discord related things.
51 lines (50 loc) • 1.89 kB
TypeScript
import Component from "./Component";
import type { ButtonColors } from "../Constants";
import { ButtonStyles, ComponentTypes, PartialEmoji, RawTextButton, TextButton, URLButton } from "oceanic.js";
export default class Button extends Component<ComponentTypes.BUTTON> {
customID?: string;
emoji?: PartialEmoji;
label?: string;
style: ButtonStyles | ButtonColors;
url?: string;
/**
* Create a new Button.
* @param style The style of this button.
* @param urlOrCustomID The url of this button if style 5, else the custom ID of this button.
*/
constructor(style: ButtonStyles | ButtonColors, urlOrCustomID: string);
/** this method is meant to be for internal use only, don't use it, as it may break or change at a moments notice */
private load;
/**
* Set the custom id of this button (styles 1-4).
* @param customID A developer-defined identifier for the button, max 100 characters.
*/
setCustomID(customID: string): this;
/**
* Set the emoji of this button.
* @param emoji The emoji to display on this button.
*/
setEmoji(emoji: PartialEmoji): this;
/**
* Set the label of this button
* @param label The label to display on this button.
*/
setLabel(label: string): this;
/**
* Set the style of this button.
* * 1 - blurple
* * 2 - grey
* * 3 - green
* * 4 - red
* * 5 - link
* @param style The [style](https://discord.com/developers/docs/interactions/message-components#button-object-button-styles) of this button.
*/
setStyle(style: ButtonStyles | ButtonColors): this;
/**
* Set the custom id of this button (style 5).
* @param url The url to open when this button is clicked.
*/
setURL(url: string): this;
toJSON(): TextButton | URLButton;
toJSONRaw(): RawTextButton | URLButton;
}