def confirm(self, *, title: str, description: str, confirm_cancellation=False):
"""Confirms something."""
embed = discord.Embed(color=discord.Color.red(), title=title, description=description)
confirmation = await self.send(embed=embed)
for tick in (self.bot.tick(tick_type, raw=True, guild=self.guild) for tick_type in ('green', 'red')):
await confirmation.add_reaction(tick)
while True:
def check(reaction: discord.Reaction, adder: discord.User) -> bool:
return adder == self.message.author and reaction.message.id == confirmation.id
# wait for a reaction
reaction, adder = await self.bot.wait_for('reaction_add', check=check)
# ignore regular emoji
if isinstance(reaction.emoji, str):
continue
if reaction.emoji.id == 318595000311087105:
await confirmation.delete()
return True
elif reaction.emoji.id == 318595010385674240:
await confirmation.delete()
if confirm_cancellation:
await self.send('Operation cancelled.')
return False
评论列表
文章目录