Python 我的垃圾邮件命令没有';当消息中有空格时,无法工作

Python 我的垃圾邮件命令没有';当消息中有空格时,无法工作,python,discord.py,error-code,Python,Discord.py,Error Code,我的留言是(你好,世界!) 和命令(/spam Hello World) 和终端:(对不起,我不能复制粘贴它,因为我的终端不能复制这个) 我的代码: @commands.command(description="you want spam but you slow typing? use this command") async def spam(self, ctx, messages, amount : int): limit = 30 print(f'b

我的留言是(你好,世界!)

和命令(/spam Hello World)

和终端:(对不起,我不能复制粘贴它,因为我的终端不能复制这个)

我的代码:

    @commands.command(description="you want spam but you slow typing? use this command")
async def spam(self, ctx, messages, amount : int):
  limit = 30
  print(f'bot spam amount : "{amount}" msg : "{message}"')
  if amount > limit:
    await ctx.send('spam count exceeded the limit (30)')
    print('not spamming')
  else:
    print('spamming')
    for _ in range(amount):
      await ctx.send(message)

首先,您的参数变量是
messages
,但您正在打印
message
:它们必须是相同的名称。其次,如果您的命令在
消息
之前获取
金额
,则更为理想。您将如何运行它是
/spam 5 Hello World
,它将打印出
Hello World
5次。要打印出多个单词,只需将
*
用作将接受多个单词字符串的变量之前的参数。试试这个:

@commands.command(description=“您想要垃圾邮件,但键入速度慢?使用此命令”)
异步def垃圾邮件(self,ctx,amount:int,*,message):
上限=30
打印(f'bot垃圾邮件金额:{amount}消息:{message}')
如果金额>限额:
等待ctx.send('垃圾邮件计数超过限制(30)')
打印('非垃圾邮件')
其他:
打印(“垃圾邮件”)
范围内的uu(金额):
等待ctx发送(消息)

@Denta Dita为您做了这项工作?