【发布时间】:2021-09-02 02:27:33
【问题描述】:
Ex 某人在 100 秒内向某人发送了大量文本。我希望他们有 100 秒的冷却时间,因为他们发送了 100 条短信。我收到此错误:
@commands.cooldown(1,{time}, commands.BucketType.user)
^
IndentationError: expected an indented block
@client.command()
async def text(ctx, ip, port, time, method):
@commands.cooldown(1,f'{time}', commands.BucketType.user)
url = f'N/A'
response = requests.get(url)
embed = discord.Embed()
embed.title = 'Launched'
print(f'{ip}')
print(f'{port}')
print(f'{time}')
print(f'{method}')
embed.add_field(name = 'IP', value = ip, inline=False)
embed.add_field(name = 'PORT', value = port, inline=False)
embed.add_field(name = 'TIME', value = f'{time}', inline=False)
embed.add_field(name = 'METHOD', value = method, inline=False)
print(ctx.author, 'in', ctx.guild)
embed.set_author(name="Proll's Bot", icon_url=client.user.avatar_url)
await ctx.send(embed = embed)
【问题讨论】:
-
我是 python 新手,主要是 java 脚本中的代码
-
改变
async def和@commands.cooldown的位置 -
def之后,以下行需要缩进。在你的情况下,它不是。请阅读基本的 Python 语法。 -
就像我说的,如果你能修复代码并发送它,我是新手。会很棒的。
标签: python python-3.x timer discord discord.py