Jac*_* W. 4 python discord discord.py
@client.command(pass_context = True)
async def getalt(ctx):
msg = ["gabrielwarren2000@gmail.com:Cyber123", "leandroriveros123@gmail.com:culillo123", "albesi8@msn.com:Albakortoci1", "dryden6@yahoo.ca:toysale22", "nichlas00100@gmail.com:nich918273645", "lodevanveen@gmail.com:Lodelode1", "kylefielding2011@gmail.com:emolover123", "rubbst3in@gmail.com:rube541632789mk", "jasonfryckman@ymail.com:fryckman22", "NickSaya1@hotmail.com:blackout541", "devinquan@yahoo.com:ploopy101"]
await client.send_message(ctx.message.author, random.choice(msg))
await client.send_message(ctx.message.channel, "Alt Has Been Seen To Your DMs")
await client.purge_from(ctx.message.channel, limit=2)
await client.send_message(ctx.message.author, "Please Wait 30 Seconds Before Using This Command Again.")
Run Code Online (Sandbox Code Playgroud)
我想为此命令设置 30 秒的冷却时间。
Sam*_*ett 24
你应该装饰你的命令
@commands.cooldown(1, 30, commands.BucketType.user)
Run Code Online (Sandbox Code Playgroud)
这将增加每位用户每 30 秒使用 1 次的速率限制。 文档,示例
您可以将 BucketType 更改为default,channel或者server改为创建全局、通道或服务器速率限制,但您只能对命令进行 1 次冷却。
Note: In discord.py rewrite (v1.0+) instead of BucketType.server, you have to use BucketType.guild.
This will also cause a CommandOnCooldown exception in on_command_error
| 归档时间: |
|
| 查看次数: |
29301 次 |
| 最近记录: |