예제 #1
0
    async def user_info(self,
                        ctx: Context,
                        user: Member = None,
                        hidden: bool = False) -> None:
        """Returns info about a user"""
        if user is None:
            user = ctx.author

        # Do a role check if this is being executed on someone other than the caller
        if user != ctx.author and not with_role_check(ctx, *MODERATION_ROLES):
            await ctx.send(
                "You may not use this command on users other than yourself.")
            return

        # Non-moderators may only do this in #bot and can't see hidden infractions.
        if not with_role_check(ctx, *STAFF_ROLES):
            if not ctx.channel.id == Channels.bot:
                raise InChannelCheckFailure(Channels.bot)

            # Hide hidden infractions for users without a moderation role
            hidden = False

        # User information
        created = time_since(user.created_at, max_units=3)

        name = str(user)
        if user.nick:
            name = f"{user.nick} ({name})"

        # Member information
        joined = time_since(user.joined_at, precision="days")

        roles = ", ".join(role.mention for role in user.roles
                          if role.name != "@everyone")

        # Infractions

        # Build the embed
        embed = Embed(title=name,
                      description=textwrap.dedent(f"""
                **User Information**
                Created: {created}
                Profile: {user.mention}
                ID: {user.id}

                **Member Information**
                Joined: {joined}
                Roles: {roles or None}
            """))

        embed.set_thumbnail(url=user.avatar_url_as(format="png"))
        embed.colour = user.top_role.colour if roles else Colour.blurple()

        await ctx.send(embed=embed)
예제 #2
0
    async def user_info(self, ctx: Context, user: Member = None) -> None:
        """Returns info about a user."""
        if user is None:
            user = ctx.author

        # Do a role check if this is being executed on someone other than the caller
        elif user != ctx.author and not with_role_check(ctx, *constants.MODERATION_ROLES):
            await ctx.send("You may not use this command on users other than yourself.")
            return

        # Non-staff may only do this in #bot-commands
        if not with_role_check(ctx, *constants.STAFF_ROLES):
            if not ctx.channel.id == constants.Channels.bot_commands:
                raise InChannelCheckFailure(constants.Channels.bot_commands)

        embed = await self.create_user_embed(ctx, user)

        await ctx.send(embed=embed)
예제 #3
0
    async def user_info(self,
                        ctx: Context,
                        user: Member = None,
                        hidden: bool = False):
        """
        Returns info about a user.
        """

        if user is None:
            user = ctx.author

        # Do a role check if this is being executed on someone other than the caller
        if user != ctx.author and not with_role_check(ctx, *MODERATION_ROLES):
            await ctx.send(
                "You may not use this command on users other than yourself.")
            return

        # Non-moderators may only do this in #bot-commands and can't see hidden infractions.
        if not with_role_check(ctx, *STAFF_ROLES):
            if not ctx.channel.id == Channels.bot:
                raise InChannelCheckFailure(Channels.bot)
            # Hide hidden infractions for users without a moderation role
            hidden = False

        # User information
        created = time_since(user.created_at, max_units=3)

        name = str(user)
        if user.nick:
            name = f"{user.nick} ({name})"

        # Member information
        joined = time_since(user.joined_at, precision="days")

        # You're welcome, Volcyyyyyyyyyyyyyyyy
        roles = ", ".join(role.mention for role in user.roles
                          if role.name != "@everyone")

        # Infractions
        infractions = await self.bot.api_client.get('bot/infractions',
                                                    params={
                                                        'hidden': str(hidden),
                                                        'user__id':
                                                        str(user.id)
                                                    })

        infr_total = 0
        infr_active = 0

        # At least it's readable.
        for infr in infractions:
            if infr["active"]:
                infr_active += 1

            infr_total += 1

        # Let's build the embed now
        embed = Embed(title=name,
                      description=textwrap.dedent(f"""
                **User Information**
                Created: {created}
                Profile: {user.mention}
                ID: {user.id}

                **Member Information**
                Joined: {joined}
                Roles: {roles or None}

                **Infractions**
                Total: {infr_total}
                Active: {infr_active}
            """))

        embed.set_thumbnail(url=user.avatar_url_as(format="png"))
        embed.colour = user.top_role.colour if roles else Colour.blurple()

        await ctx.send(embed=embed)