async def avatar(self, ctx: Context, *, user: User = None): """Shows an user's avatar""" if not user: user = ctx.author embed = Embed(ctx, title=t(ctx, "title", user=user.name)) embed.set_image(url=user.avatar_url_as(size=2048)) await ctx.send(embed=embed)
async def action(self, ctx: Context): """Send an action gif Pressing the 🔁 reaction reloads the image for a new one. The option to refresh lasts 30 seconds and only you can use it. """ await ctx.trigger_typing() embed = Embed(ctx, footer="Via Tenor", color=ctx.author.color) embed.set_image( url=await get_gif(ctx.invoked_with, self.bot.config.tenor_key)) message = await ctx.send(embed=embed) if not ctx.channel.permissions_for(ctx.me).add_reactions: # Do not create the refresh loop if bot can't add reactions return refresh_emoji = "🔁" await message.add_reaction(refresh_emoji) def check(reaction, user): return user == ctx.message.author and str( reaction.emoji) == refresh_emoji while True: try: await self.bot.wait_for("reaction_add", timeout=30, check=check) embed.set_image(url=await get_gif(ctx.invoked_with, self.bot.config.tenor_key)) await message.edit(embed=embed) try: await message.remove_reaction(refresh_emoji, ctx.author) except Forbidden: # No manage_messages permission pass except TimeoutError: break try: await message.clear_reactions() except (Forbidden, NotFound): pass