-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: handler types * style: apply code style
- Loading branch information
1 parent
4ba2b43
commit ae90a35
Showing
2 changed files
with
12 additions
and
10 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 |
---|---|---|
@@ -1,23 +1,25 @@ | ||
from __future__ import annotations | ||
|
||
from discord import Interaction | ||
from discord._types import ClientT | ||
from discord.app_commands.errors import AppCommandError | ||
from discord.app_commands.tree import CommandTree | ||
|
||
from crenata.application.client import Crenata | ||
from crenata.application.error.handler import ErrorHandler | ||
|
||
|
||
class CrenataCommandTree(CommandTree[ClientT]): | ||
def __init__(self, client: ClientT, *, fallback_to_global: bool = True): | ||
class CrenataCommandTree(CommandTree[Crenata]): | ||
def __init__(self, client: Crenata, *, fallback_to_global: bool = True): | ||
super().__init__(client, fallback_to_global=fallback_to_global) | ||
self.error_handler: ErrorHandler[Crenata] = ErrorHandler() | ||
|
||
self.error_handler: ErrorHandler[ClientT] = ErrorHandler() | ||
|
||
def set_error_handler(self, handler: ErrorHandler[ClientT]) -> None: | ||
def set_error_handler(self, handler: ErrorHandler[Crenata]) -> None: | ||
self.error_handler = handler | ||
|
||
async def on_error( | ||
self, interaction: Interaction[ClientT], error: AppCommandError | ||
self, interaction: Interaction[Crenata], error: AppCommandError | ||
) -> None: | ||
await self.error_handler.on_error(interaction, error) | ||
|
||
async def interaction_check(self, interaction: Interaction[Crenata]) -> bool: | ||
... |
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