JDA-Applications / JDA-Utilities

A series of tools and utilities for JDA to assist in bot creation
Apache License 2.0
217 stars 110 forks source link

Fixes for cooldown handling #102

Closed kantenkugel closed 4 years ago

kantenkugel commented 4 years ago

Pull Request

Pull Request Checklist

Please follow the following steps before opening this PR.
PRs that do not complete the checklist will be subject to denial for missing information.

Pull Request Information

Check and fill in the blanks for all that apply:

Description

This PR adds 2 fixes to the cooldown handling:

Cooldowns are now properly rounded up

Up until now, CommandClient#getRemainingCooldown() returns the rounded down amount of seconds remaining, which results in cooldowns effectively being (almost) 1 second shorter than they should be: If 1 second cooldown is set, then at the next check (lets assume 990ms cooldown left), getRemainingCooldown() would return 0, which in turn allows the command to be executed again.

By fetching the amount of ms remaining and rounding that up to the next second, this PR attemts to fix that issue.

Allows for disabling of cooldown error message

Now it is possible to override Command#getCooldownError() and return null in order to disable cooldown error messages to be sent