FormInteraction class

const formInteraction = new FormInteraction(data: ModalSubmitInteraction, addon: Addon);

constructor

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

Properties

type

In case of a FormInteraction, the value will be Form. 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 form interaction.

customId

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

id

The id of the interaction given by Discord.

inputs

An array with all the inputs provided by the member who submitted the form ordered in the way the form inputs were also ordered.

Functions

isButton

formInteraction.isButton() : boolean;

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

isMenu

formInteraction.isMenu() : boolean;

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

isForm

formInteraction.isForm() : boolean;

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

getInput

formInteraction.getInput(customId: string) : string;

Returns a specific value provided by the member in an input of the form identified with a specific custom id.

ArgumentDescription

customId

The custom id which you've set in the InputBuilder class where you can define your input with and of the input you'd like to get the value of which the member has provided.

deferUpdate

formInteraction.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

formInteraction.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

formInteraction.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

formInteraction.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

formInteraction.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

formInteraction.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

executeCommand

formInteraction.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 inputs provided in the executed interaction by the member.

Last updated