How could I have a decorator on my command that runs before the command (like checks) but it also passes an additional parameter to my command function? Is this even possible with pycord's current implementation?
Example:
def load_guild_or_raise(func: Callable[[Any, ...], Coroutine]) -> Callable[[Any, ...], Coroutine]:
async def wrapper(self, ctx: discord.ApplicationContext, *args, **kwargs):
guild: GuildAdapter = GuildAdapter(ctx.guild.id)
await guild.load()
if not guild.exists:
raise NotFoundError
await func(self, ctx, *args, guild=guild, **kwargs)
return wrapper
# this is in a cog
@commands.slash_command(name="ping")
@discord.option(name="enable",
description="Enable or disable the ping feature",
type=bool,
)
@load_guild_or_raise
async def(self, ctx, enable: bool, guild: GuildAdapter):
await guild.disable_ping()
this dosen't work, it adds args and kwargs as options to my slash command