-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Enhanced cooldown system with bucket types (#57)
Co-authored-by: openhands <[email protected]> Co-authored-by: nicebots-xyz-bot <[email protected]>
- Loading branch information
1 parent
eecc0c3
commit 125de62
Showing
5 changed files
with
110 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) NiceBots | ||
# SPDX-License-Identifier: MIT | ||
|
||
from typing import Any, final, override | ||
|
||
import discord | ||
|
||
from src import custom | ||
from src.i18n.classes import RawTranslation, apply_locale | ||
from src.utils.cooldown import CooldownExceeded | ||
|
||
from .base import BaseErrorHandler, ErrorHandlerRType | ||
|
||
|
||
@final | ||
class CooldownErrorHandler(BaseErrorHandler[CooldownExceeded]): | ||
def __init__(self, translations: dict[str, RawTranslation]) -> None: | ||
self.translations = translations | ||
super().__init__(CooldownExceeded) | ||
|
||
@override | ||
async def __call__( | ||
self, | ||
error: CooldownExceeded, | ||
ctx: custom.Context | discord.Interaction, | ||
sendargs: dict[str, Any], | ||
message: str, | ||
report: bool, | ||
) -> ErrorHandlerRType: | ||
translations = apply_locale(self.translations, self._get_locale(ctx)) | ||
|
||
message = translations.error_cooldown_exceeded | ||
|
||
sendargs["ephemeral"] = True | ||
|
||
return False, False, message, sendargs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters