【发布时间】:2021-03-25 12:29:35
【问题描述】:
我希望对 on_message 应用冷却时间。我已经从运行带有前言(例如 .claim 000)的命令转变为简单的 '000' 或 DM 上的任何代码。
旧代码:
@commands.command(name='claim',pass_context=True)
@commands.cooldown(1, 5, commands.BucketType.user)
async def redeem(self, ctx, code):
if isinstance(ctx.channel, discord.channel.DMChannel)
新代码:
@bot.event
@bot.cooldown(1, 5, commands.BucketType.user)
async def on_message(message):
但是,新的 .event 类型忽略了冷却谓词。有没有办法将其应用于它?
【问题讨论】: