Skip to content

Component Basics

nutmeg edited this page Feb 22, 2023 · 3 revisions

Run Down

Message Components are what makes the little things on the things do things and in this we'll go over how to make them
They consist of things like embeds, buttons, selections, and action rows

Embeds

Embeds are probably the simplest of the bunch because it's just this:

let embed = new PSClient.Embed({
	description: "this is an embed",
	color: PSClient.colors.blurple,
	timestamp: PSClient.time.now.embed
});

ctx.reply({ embeds: [embed]});

Action Row Example

Action row setup is pretty simple. Let's say for this command we want to make a command to invite someone to something for that we can use this:

PSClient.command( {name: "invite"}, (ctx, cmd) => {
	let accept = new PSClient.Button({ id: "accept", style: "success", label: "Accept" });
	let decline = new PSClient.Button({ id: "decline", style: "danger", label: "Decline" });

	let row = new PSClient.ActionRow([accept, decline]);

	let user = PSClient.fetchUser(cmd.args[0]);

	PSClient.reply(`Do you accept the invite ${user}?`, {components: [row]});
});

if you want to respond to that when it is pressed you can do this:

PSClient.buttonAction( (ctx) => {
	if (ctx.customId == "accept") {
		ctx.reply("Accepted!");
	}
	else if (ctx.customId == "decline") {
		ctx.reply("Declined :(");
	}
});
Clone this wiki locally