我正在制作discord.py命令,该命令将接受用户输入的特定消息并重复所述消息。到目前为止,这是我的代码:
async def repeat(ctx, words = None):
if words == None:
reason = 'you didn\'t say anything dummy'
await ctx.send(f'{words}')
但是,当我去实际测试命令时,该自动程序仅将我的消息的一个单词发送回去。例如,如果我说“ do repeat ab c”,则仅发送“ a”。我将如何让机器人听完我说的所有话?
您可以使用仅关键字的参数:
async def repeat(ctx, *, words):
这将自动将所有args放在单个字符串中。
请参阅:https : //discordpy.readthedocs.io/en/latest/ext/commands/commands.html#keyword-only-arguments
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句