io.github.freya022.botcommands.api.commands.text.CommandEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of BotCommands Show documentation
Show all versions of BotCommands Show documentation
A Kotlin-first (and Java) framework that makes creating Discord bots a piece of cake, using the JDA library.
package io.github.freya022.botcommands.api.commands.text;
import io.github.freya022.botcommands.api.commands.ratelimit.CancellableRateLimit;
import io.github.freya022.botcommands.api.commands.text.exceptions.BadIdException;
import io.github.freya022.botcommands.api.commands.text.exceptions.NoIdException;
import io.github.freya022.botcommands.api.core.BContext;
import io.github.freya022.botcommands.api.localization.context.TextLocalizationContext;
import io.github.freya022.botcommands.api.localization.text.LocalizableTextCommand;
import io.github.freya022.botcommands.api.localization.text.TextCommandLocaleProvider;
import io.github.freya022.botcommands.internal.commands.text.BaseCommandEventImpl;
import net.dv8tion.jda.api.entities.IMentionable;
import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.NoSuchElementException;
/**
* 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 {@link LocalizableTextCommand} for more details and configuration.
*
* An alternative to using this event is injecting an {@link TextLocalizationContext} in a parameter,
* or retrieving one using {@link #getLocalizationContext(String, String)}.
*
* In both cases, you can configure the locale, using {@link TextCommandLocaleProvider}.
*
*
Rate limit cancellation
* Although it is recommended to reject commands using {@link TextCommandFilter},
* you can also return the bucket token with {@link #cancelRateLimit()}
* if you want to avoid consuming bandwidth in certain conditions.
*/
public abstract class CommandEvent extends BaseCommandEventImpl {
public CommandEvent(BContext context, MessageReceivedEvent event, String args, CancellableRateLimit cancellableRateLimit, LocalizableTextCommand localizableTextCommand) {
super(context, event, args, cancellableRateLimit, localizableTextCommand);
}
/**
* Returns the resolved arguments of the command event, these can be a {@link User}, {@link Role}, {@link TextChannel} or a {@link String}
*
* @return List of arguments
*/
public abstract List