如果对 ❌ 有反应,我正在尝试重置冷却时间。我试过_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
也是的,我正在使用自己的确认系统,请不要让我使用现有的图书馆,我喜欢它的方式。
答案 0 :(得分:0)
你可以简单地做
ctx.command.reset_cooldown(ctx)
除了 Context