CommandEvent

abstract class CommandEvent : BaseCommandEventImpl(source)

Event for fallback text commands.

Arguments are tokenized and resolved into entities if possible

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(context: BContext, event: MessageReceivedEvent, args: String, cancellableRateLimit: CancellableRateLimit, localizableTextCommand: LocalizableTextCommand)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Gets the message's author as an InputUser.

Link copied to clipboard

Functions

Link copied to clipboard
abstract fun cancelRateLimit()
open 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
open 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 getArguments(): List<Any>
Returns the resolved arguments of the command event, these can be a User, Role, TextChannel or a String
Link copied to clipboard
Returns the unresolved arguments of the command event

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

Returns the best author name possible

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Returns the default embed, equivalent to BContext.getDefaultEmbedSupplier().get()

Returns the default embed, equivalent to BContext.getDefaultEmbedSupplier().get()

Link copied to clipboard
Returns the default embed footer icon, equivalent to BContext.getDefaultFooterIconSupplier().get()

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
open 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
open 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
open 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.
open fun getMember(): Member
Link copied to clipboard
open fun getMessageId(): String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun <T> hasNext(clazz: Class<T>): Boolean
Checks if the next argument exists and is of type T, returns true if so
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

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

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
abstract fun <T> nextArgument(clazz: Class<T>): @NotNull T
Returns the next argument if it is of type T
Link copied to clipboard
abstract fun <T> peekArgument(clazz: Class<T>): T
Link copied to clipboard
@CheckReturnValue
abstract fun reactError(): RestAction<Void>
Add a :x: reaction on the event message to indicate a command error

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

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

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
open fun replyFile(fileUploads: Array<FileUpload>): 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
open fun replyFormat(format: String, args: Array<Any>): MessageCreateAction

Sends a reply in the event's channel

Link copied to clipboard
abstract fun replyGuild(localizationPath: String, entries: Array<Localization.Entry>): MessageCreateAction
open 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
open fun replyLocalized(locale: Locale, 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
open 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
abstract fun <T : IMentionable?> resolveNext(classes: Array<Class<out Any>>): @NotNull T
Returns the next IMentionable
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

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

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
open fun respondFormat(format: String, args: Array<Any>): MessageCreateAction

Sends a response in the event's channel

Link copied to clipboard
abstract fun respondGuild(localizationPath: String, entries: Array<Localization.Entry>): MessageCreateAction
open 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
open fun respondLocalized(locale: Locale, 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

Sends a MessageEmbed on the event's channel with the default footer icon

Link copied to clipboard
abstract fun setLocalizationBundle(<set-?>: String)
open fun setLocalizationBundle($self: String)

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

Link copied to clipboard
abstract fun setLocalizationPrefix(<set-?>: String)
open fun setLocalizationPrefix($self: 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