commandos
Types
pub type InteractionError {
CouldNotParseInteraction(json.DecodeError)
CouldNotValidateSecurityHeaders(SecurityError)
}
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 400 “bad request” response.
-
CouldNotValidateSecurityHeaders(SecurityError)An error has happened while trying to verify the request’s security headers.
This is to be expected - discord often does “tests”, verifying that your webhook validates security headers properly.
Returns a 401 “unauthorized” response.
pub type PublicKeyValidationError {
PublicKeyNotValidHexadecimal
PublicKeyHasImproperLength
}
Constructors
-
PublicKeyNotValidHexadecimalThe public key you provided is not a valid hexadecimal number.
-
PublicKeyHasImproperLengthYour public key’s length as a number is not 32 bytes.
pub type SecurityError {
HttpRequestSignatureNotProvided
HttpRequestTimestampNotProvided
HttpRequestSignatureNotValidHexadecimal
HttpRequestVerificationFailed
}
Constructors
-
HttpRequestSignatureNotProvidedA request was made without a
x-signature-ed25519header. -
HttpRequestTimestampNotProvidedA request was made without a
x-signature-timestampheader. -
HttpRequestSignatureNotValidHexadecimalA request was made where the
x-signature-ed25519was not a valid hexadecimal number. -
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
Values
pub fn handle_interaction_request(
request: request.Request(String),
public_key public_key: PublicKey,
handler next: fn(Result(grom.Interaction, InteractionError)) -> Nil,
) -> response.Response(String)
pub fn public_key_from_string(
key: String,
) -> Result(PublicKey, PublicKeyValidationError)