0

次のコマンドとサブコマンドがあるとします。

@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)

4

1 に答える 1

0

を使用してチャネル オブジェクトを取得できますself.client.get_channel(id)。(歯車の場合) でインスタンス化するクラス レベルの変数を使用し、__init__()それをチャネル オブジェクトに設定することができます。

于 2020-06-19T14:36:59.013 に答える