如何获得命令后的文本不一致?



如何获得命令后的文本不一致?例如"!说hello"我该怎么打招呼?

您可以将该参数作为命令中的参数。

@commands.command()
async def say(ctx, *, args):
await ctx.send(args) #sends entire
#another method
@commands.command()
async def say_first(ctx, args):
await ctx.send(args) #sends only the first word
#another method
@commands.command()
async def say_list(ctx, *args):
await ctx.send(args) #sends args as a list

例子
!say hello there
> hello there
!say_first hello there
> hello
!say_list hello there
> ('hello', 'there')

引用:

  • command_arguments
  • <
  • 命令/gh>

最新更新