When adding checks to command groups, it is not possible to get access to the executed subcommand object from the context, which would be required for getting data from it, for example, in a subcommand permission system. Example:
Example code:
import hikari
import tanjun
def check(ctx: tanjun.abc.SlashContext) -> bool:
print(ctx.command.metadata.get("required_subcommand_permission"))
return True
group = tanjun.slash_command_group("testgroup", ".")
group.add_check(check)
@group.as_sub_command("test", ".")
async def test_command(ctx: tanjun.abc.SlashContext) -> None:
await ctx.respond(f"{ctx.command.metadata.get('required_subcommand_permission')}")
test_command.set_metadata("required_subcommand_permission", "some permission")
loader = tanjun.Component().load_from_scope().make_loader()
bot = hikari.impl.GatewayBot("MTE3MjQ5OTUzMDE5Mzg0NjI5Mg.GS629g.jhAkLkkPG9ixAliL_2TW2xYCDiWIFf5i_BXE5Y") # Doesn't exist
client = tanjun.Client.from_gateway_bot(bot, declare_global_commands=True)
client.load_modules("main")
if __name__ == "__main__":
bot.run()
When adding checks to command groups, it is not possible to get access to the executed subcommand object from the context, which would be required for getting data from it, for example, in a subcommand permission system. Example:
Example code: