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

io.github.freya022.botcommands.api.commands.ratelimit.handler.RateLimitHandler.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.22
Show newest version
package io.github.freya022.botcommands.api.commands.ratelimit.handler

import io.github.bucket4j.ConsumptionProbe
import io.github.freya022.botcommands.api.core.BContext
import io.github.freya022.botcommands.internal.commands.application.ApplicationCommandInfo
import io.github.freya022.botcommands.internal.commands.text.TextCommandInfo
import net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent
import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent
import net.dv8tion.jda.api.events.message.MessageReceivedEvent
import net.dv8tion.jda.api.interactions.callbacks.IMessageEditCallback
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback

/**
 * Defines the behavior when a rate limited is triggered.
 */
interface RateLimitHandler {
    suspend fun onRateLimit(context: BContext, event: MessageReceivedEvent, commandInfo: TextCommandInfo, probe: ConsumptionProbe)

    suspend fun  onRateLimit(context: BContext, event: T, commandInfo: ApplicationCommandInfo, probe: ConsumptionProbe)
            where T : GenericCommandInteractionEvent,
                  T : IReplyCallback

    suspend fun  onRateLimit(context: BContext, event: T, probe: ConsumptionProbe)
            where T : GenericComponentInteractionCreateEvent,
                  T : IReplyCallback,
                  T : IMessageEditCallback
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy