Work In Progress
This documentation is in beta. It's missing lots of content, search is broken, and many links go nowhere. These problems will be fixed before release, but there's plenty of work left!
Skip to main content

Error Responses

The default approach Kord Extensions takes when displaying errors to users is to send the message directly to the user, unformatted and without mentions/pings. The errorResponse { } builder allows you to change how Kord Extensions formats and displays errors to users on Discord.

Empty Messages

Remember that by using the errorResponse { } builder, you're replacing the builder Kord Extensions provides by default. Make sure your builder always adds to the message and never results in an empty message, otherwise your bot may throw strange, cryptic errors in some situations.

ExtensibleBot(TOKEN) {
// ...

errorResponse { message, type ->
allowedMentions { } // Disable mentions/pings.

embed {
title = "Oopsie Woopsie!"
color = DISCORD_FUCHSIA

description = message.translate()
}
}
}

Builders

errorResponse { ... }Receiver: MessageCreateBuilder

Replace the error response builder, allowing you to add extra formatting to error messages.

Lambda Arguments
messageType: Key

The error message to be sent to users. Call message.translate() to get the corresponding String.

typeType: FailureReason

Object representing what actually went wrong. This is a sealed type, so you can check whether it's an instance of one of its subtypes.