Package me.jakejmattson.discordkt.arguments

Argument types for parsing command input.

Types

Link copied to clipboard
open class AnyArg(val name: String = "Any", val description: String = internalLocale.anyArgDescription) : StringArgument<String>

Accepts any (single) argument. Does not accept empty strings.

Link copied to clipboard
interface Argument<Input, Output> : Cloneable

An object that represents a type and contains the logic to convert string arguments to the desired type.

Link copied to clipboard
open class AttachmentArg(val name: String = "Attachment", val description: String = internalLocale.attachmentArgDescription) : AttachmentArgument<Attachment>

Accepts a message attachment.

Link copied to clipboard
interface AttachmentArgument<Output> : EntityArgument<Attachment, Output>

An Argument that accepts an Attachment.

Link copied to clipboard
open class AutocompleteArg<Input, Output>(    val name: String,     val description: String,     val type: PrimitiveArgument<Input, Output>,     autocomplete: suspend AutocompleteData.() -> List<Input>) : WrappedArgument<Input, Output, Input, Output>

Provides autocomplete options to slash input.

Link copied to clipboard
data class AutocompleteData(val interaction: AutoCompleteInteraction, val input: String)

The data provided to process autocomplete interactions.

Link copied to clipboard
open class BooleanArg(    val name: String = "Boolean",     val truthValue: String = "true",     val falseValue: String = "false",     val description: String = internalLocale.booleanArgDescription.inject(truthValue, falseValue)) : BooleanArgument<Boolean>

Accepts either of two values. Defaults to true/false.

Link copied to clipboard
interface BooleanArgument<Output> : PrimitiveArgument<Boolean, Output>

An Argument that accepts a Boolean.

Link copied to clipboard
open class ChannelArg<T : GuildChannel>(    val name: String = "Channel",     val description: String = internalLocale.channelArgDescription,     allowsGlobal: Boolean = false) : ChannelArgument<T>

Accepts a Discord TextChannel entity as an ID or mention.

Link copied to clipboard
interface ChannelArgument<Output> : EntityArgument<Channel, Output>

An Argument that accepts a Channel.

Link copied to clipboard
open class CharArg(val name: String = "Character", val description: String = internalLocale.charArgDescription) : StringArgument<Char>

Accepts a single character.

Link copied to clipboard
open class ChoiceArg<T>(    val name: String,     val description: String = internalLocale.choiceArgDescription,     choices: T) : StringArgument<T>

Accepts a choice from the provided list.

Link copied to clipboard
open class CommandArg(val name: String = "Command", val description: String = internalLocale.commandArgDescription) : StringArgument<Command>

Accepts a DiscordKt command by name.

Link copied to clipboard
open class DoubleArg(val name: String = "Double", val description: String = internalLocale.doubleArgDescription) : DoubleArgument<Double>

Accept a decimal number in the double range.

Link copied to clipboard
interface DoubleArgument<Output> : PrimitiveArgument<Double, Output>

An Argument that accepts a Double.

Link copied to clipboard
interface EntityArgument<Input, Output> : Argument<Input, Output>

An Argument that accepts a discord entity.

Link copied to clipboard
data class Error<T>(val error: String) : Result<T>

Result indicating that a conversion was failed.

Link copied to clipboard
open class EveryArg(val name: String = "Text", val description: String = internalLocale.everyArgDescription) : StringArgument<String>

Consumes all remaining arguments. Does not accept empty strings.

Link copied to clipboard
open class GuildArg(val name: String = "Guild", val description: String = internalLocale.guildArgDescription) : StringArgument<Guild>

Accepts a Discord Guild entity as an ID.

Link copied to clipboard
open class GuildEmojiArg(    val name: String = "Guild Emoji",     val description: String = internalLocale.guildEmojiArgDescription,     allowsGlobal: Boolean = false) : StringArgument<GuildEmoji>

Accepts a guild emoji.

Link copied to clipboard
open class HexColorArg(val name: String = "Color", val description: String = internalLocale.hexColorArgDescription) : StringArgument<Color>

Accepts a color in hexadecimal format. The '#' symbol is optional.

