All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.freya022.botcommands.api.parameters.ParameterResolver.kt Maven / Gradle / Ivy

Go to download

A Kotlin-first (and Java) framework that makes creating Discord bots a piece of cake, using the JDA library.

There is a newer version: 3.0.0-alpha.18
Show newest version
package io.github.freya022.botcommands.api.parameters

import io.github.freya022.botcommands.api.commands.application.slash.annotations.ChannelTypes
import io.github.freya022.botcommands.api.commands.application.slash.annotations.MentionsString
import io.github.freya022.botcommands.api.core.entities.InputUser
import io.github.freya022.botcommands.api.core.service.annotations.BService
import io.github.freya022.botcommands.api.core.service.annotations.InterfacedService
import io.github.freya022.botcommands.api.parameters.resolvers.*
import net.dv8tion.jda.api.entities.*
import net.dv8tion.jda.api.entities.Message.Attachment
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel
import net.dv8tion.jda.api.entities.emoji.Emoji

/**
 * Base class for parameter resolvers used in text commands, application commands, and component callbacks.
 *
 * You need to extend [ClassParameterResolver] or [TypedParameterResolver] instead.
 *
 * ### Default parameter resolvers
 *
 * |                                                               | Text              | Slash           | Message context    | User context    | Components | Modals | Component timeout |
 * |---------------------------------------------------------------|-------------------|-----------------|--------------------|-----------------|------------|--------|-------------------|
 * | [String]                                                      | ✓ (can be quoted) | ✓               |                    |                 | ✓          | ✓      | ✓
 * | [Boolean]                                                     | ✓                 | ✓               |                    |                 | ✓          |        | ✓
 * | [Int]                                                         | ✓                 | ✓               |                    |                 | ✓          |        | ✓
 * | [Long]                                                        | ✓                 | ✓               |                    |                 | ✓          |        | ✓
 * | [Double]                                                      | ✓                 | ✓               |                    |                 | ✓          |        | ✓
 * | [Emoji]                                                       | ✓                 | ✓               |                    |                 | ✓          |        | ✓
 * | [IMentionable]                                                | ✓ (only mentions) | ✓               |                    |                 |            |        |
 * | [List] of mentionable (see [@MentionsString][MentionsString]) |                   | ✓               |                    |                 |            |        |
 * | [Role]                                                        | ✓                 | ✓               |                    |                 | ✓          |        |
 * | [UserSnowflake]                                               | ✓                 | ✓               |                    | ✓ (target user) | ✓          |        |
 * | [User]                                                        | ✓                 | ✓               |                    | ✓ (target user) | ✓          |        |
 * | [Member]                                                      | ✓                 | ✓               |                    | ✓ (target user) | ✓          |        |
 * | [InputUser]                                                   | ✓                 | ✓               |                    | ✓ (target user) | ✓          |        |
 * | [GuildChannel] subtypes1                           | ✓                 | ✓               |                    |                 | ✓          |        |
 * | [Guild]                                                       | ✓                 | ✓ (as a String) |                    |                 | ✓          |        |
 * | [Message]                                                     |                   |                 | ✓ (target message) |                 |            |        |
 * | [Attachment]                                                  |                   | ✓               |                    |                 |            |        |
 *
 * 1. The channel types are set automatically depending on the type,
 * but a broader channel type can be used
 * and restricted to multiple concrete types by using [@ChannelTypes][ChannelTypes].
 *
 * Parameter resolvers for services exist by default, and follow the rules described in [@BService][BService].
 *
 * You can also check loaded parameter resolvers in the logs on the `trace` level.
 *
 * @param T Type of the implementation
 * @param R Type of the returned resolved objects
 *
 * @see ClassParameterResolver
 *
 * @see ParameterResolverFactory
 *
 * @see TextParameterResolver
 * @see QuotableTextParameterResolver
 * @see ComponentParameterResolver
 * @see SlashParameterResolver
 * @see MessageContextParameterResolver
 * @see UserContextParameterResolver
 * @see TimeoutParameterResolver
 * @see ICustomResolver
 *
 * @see Resolvers
 */
@InterfacedService(acceptMultiple = true)
sealed class ParameterResolver, R : Any> : IParameterResolver




© 2015 - 2024 Weber Informatics LLC | Privacy Policy