I am trying to reset the cooldown if reacted with ?. I tried _set.reset_cooldown(self, ctx)
and commands.Command.reset_cooldown
but they didn't work. Am I doing something wrong? Can someone help me?
@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
Also yes I am using my own confirmation system, please don't ask me to use an existing library, I like the way it is.
question from:
https://stackoverflow.com/questions/65925043/how-to-reset-cooldown-of-a-command-discord-py 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…