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

io.github.freya022.botcommands.api.commands.text.TextSuggestionSupplier.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.commands.text

import info.debatty.java.stringsimilarity.NormalizedLevenshtein
import io.github.freya022.botcommands.api.core.service.annotations.InterfacedService
import io.github.freya022.botcommands.internal.commands.text.TopLevelTextCommandInfo

/**
 * Interface to supply text command suggestions from a top level name.
 *
 * ### Default implementation
 *
 * The default implementation uses a [normalized Levenshtein][NormalizedLevenshtein] similarity and does the following:
 * - Get the partial similarity between all commands, keeping 90% similarity and above (partial similarity compares the shortest substring of both the command name and the user input)
 * - Get the similarity of the remaining commands, keeping 42% similarity and above
 *
 * @see InterfacedService @InterfacedService
 */
@InterfacedService(acceptMultiple = false)
fun interface TextSuggestionSupplier {
    /**
     * Computes command suggestions from the [user input][topLevelName] and the [available commands][candidates].
     *
     * Commands are already filtered to only include those which can be shown,
     * only requiring you to match against the user input.
     *
     * @param topLevelName The user input, which should correspond to the top level command
     * @param candidates   The available commands, all of them can be shown to the user
     *
     * @return The list of commands suggested to the user
     */
    fun getSuggestions(topLevelName: String, candidates: List): Collection
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy