Dem*_*try 4 python python-3.x discord discord.py
如何在 python bot 中创建子命令。
@bot.group(pass_context=True)
async def First(ctx):
if ctx.invoked_subcommand is None:
await bot.say('Invalid sub command passed...')
@First.command(pass_context=True)
async def Second(ctx):
msg = 'Finally got success {0.author.mention}'.format(ctx.message)
await bot.say(msg)
Run Code Online (Sandbox Code Playgroud)
你也需要建Second一个群。
@bot.group(pass_context=True)
async def First(ctx):
if ctx.invoked_subcommand is None:
await bot.say('Invalid sub command passed...')
@First.group(pass_context=True)
async def Second(ctx):
if ctx.invoked_subcommand is Second:
await bot.say('Invalid sub command passed...')
@Second.command(pass_context=True)
async def Third(ctx):
msg = 'Finally got success {0.author.mention}'.format(ctx.message)
await bot.say(msg)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8549 次 |
| 最近记录: |