Package me.jakejmattson.discordkt.api.arguments

Argument types for parsing command input.

Types

AnyArg
Link copied to clipboard
open class AnyArg(name: String, description: String) : ArgumentType<String>
Accepts any (single) argument.
ArgumentResult
Link copied to clipboard
sealed class ArgumentResult<T>
The result of an argument conversion.
ArgumentType
Link copied to clipboard
interface ArgumentType<T> : Cloneable
An object that represents a type and contains the logic to convert string arguments to the desired type.
AttachmentArg
Link copied to clipboard
open class AttachmentArg(name: String, description: String) : ArgumentType<Attachment>
Accepts a file as a message attachment.
BooleanArg
Link copied to clipboard
open class BooleanArg(name: String, truthValue: String, falseValue: String, description: String) : ArgumentType<Boolean>
Accepts either of two values.
CategoryArg
Link copied to clipboard
open class CategoryArg(name: String, description: String, guildId: Snowflake?, allowsGlobal: Boolean) : ArgumentType<Category>
Accepts a Discord Category entity as an ID, a mention, or by name.
ChannelArg
Link copied to clipboard
open class ChannelArg<T : GuildChannel>(name: String, description: String, allowsGlobal: Boolean) : ArgumentType<T>
Accepts a Discord TextChannel entity as an ID or mention.
CharArg
Link copied to clipboard
open class CharArg(name: String, description: String) : ArgumentType<Char>
Accepts a single character.
ChoiceArg
Link copied to clipboard
open class ChoiceArg<T>(name: String, description: String, choices: T) : ArgumentType<T>
Accepts a choice from the provided list.
CommandArg
Link copied to clipboard
open class CommandArg(name: String, description: String) : ArgumentType<Command>
Accepts a DiscordKt command by name.
DoubleArg
Link copied to clipboard
open class DoubleArg(name: String, description: String) : ArgumentType<Double>
Accept a decimal number in the double range.
Either
Link copied to clipboard
sealed class Either<out L, out R>
Represent 2 possible types in a single object.
EitherArg
Link copied to clipboard
class EitherArg<L, R>(left: ArgumentType<L>, right: ArgumentType<R>, name: String, description: String) : ArgumentType<Either<L, R>>
Accept either the left argument or the right ArgumentType.
Error
Link copied to clipboard
data class Error<T>(error: String) : ArgumentResult<T>
ArgumentResult indicating that a conversion was failed.
EveryArg
Link copied to clipboard
open class EveryArg(name: String, description: String) : ArgumentType<String>
Consumes all remaining arguments.
GuildArg
Link copied to clipboard
open class GuildArg(name: String, description: String) : ArgumentType<Guild>
Accepts a Discord Guild entity as an ID.
GuildEmojiArg
Link copied to clipboard
open class GuildEmojiArg(name: String, description: String, allowsGlobal: Boolean) : ArgumentType<GuildEmoji>
Accepts a guild emoji.
HexColorArg
Link copied to clipboard
open class HexColorArg(name: String, description: String) : ArgumentType<Color>
Accepts a color in hexadecimal format.
IntegerArg
Link copied to clipboard
open class IntegerArg(name: String, description: String) : ArgumentType<Int>
Accept a whole number in the int range.
IntegerRangeArg
Link copied to clipboard
open class IntegerRangeArg(min: Int, max: Int, name: String, description: String) : ArgumentType<Int>
Accepts an integer within a pre-defined range.
Left
Link copied to clipboard
data class Left<out L>(data: L) : Either<L, Nothing>
An Either type
LongArg
Link copied to clipboard
open class LongArg(name: String, description: String) : ArgumentType<Long>
Accept a whole number in the long range.
MemberArg
Link copied to clipboard
open class MemberArg(name: String, description: String, allowsBot: Boolean) : ArgumentType<Member>
Accepts a Discord Member entity as an ID or mention.
MessageArg
Link copied to clipboard
open class MessageArg(name: String, description: String, allowsGlobal: Boolean) : ArgumentType<Message>
Accepts a Discord Message entity as an ID or a link.
MultipleArg
Link copied to clipboard
class MultipleArg<T>(base: ArgumentType<T>, name: String, description: String) : ArgumentType<List<T>>
Accepts multiple arguments of the given type.
OptionalArg
Link copied to clipboard
class OptionalArg<G>(name: String, type: ArgumentType<*>, default: suspend CommandEvent<*>.() -> G) : ArgumentType<G>
An optional argument with a default value.
QuoteArg
Link copied to clipboard
open class QuoteArg(name: String, description: String) : ArgumentType<String>
Accepts a group of arguments surrounded by quotation marks.
Right
Link copied to clipboard
data class Right<out R>(data: R) : Either<Nothing, R>
An Either type
RoleArg
Link copied to clipboard
open class RoleArg(name: String, description: String, guildId: Snowflake?, allowsGlobal: Boolean) : ArgumentType<Role>
Accepts a Discord Role entity as an ID, a mention, or by name.
SplitterArg
Link copied to clipboard
open class SplitterArg(splitter: String, name: String, description: String) : ArgumentType<List<String>>
Consumes all arguments and returns a list of the results (split by splitter character).
Success
Link copied to clipboard
data class Success<T>(result: T, consumed: Int) : ArgumentResult<T>
ArgumentResult indicating that a conversion was successful.
TimeArg
Link copied to clipboard
open class TimeArg(name: String, description: String) : ArgumentType<Double>
Accepts a group of time elements and returns the number of seconds as a double.
UnicodeEmojiArg
Link copied to clipboard
open class UnicodeEmojiArg(name: String, description: String) : ArgumentType<DiscordEmoji>
Accepts a unicode emoji.
UrlArg
Link copied to clipboard
open class UrlArg(name: String, description: String) : ArgumentType<String>
Accepts a string that matches the URL regex.
UserArg
Link copied to clipboard
open class UserArg(name: String, description: String) : ArgumentType<User>
Accepts a Discord User entity as an ID or mention.

Functions

or
Link copied to clipboard
infix fun <L, R> ArgumentType<L>.or(right: ArgumentType<R>): EitherArg<L, R>
Syntactic sugar for creating an EitherArg from the two given types.