Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Cooldown annotation #15

Open
IIHERO4 opened this issue Jun 25, 2022 · 2 comments
Open

@Cooldown annotation #15

IIHERO4 opened this issue Jun 25, 2022 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@IIHERO4
Copy link

IIHERO4 commented Jun 25, 2022

Extend the drink api to include cooldown annotations for ease of managing cooldowns @Require-like

Per: the time at which the uses gets reset
Rate: the number of times that are allowed the command to be executed in a specific amount of time
BucketType: Which to apply the cooldown on

This is inspired by discord.py cooldowns

BucketTypes:

  • USER - applys a per-user cooldown
  • COMMAND - applys the cooldown globally

Behavior:

When annotated on an @Command annotated method

The cooldown applys on that command with respect to the bucket type, if a player is on cooldown. it will call a handler callback1.

When annotated on the class

Either The cooldown mapping is shared across all sub commands OR Add a mapping as the same as @Cooldown being annotated on all of the sub commands

You can achive this by making a boolean or another annotated @ClassCooldown for example

Footnotes

  1. A cooldown handler is should be a function that takes in (Player, DrinkContainer), (You may also make it return a boolean, if false the cooldown will be neglected)

@IIHERO4
Copy link
Author

IIHERO4 commented Jun 25, 2022

I may implement this if i get time in about 2 weeks but feel free if u have suggestions or anyone to do it

@jonahseguin
Copy link
Owner

jonahseguin commented Jun 27, 2022

Perhaps a system for binding annotations to whole command methods ("modifiers"?) similar to @Require would be nice to have, so that this and similar implementations can be done by users.

such as:

drink.bindModifier(Cooldown.class).to(CooldownHandler::new);

where Cooldown.class is the @Annotation class, and CooldownHandler implements a Modifier interface or abstract class.

I don't have any time to do this soon, but seems like a good idea.

You could also technically get the behaviour you want using a custom annotation+provider on the player/sender type

@jonahseguin jonahseguin added enhancement New feature or request help wanted Extra attention is needed labels Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants