【发布时间】:2019-12-29 13:26:46
【问题描述】:
这是写在discord.py。
我有多个类似于以下的命令:
@bot.command(name ="hi")
async def hi(ctx):
link = ["https://google.com", "https://youtube.com"]
chosen = random.choice(link)
url = chosen
embed = discord.Embed(title="Your Link", description=f"[Click Here]({url})", color=0x00ff00)
if ctx.message.guild == None:
await ctx.author.send('You can not use this command in your DM!')
pass
else:
await ctx.author.send(embed=embed)
如果有人使用其中一个命令,则应为所有命令设置冷却时间(例如,如果使用!hi,则!hi 和!bye 都将应用冷却时间。
我知道你可以使用@commands.cooldown(1, 600, commands.BucketType.user),但这只会对当前命令应用冷却时间。
【问题讨论】:
标签: python discord discord.py