【发布时间】:2020-10-09 19:16:21
【问题描述】:
假设我有以下命令和子命令:
@commands.group()
async def channel(self, ctx, channel_name_or_id):
# convert channel_name_or_id to channel object
@channel.command()
async def get_mention(ctx, channel_object):
await ctx.send(channel_object.mention)
@channel.command()
async def get_id(ctx, channel_object):
await ctx.send(channel_object.id)
我希望父命令将名称或 ID 转换为对象,然后将该对象传递给子命令。有没有办法做到这一点? ctx.invoked_subcommand.pass(channel_object) 之类的东西?
【问题讨论】:
标签: python discord.py-rewrite subcommand