Link copied to clipboard
open class IntegerArg(val name: String = "Integer", val description: String = internalLocale.integerArgDescription) : IntegerArgument<Int>

Accept a whole number in the int range.

Link copied to clipboard
interface IntegerArgument<Output> : PrimitiveArgument<Int, Output>

An Argument that accepts an Int.

Link copied to clipboard
open class IntegerRangeArg(    min: Int,     max: Int,     val name: String = "Integer (",     val description: String = internalLocale.integerRangeArgDescription.inject(min.toString(), max.toString())) : IntegerArgument<Int>

Accepts an integer within a pre-defined range.

Link copied to clipboard
open class MemberArg(    val name: String = "Member",     val description: String = internalLocale.memberArgDescription,     allowsBot: Boolean = false) : UserArgument<Member>

Accepts a Discord Member entity as an ID or mention.

Link copied to clipboard
open class MessageArg(    val name: String = "Message",     val description: String = internalLocale.messageArgDescription,     allowsGlobal: Boolean = false) : StringArgument<Message>

Accepts a Discord Message entity as an ID or a link.

Link copied to clipboard
class MultipleArg<Input, Output>(    val type: Argument<Input, Output>,     val name: String = type.name,     description: String = "") : WrappedArgument<Input, Output, List<Input>, List<Output>>

Accepts multiple arguments of the given type. Returns a list.

Link copied to clipboard
class OptionalArg<I, O, O2>(    val name: String,     val type: Argument<I, O>,     default: suspend DiscordContext.() -> O2) : WrappedArgument<I, O, I, O2>

An optional argument with a default value.

Link copied to clipboard
interface PrimitiveArgument<Input, Output> : Argument<Input, Output>

An Argument that accepts a primitive type.

Link copied to clipboard
open class QuoteArg(val name: String = "Quote", val description: String = internalLocale.quoteArgDescription) : StringArgument<String>

Accepts a group of arguments surrounded by quotation marks.

Link copied to clipboard
sealed class Result<T>

The result of some conversion.

Link copied to clipboard
open class RoleArg(    val name: String = "Role",     val description: String = internalLocale.roleArgDescription,     guildId: Snowflake? = null,     allowsGlobal: Boolean = false) : RoleArgument<Role>

Accepts a Discord Role entity as an ID, a mention, or by name.

Link copied to clipboard
interface RoleArgument<Output> : EntityArgument<Role, Output>

An Argument that accepts a Role.

Link copied to clipboard
open class SplitterArg(    splitter: String = "|",     val name: String = "TextWithSplitter",     val description: String = internalLocale.splitterArgDescription.inject(splitter)) : StringArgument<List<String>>

Consumes all arguments and returns a list of the results (split by splitter character).

Link copied to clipboard
interface StringArgument<Output> : PrimitiveArgument<String, Output>

An Argument that accepts a String.

Link copied to clipboard
data class Success<T>(val result: T) : Result<T>

Result indicating that a conversion was successful.

Link copied to clipboard
open class TimeArg(val name: String = "Time", val description: String = internalLocale.timeArgDescription) : StringArgument<Double>

Accepts a group of time elements and returns the number of seconds as a double.

Link copied to clipboard
open class UnicodeEmojiArg(val name: String = "Emoji", val description: String = internalLocale.unicodeEmojiArgDescription) : StringArgument<DiscordEmoji>

Accepts a unicode emoji.

Link copied to clipboard
open class UrlArg(val name: String = "URL", val description: String = internalLocale.urlArgDescription) : StringArgument<String>

Accepts a string that matches the URL regex.

Link copied to clipboard
open class UserArg(val name: String = "User", val description: String = internalLocale.userArgDescription) : UserArgument<User>

Accepts a Discord User entity as an ID or mention.

Link copied to clipboard
interface UserArgument<Output> : EntityArgument<User, Output>

An Argument that accepts a User.

Link copied to clipboard
interface WrappedArgument<Input, Output, Input2, Output2> : Argument<Input2, Output2>

An Argument that wraps around another argument.

Functions

Link copied to clipboard
inline fun <T> WrappedArgument<*, *, *, *>.containsType(): Boolean

Perform a nested search on this wrapped argument to check for a certain type.