-
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.
feat: use generic type to ClientT (#58)
* feat: use generic type to ClientT * style: apply code style
- Loading branch information
1 parent
ae90a35
commit 64dd7c5
Showing
1 changed file
with
7 additions
and
7 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,25 +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[Crenata]): | ||
def __init__(self, client: Crenata, *, fallback_to_global: bool = True): | ||
class CrenataCommandTree(CommandTree[ClientT]): | ||
def __init__(self, client: ClientT, *, 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[Crenata]) -> None: | ||
def set_error_handler(self, handler: ErrorHandler[ClientT]) -> None: | ||
self.error_handler = handler | ||
|
||
async def on_error( | ||
self, interaction: Interaction[Crenata], error: AppCommandError | ||
self, interaction: Interaction[ClientT], error: AppCommandError | ||
) -> None: | ||
await self.error_handler.on_error(interaction, error) | ||
|
||
async def interaction_check(self, interaction: Interaction[Crenata]) -> bool: | ||
async def interaction_check(self, interaction: Interaction[ClientT]) -> bool: | ||
... |