BaseCommandEvent

Event for regex-based text commands.

Localization

You can send localized replies using the user, guild and also any [Locale], by using this event directly, see LocalizableTextCommand for more details and configuration.

An alternative to using this event is injecting an TextLocalizationContext in a parameter, or retrieving one using getLocalizationContext.

In both cases, you can configure the locale, using TextCommandLocaleProvider.

Rate limit cancellation

Although it is recommended to reject commands using TextCommandFilter, you can also return the bucket token with cancelRateLimit if you want to avoid consuming bandwidth in certain conditions.

Constructors

Link copied to clipboard
constructor(@NotNull api: @NotNull JDA, responseNumber: Long, @NotNull message: @NotNull Message)

Properties

Link copied to clipboard

Gets the message's author as an InputUser.

Link copied to clipboard

Functions

Link copied to clipboard
abstract fun cancelRateLimit()

Cancels the token consumption of the current rate limited interaction.

Link copied to clipboard
abstract fun failureReporter(message: String): Consumer<in Throwable>
Throwable consumer that, when triggered, sends an error message to the event's GuildMessageChannel and to the bot owner with the exception name and the simple exception description
Link copied to clipboard
abstract fun getArgumentsStr(): String
Returns the full argument part of the message
Link copied to clipboard
Returns the unresolved arguments of the command event
Link copied to clipboard
open fun getAuthor(): User
Link copied to clipboard
abstract fun getAuthorBestName(): String
Returns the best author name possibleIf the User is not in the guild then returns his tag (Name#Discriminator)If the User is in the guild then returns his effective name
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Returns the default embed, equivalent to BContext.getDefaultEmbedSupplier().get()
Link copied to clipboard
Returns the default embed footer icon, equivalent to BContext.getDefaultFooterIconSupplier().get()
Link copied to clipboard

Retrieves a DefaultMessages instance, using a locale suitable for messages sent to the user.

Link copied to clipboard
open fun getGuild(): Guild
Link copied to clipboard
Link copied to clipboard
abstract fun getGuildMessage(localizationPath: String, entries: Array<Localization.Entry>): String

Returns the localized message at the following path, using the guild's locale and provided parameters.

Link copied to clipboard
fun LocalizableTextCommand.getGuildMessage(localizationPath: String, vararg entries: PairEntry): String
Link copied to clipboard
open fun getJDA(): JDA
Link copied to clipboard
open fun getJumpUrl(): String
Link copied to clipboard

If set, forces the specified localization bundle to be used.

Link copied to clipboard
abstract fun getLocalizationContext(bundleName: String, pathPrefix: String): LocalizationContext

Returns a localization context for the provided bundle name and path prefix.

abstract fun getLocalizationContext(bundleName: String, pathPrefix: String): TextLocalizationContext

Returns a localization context for the provided bundle name and path prefix, using the locale from TextCommandLocaleProvider.getDiscordLocale.

Link copied to clipboard

If set, adds the specified prefix to the path of every localization call, useful to avoid using very long strings in every reply/edit.

Link copied to clipboard
abstract fun getLocalizedMessage(locale: Locale, localizationPath: String, entries: Array<Localization.Entry>): String

Returns the localized message at the following path, using the provided locale and parameters.

Link copied to clipboard
fun LocalizableAction.getLocalizedMessage(locale: Locale, localizationPath: String, vararg entries: PairEntry): String
fun LocalizableAction.getLocalizedMessage(locale: DiscordLocale, localizationPath: String, vararg entries: PairEntry): String
Link copied to clipboard
The Author of the Message received as Member object.
Link copied to clipboard
open fun getMessageId(): String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@CheckReturnValue
abstract fun indicateError(@NotNull text: @NotNull CharSequence): @NotNull RestAction<Message>
@CheckReturnValue
abstract fun indicateError(@NotNull embed: @NotNull MessageEmbed, @NotNull other: Array<@NotNull MessageEmbed>): @NotNull RestAction<Message>
Sends an error reply in the event's channel
Link copied to clipboard
@CheckReturnValue
abstract fun indicateErrorFormat(@NotNull format: @NotNull String, @NotNull args: Array<@NotNull Any>): @NotNull RestAction<Message>
Sends an error reply in the event's channel
Link copied to clipboard
open fun isFromGuild(): Boolean
Link copied to clipboard
open fun isFromThread(): Boolean
Link copied to clipboard
open fun isFromType(type: ChannelType): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@CheckReturnValue
abstract fun reactError(): RestAction<Void>
Add a :x: reaction on the event message to indicate a command error
Link copied to clipboard
@CheckReturnValue
abstract fun reactSuccess(): RestAction<Void>
Add a :white_check_mark: reaction on the event message to indicate command success
Link copied to clipboard
@CheckReturnValue
abstract fun reply(@NotNull text: @NotNull CharSequence): @NotNull MessageCreateAction
@CheckReturnValue
abstract fun reply(@NotNull embed: @NotNull MessageEmbed, @NotNull other: Array<@NotNull MessageEmbed>): @NotNull MessageCreateAction
Sends a reply in the event's channel
Link copied to clipboard
@CheckReturnValue
abstract fun replyFile(@NotNull fileUploads: Array<@NotNull FileUpload>): @NotNull RestAction<Message>
Sends a file as a reply in the event's channel
Link copied to clipboard
@CheckReturnValue
abstract fun replyFormat(@NotNull format: @NotNull String, @NotNull args: Array<@NotNull Any>): @NotNull MessageCreateAction
Sends a reply in the event's channel
Link copied to clipboard
abstract fun replyGuild(localizationPath: String, entries: Array<Localization.Entry>): MessageCreateAction

Replies with the localized message at the following path, using the guild's locale and provided parameters.

Link copied to clipboard
fun LocalizableTextCommand.replyGuild(localizationPath: String, vararg entries: PairEntry): MessageCreateAction
Link copied to clipboard
open fun replyLocalized(locale: DiscordLocale, localizationPath: String, entries: Array<Localization.Entry>): MessageCreateAction

Replies with the localized message at the following path, using the provided locale and parameters.

Link copied to clipboard
fun BaseCommandEvent.replyLocalized(context: LocalizationContext, localizationPath: String, vararg entries: PairEntry): MessageCreateAction

Replies a localized message to the user's command.

fun LocalizableTextCommand.replyLocalized(locale: Locale, localizationPath: String, vararg entries: PairEntry): MessageCreateAction
Link copied to clipboard
abstract fun reportError(message: String, e: Throwable)
Send an error message to the event's GuildMessageChannel and to the bot owner with the exception name and the simple exception description
Link copied to clipboard
@CheckReturnValue
abstract fun respond(@NotNull text: @NotNull CharSequence): @NotNull MessageCreateAction
@CheckReturnValue
abstract fun respond(@NotNull embed: @NotNull MessageEmbed, @NotNull other: Array<@NotNull MessageEmbed>): @NotNull MessageCreateAction
Sends a response in the event's channel
Link copied to clipboard
@CheckReturnValue
abstract fun respondFile(@NotNull fileUploads: Array<@NotNull FileUpload>): @NotNull MessageCreateAction
Sends a file as a response in the event's channel
Link copied to clipboard
@CheckReturnValue
abstract fun respondFormat(@NotNull format: @NotNull String, @NotNull args: Array<@NotNull Any>): @NotNull MessageCreateAction
Sends a response in the event's channel
Link copied to clipboard
abstract fun respondGuild(localizationPath: String, entries: Array<Localization.Entry>): MessageCreateAction

Responds with the localized message at the following path, using the guild's locale and provided parameters.

Link copied to clipboard
Link copied to clipboard
open fun respondLocalized(locale: DiscordLocale, localizationPath: String, entries: Array<Localization.Entry>): MessageCreateAction

Responds with the localized message at the following path, using the provided locale and parameters.

Link copied to clipboard

Sends a localized message to the event's channel.

fun LocalizableTextCommand.respondLocalized(locale: Locale, localizationPath: String, vararg entries: PairEntry): MessageCreateAction
Link copied to clipboard
@CheckReturnValue
abstract fun sendWithEmbedFooterIcon(embed: MessageEmbed): RestAction<Message>
Sends a MessageEmbed on the event's channel with the default footer icon
@CheckReturnValue
abstract fun sendWithEmbedFooterIcon(channel: MessageChannel, embed: MessageEmbed): RestAction<Message>
@CheckReturnValue
abstract fun sendWithEmbedFooterIcon(channel: MessageChannel, iconStream: InputStream, embed: MessageEmbed): RestAction<Message>
Sends a MessageEmbed on the specified channel with the default footer icon
Link copied to clipboard
abstract fun setLocalizationBundle(<set-?>: String)

If set, forces the specified localization bundle to be used.

Link copied to clipboard
abstract fun setLocalizationPrefix(<set-?>: String)

If set, adds the specified prefix to the path of every localization call, useful to avoid using very long strings in every reply/edit.

Link copied to clipboard
open fun toString(): String