如何重置命令的冷却时间 discord.py

How to reset cooldown of a command discord.py

如果对 ❌ 做出反应,我正在尝试重置冷却时间。我试过了 _set.reset_cooldown(self, ctx)commands.Command.reset_cooldown 但它们没有用。难道我做错了什么?有人可以帮助我吗?


    @prefix.command(aliases=["set"])
    @commands.has_permissions(manage_messages=True)
    @commands.cooldown(1, 20, commands.BucketType.guild)
    async def _set(self, ctx, prefix):
        embed = discord.Embed(
            title="Prefix Change",
            description=f"Are you sure you want to change the prefix for Umbra to `{prefix}` in {ctx.guild}?",
            colour=ctx.author.color
            )
        message = await ctx.send(embed=embed)

        await message.add_reaction("✅")
        await message.add_reaction("❌")

        def check(reaction, user):
            if reaction.message.id == message.id:
                return user == ctx.author and str(reaction.emoji) in ["✅", "❌"]
            else:
                return

        while True:
            try:
                reaction, user = await self.bot.wait_for("reaction_add", timeout=180, check=check)

                if str(reaction.emoji) == "✅":
                    client.query(
                        q.update(
                            q.select(['ref'], q.get(
                                q.match(
                                    q.index("prefixByGuildID"), f"{ctx.guild.id}"
                                    )
                                )
                            ), {"data": {"guildID": f"{ctx.guild.id}", "prefix": f"{prefix}"}}
                        )
                    )
                    conftrue = discord.Embed(
                        title="Prefix Change",
                        description=f"Prefix changed to `{prefix}` successfully!",
                        colour=0x55ff55
                    )
                    await message.edit(embed=conftrue)
                    await message.clear_reactions()

                elif str(reaction.emoji) == "❌":
                    conffalse = discord.Embed(
                        title="Prefix Change",
                        description=f"Prefix change cancelled.",
                        colour=0xff5555
                    )
                    await message.edit(embed=conffalse)
                    await message.clear_reactions()
                        
                else:
                    await message.remove_reaction(reaction, user)

            except asyncio.TimeoutError:
                break

另外是的,我正在使用我自己的确认系统,请不要让我使用现有的库,我喜欢它的方式。

你可以简单地做

ctx.command.reset_cooldown(ctx)

Context

外,您没有传递任何其他参数