grom/interaction
Types
pub type ButtonExecution {
ButtonExecution(
custom_id: String,
resolved: option.Option(Resolved),
)
}
Constructors
-
ButtonExecution( custom_id: String, resolved: option.Option(Resolved), )
pub type ChannelSelectExecution {
ChannelSelectExecution(
custom_id: String,
selected_channels_ids: List(String),
resolved: option.Option(Resolved),
)
}
Constructors
-
ChannelSelectExecution( custom_id: String, selected_channels_ids: List(String), resolved: option.Option(Resolved), )
pub type CheckboxGroupSubmission {
CheckboxGroupSubmission(
id: Int,
custom_id: String,
selected_values: List(String),
)
}
Constructors
-
CheckboxGroupSubmission( id: Int, custom_id: String, selected_values: List(String), )
pub type CheckboxSubmission {
CheckboxSubmission(
id: Int,
custom_id: String,
is_selected: Bool,
)
}
Constructors
-
CheckboxSubmission(id: Int, custom_id: String, is_selected: Bool)
pub type CommandExecution {
SlashCommandExecuted(SlashCommandExecution)
MessageCommandExecuted(MessageCommandExecution)
UserCommandExecuted(UserCommandExecution)
}
Constructors
-
SlashCommandExecuted(SlashCommandExecution) -
MessageCommandExecuted(MessageCommandExecution) -
UserCommandExecuted(UserCommandExecution)
pub type Context {
TriggeredInGuild
TriggeredInBotDms
TriggeredInPrivateChannel
}
Constructors
-
TriggeredInGuild -
TriggeredInBotDms -
TriggeredInPrivateChannel
pub type Data {
CommandExecuted(CommandExecution)
MessageComponentExecuted(MessageComponentExecution)
ModalSubmitted(ModalSubmission)
}
Constructors
-
CommandExecuted(CommandExecution) -
MessageComponentExecuted(MessageComponentExecution) -
ModalSubmitted(ModalSubmission)
pub type FileUploadSubmission {
FileUploadSubmission(
id: Int,
custom_id: String,
uploaded_files_ids: List(String),
)
}
Constructors
-
FileUploadSubmission( id: Int, custom_id: String, uploaded_files_ids: List(String), )
pub type Followup {
Followup(
content: option.Option(String),
is_tts: Bool,
embeds: option.Option(List(embed.Embed)),
allowed_mentions: option.Option(
allowed_mentions.AllowedMentions,
),
components: option.Option(List(message.Component)),
files: option.Option(List(file.File)),
attachments: option.Option(List(attachment.Create)),
flags: option.Option(List(FollowupFlag)),
poll: option.Option(poll.Create),
)
}
Constructors
-
Followup( content: option.Option(String), is_tts: Bool, embeds: option.Option(List(embed.Embed)), allowed_mentions: option.Option( allowed_mentions.AllowedMentions, ), components: option.Option(List(message.Component)), files: option.Option(List(file.File)), attachments: option.Option(List(attachment.Create)), flags: option.Option(List(FollowupFlag)), poll: option.Option(poll.Create), )
pub type FollowupFlag {
EphemeralFollowup
FollowupWithSuppressedEmbeds
FollowupWithSuppressedNotifications
FollowupWithComponentsV2
}
Constructors
-
EphemeralFollowup -
FollowupWithSuppressedEmbeds -
FollowupWithSuppressedNotifications -
FollowupWithComponentsV2
pub type HttpError {
CouldNotParseInteraction(json.DecodeError)
CouldNotValidateSecurityHeaders(HttpSecurityError)
}
Constructors
-
CouldNotParseInteraction(json.DecodeError)A properly validated request was made, but it couldn’t be parsed as an interaction.
This isn’t to be expected too often.
Returns a 422 unprocessable content response.
-
CouldNotValidateSecurityHeaders(HttpSecurityError)An error has happened while trying to verify the request’s security headers.
While some of these errors are to be expected, some are genuine bugs within your code.
Check the inner field to check what error exactly happened.
pub type HttpSecurityError {
PublicKeyNotValidHexadecimal
PublicKeyHasImproperLength
HttpRequestSignatureNotProvided
HttpRequestTimestampNotProvided
HttpRequestSignatureNotValidHexadecimal
HttpRequestVerificationFailed
}
Constructors
-
PublicKeyNotValidHexadecimalThe public key you provided is not a valid hexadecimal number.
This is not to be expected and results in a HTTP response with the status 500 - internal server error.
-
PublicKeyHasImproperLengthYour public key’s length as a number is not 32 bytes.
This is not to be expected and results in a HTTP response with the status 500 - internal server error.
-
HttpRequestSignatureNotProvidedA request was made without a
x-signature-ed25519header.This is to be expected - discord often does “tests”, verifying that your webhook validates security headers properly.
Returns a 401 unauthorized response.
-
HttpRequestTimestampNotProvidedA request was made without a
x-signature-timestampheader.This is to be expected - discord often does “tests”, verifying that your webhook validates security headers properly.
Returns a 401 unauthorized response.
-
HttpRequestSignatureNotValidHexadecimalA request was made where the
x-signature-ed25519was not a valid hexadecimal number.This is to be expected - discord often does “tests”, verifying that your webhook validates security headers properly.
Returns a 401 unauthorized response.
-
HttpRequestVerificationFailedA request was made with the correct headers, however verifying that the message:
- was intended for your app
- was sent from Discord has failed.
This could happen for several reasons:
- an automated test was performed by Discord, verifying whether your app validates security headers (most common)
- you provided an inappropriate public key (for example, another app’s)
- there was a forgery attempt
Returns a 401 unauthorized response.
pub type Interaction {
Interaction(
id: String,
application_id: String,
data: Data,
invokement_info: InvokementInfo,
channel_id: String,
token: String,
message: option.Option(message.Message),
application_permissions: List(permission.Permission),
locale: String,
entitlements: option.Option(List(entitlement.Entitlement)),
authorizing_integration_owners_ids: dict.Dict(
application.InstallationContext,
String,
),
context: option.Option(Context),
attachment_size_limit_bytes: Int,
)
}
Constructors
-
Interaction( id: String, application_id: String, data: Data, invokement_info: InvokementInfo, channel_id: String, token: String, message: option.Option(message.Message), application_permissions: List(permission.Permission), locale: String, entitlements: option.Option(List(entitlement.Entitlement)), authorizing_integration_owners_ids: dict.Dict( application.InstallationContext, String, ), context: option.Option(Context), attachment_size_limit_bytes: Int, )Arguments
- message
-
For modals/component interactions, the message it was triggered from.
pub type InvokementInfo {
InvokedInGuild(
guild_id: String,
member: guild_member.GuildMember,
guild_locale: String,
)
InvokedInDm(user: user.User)
}
Constructors
-
InvokedInGuild( guild_id: String, member: guild_member.GuildMember, guild_locale: String, ) -
InvokedInDm(user: user.User)
pub type LabelSubmission {
LabelSubmission(id: Int, component: SubmittedLabelComponent)
}
Constructors
-
LabelSubmission(id: Int, component: SubmittedLabelComponent)
pub type MentionableSelectExecution {
MentionableSelectExecution(
custom_id: String,
selected_mentionables_ids: List(String),
resolved: option.Option(Resolved),
)
}
Constructors
-
MentionableSelectExecution( custom_id: String, selected_mentionables_ids: List(String), resolved: option.Option(Resolved), )
pub type MessageCommandExecution {
MessageCommandExecution(
id: String,
name: String,
resolved: option.Option(Resolved),
registered_to_guild_id: option.Option(String),
message_id: String,
)
}
Constructors
-
MessageCommandExecution( id: String, name: String, resolved: option.Option(Resolved), registered_to_guild_id: option.Option(String), message_id: String, )
pub type MessageComponentExecution {
ButtonExecuted(ButtonExecution)
StringSelectExecuted(StringSelectExecution)
UserSelectExecuted(UserSelectExecution)
RoleSelectExecuted(RoleSelectExecution)
MentionableSelectExecuted(MentionableSelectExecution)
ChannelSelectExecuted(ChannelSelectExecution)
}
Constructors
-
ButtonExecuted(ButtonExecution) -
StringSelectExecuted(StringSelectExecution) -
UserSelectExecuted(UserSelectExecution) -
RoleSelectExecuted(RoleSelectExecution) -
MentionableSelectExecuted(MentionableSelectExecution) -
ChannelSelectExecuted(ChannelSelectExecution)
pub type ModalResponse {
ModalResponse(
custom_id: String,
title: String,
components: List(modal.Component),
)
}
Constructors
-
ModalResponse( custom_id: String, title: String, components: List(modal.Component), )
pub type ModalSubmission {
ModalSubmission(
custom_id: String,
components: List(SubmittedModalComponent),
resolved: option.Option(Resolved),
)
}
Constructors
-
ModalSubmission( custom_id: String, components: List(SubmittedModalComponent), resolved: option.Option(Resolved), )
pub type ModifyFollowup {
ModifyFollowup(
content: modification.Modification(String),
embeds: modification.Modification(List(embed.Embed)),
flags: modification.Modification(List(ModifyFollowupFlag)),
allowed_mentions: modification.Modification(
allowed_mentions.AllowedMentions,
),
components: modification.Modification(List(message.Component)),
files: modification.Modification(List(file.File)),
attachments: modification.Modification(
List(attachment.Create),
),
poll: modification.Modification(poll.Create),
)
}
Constructors
-
ModifyFollowup( content: modification.Modification(String), embeds: modification.Modification(List(embed.Embed)), flags: modification.Modification(List(ModifyFollowupFlag)), allowed_mentions: modification.Modification( allowed_mentions.AllowedMentions, ), components: modification.Modification(List(message.Component)), files: modification.Modification(List(file.File)), attachments: modification.Modification(List(attachment.Create)), poll: modification.Modification(poll.Create), )
pub type ModifyFollowupFlag {
ModifyFollowupWithSuppressedEmbeds
}
Constructors
-
ModifyFollowupWithSuppressedEmbeds
pub type ModifyOriginalResponse {
ModifyOriginalResponse(
content: modification.Modification(String),
embeds: modification.Modification(List(embed.Embed)),
flags: modification.Modification(
List(ModifyOriginalResponseFlag),
),
allowed_mentions: modification.Modification(
allowed_mentions.AllowedMentions,
),
components: modification.Modification(List(message.Component)),
files: modification.Modification(List(file.File)),
attachments: modification.Modification(
List(attachment.Create),
),
poll: modification.Modification(poll.Create),
)
}
Constructors
-
ModifyOriginalResponse( content: modification.Modification(String), embeds: modification.Modification(List(embed.Embed)), flags: modification.Modification( List(ModifyOriginalResponseFlag), ), allowed_mentions: modification.Modification( allowed_mentions.AllowedMentions, ), components: modification.Modification(List(message.Component)), files: modification.Modification(List(file.File)), attachments: modification.Modification(List(attachment.Create)), poll: modification.Modification(poll.Create), )
pub type ModifyOriginalResponseFlag {
ModifyResponseWithSuppressedEmbeds
ModifyResponseWithComponentsV2
}
Constructors
-
ModifyResponseWithSuppressedEmbeds -
ModifyResponseWithComponentsV2
pub type RadioGroupSubmission {
RadioGroupSubmission(
id: Int,
custom_id: String,
value: option.Option(String),
)
}
Constructors
-
RadioGroupSubmission( id: Int, custom_id: String, value: option.Option(String), )
pub type Resolved {
Resolved(
users: option.Option(dict.Dict(String, user.User)),
members: option.Option(
dict.Dict(String, guild_member.GuildMember),
),
roles: option.Option(dict.Dict(String, role.Role)),
channels: option.Option(dict.Dict(String, ResolvedChannel)),
messages: option.Option(dict.Dict(String, message.Message)),
attachments: option.Option(
dict.Dict(String, attachment.Attachment),
),
)
}
Constructors
-
Resolved( users: option.Option(dict.Dict(String, user.User)), members: option.Option( dict.Dict(String, guild_member.GuildMember), ), roles: option.Option(dict.Dict(String, role.Role)), channels: option.Option(dict.Dict(String, ResolvedChannel)), messages: option.Option(dict.Dict(String, message.Message)), attachments: option.Option( dict.Dict(String, attachment.Attachment), ), )
pub type ResolvedChannel {
ResolvedTextChannel(
id: String,
name: String,
current_user_permissions: List(permission.Permission),
)
ResolvedVoiceChannel(
id: String,
name: String,
current_user_permissions: List(permission.Permission),
)
ResolvedCategoryChannel(
id: String,
name: String,
current_user_permissions: List(permission.Permission),
)
ResolvedAnnouncementChannel(
id: String,
name: String,
current_user_permissions: List(permission.Permission),
)
ResolvedAnnouncementThread(
id: String,
name: String,
current_user_permissions: List(permission.Permission),
metadata: thread.Metadata,
parent_id: String,
)
ResolvedPublicThread(
id: String,
name: String,
current_user_permissions: List(permission.Permission),
metadata: thread.Metadata,
parent_id: String,
)
ResolvedPrivateThread(
id: String,
name: String,
current_user_permissions: List(permission.Permission),
metadata: thread.Metadata,
parent_id: String,
)
ResolvedStageChannel(
id: String,
name: String,
current_user_permissions: List(permission.Permission),
)
ResolvedForumChannel(
id: String,
name: String,
current_user_permissions: List(permission.Permission),
)
ResolvedMediaChannel(
id: String,
name: String,
current_user_permissions: List(permission.Permission),
)
}
Constructors
-
ResolvedTextChannel( id: String, name: String, current_user_permissions: List(permission.Permission), ) -
ResolvedVoiceChannel( id: String, name: String, current_user_permissions: List(permission.Permission), ) -
ResolvedCategoryChannel( id: String, name: String, current_user_permissions: List(permission.Permission), ) -
ResolvedAnnouncementChannel( id: String, name: String, current_user_permissions: List(permission.Permission), ) -
ResolvedAnnouncementThread( id: String, name: String, current_user_permissions: List(permission.Permission), metadata: thread.Metadata, parent_id: String, ) -
ResolvedPublicThread( id: String, name: String, current_user_permissions: List(permission.Permission), metadata: thread.Metadata, parent_id: String, ) -
ResolvedPrivateThread( id: String, name: String, current_user_permissions: List(permission.Permission), metadata: thread.Metadata, parent_id: String, ) -
ResolvedStageChannel( id: String, name: String, current_user_permissions: List(permission.Permission), ) -
ResolvedForumChannel( id: String, name: String, current_user_permissions: List(permission.Permission), ) -
ResolvedMediaChannel( id: String, name: String, current_user_permissions: List(permission.Permission), )
pub type Response {
RespondWithChannelMessageWithSource(ResponseMessage)
RespondWithDeferredChannelMessageWithSource(ResponseMessage)
RespondWithDeferredUpdateMessage
RespondWithUpdateMessage(ResponseMessage)
RespondWithModal(ModalResponse)
}
Constructors
-
RespondWithChannelMessageWithSource(ResponseMessage) -
RespondWithDeferredChannelMessageWithSource(ResponseMessage)You should only set the
flagsproperty in this response. -
RespondWithDeferredUpdateMessage -
RespondWithUpdateMessage(ResponseMessage) -
RespondWithModal(ModalResponse)
pub type ResponseMessage {
ResponseMessage(
is_tts: option.Option(Bool),
content: option.Option(String),
embeds: option.Option(List(embed.Embed)),
allowed_mentions: option.Option(
allowed_mentions.AllowedMentions,
),
flags: option.Option(List(ResponseMessageFlag)),
components: option.Option(List(message.Component)),
attachments: option.Option(List(attachment.Create)),
files: option.Option(List(file.File)),
poll: option.Option(poll.Create),
)
}
Constructors
-
ResponseMessage( is_tts: option.Option(Bool), content: option.Option(String), embeds: option.Option(List(embed.Embed)), allowed_mentions: option.Option( allowed_mentions.AllowedMentions, ), flags: option.Option(List(ResponseMessageFlag)), components: option.Option(List(message.Component)), attachments: option.Option(List(attachment.Create)), files: option.Option(List(file.File)), poll: option.Option(poll.Create), )Arguments
- flags
-
For
RespondWithDeferredChannelMessageWithSources, you can only set theEphemeralResponseMessageflag. If you need any other flags - use them with the edited response message.
pub type ResponseMessageFlag {
ResponseMessageWithSuppressedEmbeds
EphemeralResponseMessage
ResponseMessageWithComponentsV2
VoiceResponseMessage
ResponseMessageWithSuppressedNotifications
}
Constructors
-
ResponseMessageWithSuppressedEmbeds -
EphemeralResponseMessage -
ResponseMessageWithComponentsV2 -
VoiceResponseMessage -
ResponseMessageWithSuppressedNotifications
pub type RoleSelectExecution {
RoleSelectExecution(
custom_id: String,
selected_roles_ids: List(String),
resolved: option.Option(Resolved),
)
}
Constructors
-
RoleSelectExecution( custom_id: String, selected_roles_ids: List(String), resolved: option.Option(Resolved), )
pub type SlashCommandExecution {
SlashCommandExecution(
id: String,
name: String,
resolved: option.Option(Resolved),
options: List(SlashCommandOption),
registered_to_guild_id: option.Option(String),
)
}
Constructors
-
SlashCommandExecution( id: String, name: String, resolved: option.Option(Resolved), options: List(SlashCommandOption), registered_to_guild_id: option.Option(String), )
pub type SlashCommandOption {
StringSlashCommandOption(
name: String,
value: String,
is_focused: Bool,
)
IntegerSlashCommandOption(
name: String,
value: Int,
is_focused: Bool,
)
NumberSlashCommandOption(
name: String,
value: Float,
is_focused: Bool,
)
BoolSlashCommandOption(
name: String,
value: Bool,
is_focused: Bool,
)
UserSlashCommandOption(
name: String,
user_id: String,
is_focused: Bool,
)
ChannelSlashCommandOption(
name: String,
channel_id: String,
is_focused: Bool,
)
RoleSlashCommandOption(
name: String,
role_id: String,
is_focused: Bool,
)
MentionableSlashCommandOption(
name: String,
mentionable_id: String,
is_focused: Bool,
)
AttachmentSlashCommandOption(
name: String,
attachment_id: String,
is_focused: Bool,
)
SubCommandSlashCommandOption(
name: String,
options: List(SlashCommandOption),
)
SubCommandGroupSlashCommandOption(
name: String,
options: List(SlashCommandOption),
)
}
Constructors
-
StringSlashCommandOption( name: String, value: String, is_focused: Bool, )Arguments
- is_focused
-
For autocomplete.
-
IntegerSlashCommandOption( name: String, value: Int, is_focused: Bool, )Arguments
- is_focused
-
For autocomplete.
-
NumberSlashCommandOption( name: String, value: Float, is_focused: Bool, )Arguments
- is_focused
-
For autocomplete.
-
BoolSlashCommandOption( name: String, value: Bool, is_focused: Bool, )Arguments
- is_focused
-
For autocomplete.
-
UserSlashCommandOption( name: String, user_id: String, is_focused: Bool, )Arguments
- name
-
Name of the option, NOT of the user.
- is_focused
-
For autocomplete.
-
ChannelSlashCommandOption( name: String, channel_id: String, is_focused: Bool, )Arguments
- name
-
Name of the option, NOT of the channel.
- is_focused
-
For autocomplete.
-
RoleSlashCommandOption( name: String, role_id: String, is_focused: Bool, )Arguments
- name
-
Name of the option, NOT of the role.
- is_focused
-
For autocomplete.
-
MentionableSlashCommandOption( name: String, mentionable_id: String, is_focused: Bool, )Arguments
- name
-
Name of the option, NOT of the mentionable.
- is_focused
-
For autocomplete.
-
AttachmentSlashCommandOption( name: String, attachment_id: String, is_focused: Bool, )Arguments
- name
-
Name of the option, NOT of the attachment.
- attachment_id
-
You likely want to search for this in
resolved. - is_focused
-
For autocomplete.
-
SubCommandSlashCommandOption( name: String, options: List(SlashCommandOption), ) -
SubCommandGroupSlashCommandOption( name: String, options: List(SlashCommandOption), )
pub type StringSelectExecution {
StringSelectExecution(
custom_id: String,
selected_values: List(String),
resolved: option.Option(Resolved),
)
}
Constructors
-
StringSelectExecution( custom_id: String, selected_values: List(String), resolved: option.Option(Resolved), )
pub type SubmittedLabelComponent {
LabelTextInputSubmitted(TextInputSubmission)
LabelStringSelectSubmitted(StringSelectExecution)
LabelUserSelectSubmitted(UserSelectExecution)
LabelRoleSelectSubmitted(RoleSelectExecution)
LabelMentionableSelectSubmitted(MentionableSelectExecution)
LabelChannelSelectSubmitted(ChannelSelectExecution)
LabelFileUploadSubmitted(FileUploadSubmission)
LabelRadioGroupSubmitted(RadioGroupSubmission)
LabelCheckboxGroupSubmitted(CheckboxGroupSubmission)
LabelCheckboxSubmitted(CheckboxSubmission)
}
Constructors
-
LabelTextInputSubmitted(TextInputSubmission) -
LabelStringSelectSubmitted(StringSelectExecution) -
LabelUserSelectSubmitted(UserSelectExecution) -
LabelRoleSelectSubmitted(RoleSelectExecution) -
LabelMentionableSelectSubmitted(MentionableSelectExecution) -
LabelChannelSelectSubmitted(ChannelSelectExecution) -
LabelFileUploadSubmitted(FileUploadSubmission) -
LabelRadioGroupSubmitted(RadioGroupSubmission) -
LabelCheckboxGroupSubmitted(CheckboxGroupSubmission) -
LabelCheckboxSubmitted(CheckboxSubmission)
pub type SubmittedModalComponent {
TextDisplaySubmitted(TextDisplaySubmission)
LabelSubmitted(LabelSubmission)
}
Constructors
-
TextDisplaySubmitted(TextDisplaySubmission) -
LabelSubmitted(LabelSubmission)
pub type TextDisplaySubmission {
TextDisplaySubmission(id: Int)
}
Constructors
-
TextDisplaySubmission(id: Int)
pub type TextInputSubmission {
TextInputSubmission(id: Int, custom_id: String, value: String)
}
Constructors
-
TextInputSubmission(id: Int, custom_id: String, value: String)
pub type UserCommandExecution {
UserCommandExecution(
id: String,
name: String,
resolved: option.Option(Resolved),
registered_to_guild_id: option.Option(String),
user_id: String,
)
}
Constructors
-
UserCommandExecution( id: String, name: String, resolved: option.Option(Resolved), registered_to_guild_id: option.Option(String), user_id: String, )
pub type UserSelectExecution {
UserSelectExecution(
custom_id: String,
selected_users_ids: List(String),
resolved: option.Option(Resolved),
)
}
Constructors
-
UserSelectExecution( custom_id: String, selected_users_ids: List(String), resolved: option.Option(Resolved), )
Values
pub fn delete_followup(
client: grom.Client,
of interaction: Interaction,
id message_id: String,
) -> Result(Nil, grom.Error)
pub fn delete_original_response(
client: grom.Client,
of interaction: Interaction,
) -> Result(Nil, grom.Error)
pub fn followup(
client: grom.Client,
to interaction: Interaction,
using followup: Followup,
) -> Result(message.Message, grom.Error)
Do not use this function to send a message after deferring it.
Use modify_original_response instead.
pub fn get_followup(
client: grom.Client,
for interaction: Interaction,
id message_id: String,
) -> Result(message.Message, grom.Error)
pub fn get_original_response(
client: grom.Client,
for interaction: Interaction,
) -> Result(Response, grom.Error)
pub fn handle_http_interaction_request(
request: request.Request(String),
public_key public_key: String,
next next: fn(Result(Interaction, HttpError)) -> Nil,
) -> response.Response(String)
A HTTP request handler middleware that:
- handles PING requests (which verify that your interaction endpoint is still up and secure)
- gives you access to the interaction object, allowing you to handle your interactions
- sends an HTTP response whenever you’re done with handling your interactions
Warning: Do not use long-running code to handle your interactions, as it could trigger an HTTP timeout.
See the http_interactions example to see how to set-up HTTP interactions and how to properly handle them.
pub fn modify_followup(
client: grom.Client,
for interaction: Interaction,
id message_id: String,
using modify: ModifyFollowup,
) -> Result(message.Message, grom.Error)
pub fn modify_original_response(
client: grom.Client,
of interaction: Interaction,
using modify: ModifyOriginalResponse,
) -> Result(message.Message, grom.Error)
pub fn new_followup() -> Followup
pub fn new_modify_followup() -> ModifyFollowup
pub fn new_modify_original_response() -> ModifyOriginalResponse
pub fn new_response_message() -> ResponseMessage
pub fn respond(
client: grom.Client,
to interaction: Interaction,
using response: Response,
) -> Result(Nil, grom.Error)