Skip to main content

btnRole

A Button Role System that lets you create button roles with your own message. | Requires: manageBtnRole()

Implementation

simplydjs.btnRole(interaction, {
data: [
{...}
], // array of data objects (required)
// options (optional)
})
NOTE

This is totally different from betterBtnRole !

betterBtnRole is a button role builder system. where, btnRole is a function that sends your message (with embeds) with the buttons necessary for the button role.

Output

button role panel

Types

simplydjs.btnRole(
msgOrInt: ExtendedMessage | ExtendedInteraction,
options: btnRoleOptions
): Promise<boolean>
info

This is just 50% of the code for Button Role System !. You also need manageBtnRole() to handle all button clicks. This makes it 100% !

Options

btnRoleOptions

ParameterTypeRequiredDefaultDescription
strictbooleanfalseEnables strict mode in btnRole
embedCustomizableEmbed-The embed of your message that is sent with the necessary buttons
contentstringnoneThe content of your message that is sent with the necessary buttons
dataBtnRoleButtons[]noneThe data necessary to create the buttons. (Array of dataObj)
export type btnRoleOptions = {
embed?: CustomizableEmbed;
content?: string;
data?: BtnRoleButtons[];
strict?: boolean;
};

BtnRoleButtons

ParameterTypeRequiredDefaultDescription
labelstringRole NameThe label of the button you're trying to add/remove
roleRole-The role to be given when a button is clicked
styleButtonStyleButtonStyle.PrimaryThe style of the button that is getting added.
emojistringnoneThe emoji of the button you're trying to add
urlstringnoneThe URL that needs to be redirected when clicked (Only when the style is ButtonStyle.Link)
export type BtnRoleButtons = {
role?: string | Role;
url?: `https://${string}`; // Only HTTPS allowed !
} & CustomizableButton;

Example

To make this system work, you should also implement manageBtnRole() manageBtnRole function handles all the buttons for btnRole and betterBtnRole.

  • Default settings

btnrole.js
const simplydjs = require('simply-djs')

simplydjs.btnRole(interaction, {
strict: true,
data: [
{
role: "01234567890123",
style: ButtonStyle.Primary
},
],
content: "Take your roles with button"
})
  • Customized with options

btnrole.js
const { ButtonStyle } = require('discord.js')
const simplydjs = require('simply-djs')

simplydjs.btnRole(interaction, {
strict: true,
data: [
{
role: "01234567890123",
style: ButtonStyle.Primary
},
{
role: "98765432109876",
style: ButtonStyle.Secondary
}
],
content: "Take your roles with button",
embed: {
title: "Take your roles",
color: simplydjs.toRgb("#406dbc"),
description: "Take your roles by interacting with button"
},
})