Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在discordpy中获取命令后的文本_Python_Discord - Fatal编程技术网

Python 如何在discordpy中获取命令后的文本

Python 如何在discordpy中获取命令后的文本,python,discord,Python,Discord,如何在discordpy中获取命令后的文本?例如“!say hello”如何获取hello?您可以将参数作为命令中的参数 @commands.command() 异步定义(ctx,*,参数): 等待ctx发送(args)#发送整个 #另一种方法 @commands.command() async def say_first(ctx,args): wait ctx.send(args)#只发送第一个单词 #另一种方法 @commands.command() 异步定义列表(ctx,*参数): wai

如何在discordpy中获取命令后的文本?例如“!say hello”如何获取hello?

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

@commands.command()
异步定义(ctx,*,参数):
等待ctx发送(args)#发送整个
#另一种方法
@commands.command()
async def say_first(ctx,args):
wait ctx.send(args)#只发送第一个单词
#另一种方法
@commands.command()
异步定义列表(ctx,*参数):
wait ctx.send(args)#将args作为列表发送
范例

!say hello there
> hello there
!say_first hello there
> hello
!say_list hello there
> ('hello', 'there')
参考资料:

在发布堆栈溢出之前,请做一些研究。请阅读以下内容以了解更多信息:)