async def einfo(self, ctx, *, emoji: Union[discord.Emoji, discord.PartialEmoji] = None): """Get info about emoji""" if emoji is None: if ctx.channel.permissions_for(ctx.author).add_reactions: m = await ctx.send(_("React to this message with your emoji")) try: reaction = await ctx.bot.wait_for( "reaction_add", check=ReactionPredicate.same_context(message=m, user=ctx.author), timeout=30, ) emoji = reaction[0].emoji except AsyncTimeoutError: return finally: await m.delete(delay=0) else: await ctx.send_help() return em = await self.emoji_embed(ctx, emoji) await ctx.send(embed=em)
async def icon_emoji(self, ctx, *, emoji: Union[discord.Emoji, discord.PartialEmoji] = None): """Change icon of personal role using emoji""" role = await self.config.member(ctx.author).role() role = ctx.guild.get_role(role) if not emoji: if ctx.channel.permissions_for(ctx.author).add_reactions: m = await ctx.send(_("React to this message with your emoji")) try: reaction = await ctx.bot.wait_for( "reaction_add", check=ReactionPredicate.same_context(message=m, user=ctx.author), timeout=30, ) emoji = reaction[0].emoji except AsyncTimeoutError: return finally: await m.delete(delay=0) else: await ctx.send_help() return try: if isinstance(emoji, (discord.Emoji, discord.PartialEmoji)): await edit_role_icon( self.bot, role, icon=await emoji.url_as(format="png").read(), reason=get_audit_reason(ctx.author, _("Personal Role")), ) else: await edit_role_icon( self.bot, role, unicode_emoji=emoji, reason=get_audit_reason(ctx.author, _("Personal Role")), ) except discord.Forbidden: ctx.command.reset_cooldown(ctx) await ctx.send( chat.error( _("Unable to edit role.\nRole must be lower than my top role" ))) except discord.InvalidArgument: await ctx.send( chat.error( _("This image type is unsupported, or link is incorrect"))) except discord.HTTPException as e: ctx.command.reset_cooldown(ctx) await ctx.send(chat.error(_("Unable to edit role: {}").format(e))) else: await ctx.send( _("Changed icon of {user}'s personal role").format( user=ctx.message.author.name))