diff --git a/v6d2ctx/context.py b/v6d2ctx/context.py index 203fc77..47d1fca 100644 --- a/v6d2ctx/context.py +++ b/v6d2ctx/context.py @@ -9,10 +9,11 @@ usertype = Union[discord.abc.User, discord.user.BaseUser, discord.Member, discor class Context: - def __init__(self, message: discord.Message): + def __init__(self, message: discord.Message, client: discord.Client): self.message: discord.Message = message + self.client: discord.Client = client self.channel: discord.abc.Messageable = message.channel - self.dm_or_text: Union[discord.DMChannel, discord.TextChannel] = message.channel + self.dm_or_text: Union[discord.DMChannel, discord.TextChannel] = message.channel # type: ignore self.author: usertype = message.author self.content: str = message.content self.member: Optional[discord.Member] = message.author if isinstance(message.author, discord.Member) else None diff --git a/v6d2ctx/handle_args.py b/v6d2ctx/handle_args.py index e9caf55..8190504 100644 --- a/v6d2ctx/handle_args.py +++ b/v6d2ctx/handle_args.py @@ -4,12 +4,12 @@ from v6d2ctx.context import Context, Implicit, Explicit from v6d2ctx.handle_command import handle_command -async def handle_args(message: discord.Message, args: list[str]): +async def handle_args(message: discord.Message, args: list[str], client: discord.Client): match args: case []: return case [command_name, *command_args]: - ctx = Context(message) + ctx = Context(message, client) try: await handle_command(ctx, command_name, command_args) except Implicit: diff --git a/v6d2ctx/handle_content.py b/v6d2ctx/handle_content.py index abf48e7..962e9c2 100644 --- a/v6d2ctx/handle_content.py +++ b/v6d2ctx/handle_content.py @@ -5,11 +5,11 @@ import discord from v6d2ctx.handle_args import handle_args -async def handle_content(message: discord.Message, content: str, prefix: str): +async def handle_content(message: discord.Message, content: str, prefix: str, client: discord.Client): if message.author.bot: return if not content.startswith(prefix): return content = content.removeprefix(prefix) args = shlex.split(content) - await handle_args(message, args) + await handle_args(message, args, client)