【发布时间】:2022-01-18 20:42:48
【问题描述】:
事实上,我想用参数:“async def say(ctx, repeat, *phrase) 重复定义的次数,但实际上我想在命令中只指定句子时,通过默认重复次数为 1 并给出: async def say(ctx, repeat = 1, *phrase) 问题是当输入不和谐的命令时,例如:“!say Hello my name is Leo” 它需要 Hello作为重复参数,我真的不知道我是否清楚????
我想让不和谐在“!say hi how are u?”中理解这一点。重复默认为 1,Hi 对应于参数“sentence”,另一方面,在“!say 5 Hi how are u?”中对应。有 5 对应于重复。不知道有没有可能。。
感谢您的回答!
【问题讨论】:
-
只需检查
try: int(args[0]),如果通过则sentence = " ".join(args[1:])和rep = int(args[0])否则请检查rep = 1和sentence = " ".join(args)。
标签: python discord.py