Skip to content

Buttons

nutmeg edited this page Feb 22, 2023 · 4 revisions

Run Down

Buttons in Discord+PS function similarly to how they do in Discord.JS except with a few adjustments to make things generally easier
For more info on buttons and how they're formatted check out this

Creating Buttons

Buttons are classes so they are created like this:

let button = new PSClient.Button({/* stuff */});

Now we'll go over the new additions of buttons in Discord+PS

Button Styles

Discord+PS has built in button styles for you to use
the styles are primary, secondary, success, danger, and link

{
	style: "primary"
}

Button Structures

If you want more info on how buttons function this is the code:

Button = class {
	constructor(obj) {
		obj.type = 2;
		if (obj.id) {
			obj.custom_id = obj.id;
		}
		if (obj.style) {
			obj.style = this.buttonStyle(obj.style);
		}
		
		return obj;
	}
}

Button Related Functions

PSClient.Button

  • Description: Used to create buttons
  • Setup: new PSClient.Button(Object)
  • Returns: Object

PSClient.buttonStyle

  • Description: turns the style into a number to be used by the buttons
  • Setup: PSClient.buttonStyle(style)
  • Returns: Number

Clone this wiki locally