ButtonInteraction class

const buttonInteraction = new ButtonInteraction(data: ButtonInteraction, addon: Addon);

constructor

The constructor requires two arguments. The first argument is the data of the button interaction and must be an instance of the Discord.js ButtonInteraction class. The second argument is the addon where to create the button interaction for and must be an instance of the Zyno Bot Addons Addon class.

Properties

type

In case of a ButtonInteraction, the value will be Button. It defines the type of interaction.

guild

An instance of the Guild class which represents the guild where the interaction took place.

guildId

The id of the guild where the interaction took place.

channel

An instance of the TextChannel, VoiceChannel, StageChannel, DirectoryChannel, ForumChannel, ThreadChannel or DMChannel and represents the channel where the interaction took place.

channelId

The id of the channel where the interaction took place.

member

An instance of the Member class and represents the member who created the interaction.

memberId

The id of the member who created the interaction.

user

An instance of the User class and represents the user who created the interaction.

message

An instance of the Message class and represents the message where the interaction was created.

messageId

The id of the corresponding message of the button interaction.

customId

The id which was given to the button when it was created to recognize it when an interaction with this button was created.

id

The id of the interaction given by Discord.

Functions

isButton

buttonInteraction.isButton() : boolean;

Returns a boolean which defines whether the interaction is a button interaction or not.

isMenu

buttonInteraction.isMenu() : boolean;

Returns a boolean which defines whether the interaction is a menu interaction or not.

isForm

buttonInteraction.isForm() : boolean;

Returns a boolean which defines whether the interaction is a form interaction or not.

deferUpdate

buttonInteraction.deferUpdate() : Promise<void>;

Tells the Discord API that a change has already been made and the interaction can be ignored. The function returns a Promise which gets fulfilled once the update has been deferred.

deferReply

buttonInteraction.deferReply() : Promise<void>;

Tells the Discord API that a change will be made, but that it may take a little more time than the Discord API gives by default. The function returns a Promise which gets fulfilled once the reply has been deferred.

deleteReply

buttonInteraction.deleteReply() : Promise<void>;

Deletes a previously made reply for the interaction. The function returns a Promise which gets fulfilled once the reply has been deleted.

reply

buttonInteraction.reply(...content: [string, Embed, ActionRowBuilder, ButtonBuilder, SelectMenuBuilder, object]) : Promise<Message>;

Creates a reply for the interaction and sends it as a message. The function returns a Promise which returns an instance of the Message class which represents the reply which was sent by the bot when the reply was sent.

ArgumentDescription

content

The content of the reply the bot should send. The content must be a string, an Embed class, the ActionRowBuilder class, the ButtonBuilder class, the SelectMenuBuilder class or an object which provides the reply its content.

The object of the reply may contain the following information:

  • content: A string of the content of the reply.

  • embeds: An array with the Embed class.

  • files: An array with a string which represents a file url or an object when uploading a file.

  • components: An array with the Discord.js ActionRowBuilder class.

The file object data may contain the following information:

  • name: The name of the file you want to upload

  • attachment: The path of the file you want to upload

  • description: The description of the file

followUp

buttonInteraction.followUp(...content: [string, Embed, ActionRowBuilder, ButtonBuilder, SelectMenuBuilder, object]) : Promise<Message>;

Creates a reply to a previously made reply for the interaction and sends it as a message. The function returns a Promise which returns an instance of the Message class which represents the message of the follow up which was sent by the bot when the follow up was sent.

ArgumentDescription

content

The content of the follow up the bot should send. The content must be a string, an Embed class, the ActionRowBuilder class, the ButtonBuilder class, the SelectMenuBuilder class or an object which provides the follow up its content.

The object of the follow up may contain the following information:

  • content: A string of the content of the follow up.

  • embeds: An array with the Embed class.

  • files: An array with a string which represents a file url or an object when uploading a file.

  • components: An array with the Discord.js ActionRowBuilder class.

The file object data may contain the following information:

  • name: The name of the file you want to upload

  • attachment: The path of the file you want to upload

  • description: The description of the file

update

buttonInteraction.update(...content: [string, Embed, ActionRowBuilder, ButtonBuilder, SelectMenuBuilder, object]) : Promise<Message>;

Updates a previously made reply for the interaction and sends it as a message. The function returns a Promise which returns an instance of the Message class which represents the mew reply which was sent by the bot when the reply was updated.

ArgumentDescription

content

The content of the reply the bot should send. The content must be a string, an Embed class, the ActionRowBuilder class, the ButtonBuilder class, the SelectMenuBuilder class or an object which provides the reply its content.

The object of the reply may contain the following information:

  • content: A string of the content of the message.

  • embeds: An array with the Embed class.

  • files: An array with a string which represents a file url or an object when uploading a file.

  • components: An array with the Discord.js ActionRowBuilder class.

The file object data may contain the following information:

  • name: The name of the file you want to upload

  • attachment: The path of the file you want to upload

  • description: The description of the file

sendForm

buttonInteraction.sendForm(form: FormBuilder) : Promise<void>;

Sends a form to the member who created an interaction. Once the form has been submitted, the data can be received with the formSubmit event of the createEventListener() EventEmitter.

ArgumentDescription

form

An instance of the FormBuilder class which defines the form you'd like to send to the member who created the interaction.

executeCommand

buttonInteraction.executeCommand(commandName: string, args?: [any]) : Promise<void>;

Executes another registered command based on the interaction executed by the member. The command can be a default Zyno Bot command or another command created by another addon.

ArgumentDescription

commandName

The name of the command you'd like to execute. The information provided in the current command, such as options, will also be provided to the command which you'd like to execute.

args

An array of custom arguments. The command will be based on the custom arguments instead of the command name as the only argument.

Last updated