示例#1
0
    async def serverinfo(self, ctx):
        """ Overview about the information of a server """

        if not ctx.guild.chunked:
            await ctx.guild.chunk(cache=True)

        acks = default.server_badges(ctx, ctx.guild)
        ack = _("\n**Acknowledgements:** {0}").format(acks) if acks else ''
        unique_members = set(ctx.guild.members)
        unique_online = sum(1 for m in unique_members
                            if m.status is discord.Status.online
                            and not type(m.activity) == discord.Streaming)
        unique_offline = sum(1 for m in unique_members
                             if m.status is discord.Status.offline
                             and not type(m.activity) == discord.Streaming)
        unique_idle = sum(1 for m in unique_members
                          if m.status is discord.Status.idle
                          and not type(m.activity) == discord.Streaming)
        unique_dnd = sum(1 for m in unique_members
                         if m.status is discord.Status.dnd
                         and not type(m.activity) == discord.Streaming)
        unique_streaming = sum(1 for m in unique_members
                               if type(m.activity) == discord.Streaming)
        humann = sum(1 for member in ctx.guild.members if not member.bot)
        botts = sum(1 for member in ctx.guild.members if member.bot)
        num = 0
        for user in ctx.guild.members:
            if ctx.channel.permissions_for(user).kick_members or \
               ctx.channel.permissions_for(user).ban_members:
                if not user.bot:
                    num += 1
        bans = ''
        if ctx.channel.permissions_for(ctx.guild.me).ban_members:
            bans += _("\n**Banned:** {0}").format(
                f'{len(await ctx.guild.bans()):,}')
        nitromsg = _("This server has **{0}** boosts").format(
            ctx.guild.premium_subscription_count)
        nitromsg += _("\n{0}").format(default.next_level(ctx))
        region = default.region_flags(ctx)

        e = discord.Embed(color=self.bot.settings['colors']['embed_color'])
        e.set_author(name=_("{0} Information").format(ctx.guild.name),
                     icon_url=ctx.guild.icon_url)
        e.add_field(name=_('General Information:'),
                    value=_("""
**Name:** {0}
**ID:** {1}
**Guild created:** {2} ({3})
**Region:** {4}
**Verification level:** {5}

**Owner:** {6}
**Owner ID:** {7}{8}

**Nitro status:**
{9}
""").format(
                        ctx.guild.name, ctx.guild.id,
                        default.date(ctx.guild.created_at),
                        btime.human_timedelta(
                            ctx.guild.created_at.replace(tzinfo=None),
                            source=datetime.utcnow()), region,
                        str(ctx.guild.verification_level).capitalize(),
                        ctx.guild.owner or 'Unknown', ctx.guild.owner.id, ack,
                        nitromsg))

        members_info = (
            f"{self.bot.settings['emojis']['misc']['pc-online']} {unique_online:,}\n"
            f"{self.bot.settings['emojis']['misc']['pc-idle']} {unique_idle:,}\n"
            f"{self.bot.settings['emojis']['misc']['pc-dnd']} {unique_dnd:,}\n"
            f"{self.bot.settings['emojis']['misc']['offline']} {unique_offline:,}\n"
            f"{self.bot.settings['emojis']['misc']['streaming']} {unique_streaming:,}"
        )
        e.add_field(name=_('Other Information:'),
                    value=_("""**Members:** (Total: {0})
{1}
**Bots:** {2} | **Humans:** {3}
**Staff:** {4}{5}
**Channels:** {6} {7} | {8} {9}
""").format(f'{ctx.guild.member_count:,}', members_info, f'{botts:,}',
            f'{humann:,}', f'{num:,}', bans,
            self.bot.settings['emojis']['logs']['unlock'],
            f'{len(ctx.guild.text_channels):,}',
            self.bot.settings['emojis']['logs']['vcunlock'],
            f'{len(ctx.guild.voice_channels):,}'))
        info = []
        features = set(ctx.guild.features)
        all_features = {
            'PARTNERED': 'Partnered',
            'VERIFIED': 'Verified',
            'DISCOVERABLE': 'Server Discovery',
            'COMMUNITY': 'Community server',
            'INVITE_SPLASH': 'Invite Splash',
            'VIP_REGIONS': 'VIP Voice Servers',
            'VANITY_URL': 'Vanity Invite',
            'MORE_EMOJI': 'More Emoji',
            'COMMERCE': 'Commerce',
            'LURKABLE': 'Lurkable',
            'NEWS': 'News Channels',
            'ANIMATED_ICON': 'Animated Icon',
            'BANNER': 'Banner',
            'WELCOME_SCREEN_ENABLED': "Welcome screen"
        }
        for feature, label in all_features.items():
            if feature in features:
                info.append(label)

        if info:
            e.add_field(name=_("Features"),
                        value=', '.join(info),
                        inline=False)

        if not ctx.guild.is_icon_animated():
            e.set_thumbnail(url=ctx.guild.icon_url_as(format="png"))
        elif ctx.guild.is_icon_animated():
            e.set_thumbnail(url=ctx.guild.icon_url_as(format="gif"))
        if ctx.guild.banner:
            e.set_image(url=ctx.guild.banner_url_as(format="png"))
        await ctx.send(embed=e)
示例#2
0
    async def serverinfo(self, ctx):
        """ Overview about the information of a server """

            
        if ctx.guild.mfa_level == 0:
            mfa = "Disabled"
        else:
            mfa = "Enabled"

        tot_mem = 0
        for member in ctx.guild.members:
            tot_mem += 1

        unique_members = set(ctx.guild.members)
        unique_online = sum(1 for m in unique_members if m.status is discord.Status.online and not type(m.activity) == discord.Streaming)
        unique_offline = sum(1 for m in unique_members if m.status is discord.Status.offline and not type(m.activity) == discord.Streaming)
        unique_idle = sum(1 for m in unique_members if m.status is discord.Status.idle and not type(m.activity) == discord.Streaming)
        unique_dnd = sum(1 for m in unique_members if m.status is discord.Status.dnd and not type(m.activity) == discord.Streaming )
        unique_streaming = sum(1 for m in unique_members if type(m.activity) == discord.Streaming)
        humann = sum(1 for member in ctx.guild.members if not member.bot)
        botts = sum(1 for member in ctx.guild.members if member.bot)

        nitromsg = f"This server has **{ctx.guild.premium_subscription_count}** boosts"
        nitromsg += "\n{0}".format(default.next_level(ctx))

        ranks = []
        with open('db/badges.json', 'r') as f:
            data = json.load(f)

        try:
            ranks.append(' '.join(data["Servers"][f"{ctx.guild.id}"]["Badges"]))
        except KeyError:
            pass

        embed = discord.Embed(color=self.bot.embed_color)
        embed.set_author(icon_url=ctx.guild.icon_url,
                         name=f"Server Information")
        if ranks:
            embed.title = ' '.join(ranks)
        embed.add_field(name="__**General Information**__", value=f"**Guild name:** {ctx.guild.name}\n**Guild ID:** {ctx.guild.id}\n**Guild Owner:** {ctx.guild.owner}\n**Guild Owner ID:** {ctx.guild.owner.id}\n**Created at:** {default.date(ctx.guild.created_at)}\n**Region:** {str(ctx.guild.region).title()}\n**MFA:** {mfa}\n**Verification level:** {str(ctx.guild.verification_level).capitalize()}", inline=True)
        embed.add_field(name="__**Other**__", value=f"**Members:**\n{emotes.online_status} **{unique_online:,}**\n{emotes.idle_status} **{unique_idle:,}**\n{emotes.dnd_status} **{unique_dnd:,}**\n{emotes.streaming_status} **{unique_streaming:,}**\n{emotes.offline_status} **{unique_offline:,}**\n**Total:** {tot_mem:,} ({humann:,} Humans/{botts:,} Bots)\n**Channels:** {emotes.other_unlocked} {len(ctx.guild.text_channels)}/{emotes.other_vcunlock} {len(ctx.guild.voice_channels)}\n**Roles:** {len(ctx.guild.roles)}", inline=True)
        embed.add_field(name='__**Server boost status**__',
                        value=nitromsg, inline=False)
        info = []
        features = set(ctx.guild.features)
        all_features = {
            'PARTNERED': 'Partnered',
            'VERIFIED': 'Verified',
            'DISCOVERABLE': 'Server Discovery',
            'COMMUNITY': 'Community server',
            'INVITE_SPLASH': 'Invite Splash',
            'VIP_REGIONS': 'VIP Voice Servers',
            'VANITY_URL': 'Vanity Invite',
            'MORE_EMOJI': 'More Emoji',
            'COMMERCE': 'Commerce',
            'LURKABLE': 'Lurkable',
            'NEWS': 'News Channels',
            'ANIMATED_ICON': 'Animated Icon',
            'BANNER': 'Banner',
            'WELCOME_SCREEN_ENABLED': "Welcome screen"
        }

        for feature, label in all_features.items():
            if feature in features:
                info.append(label)

        if info:
            embed.add_field(name="__**Features**__", value=', '.join(info))
        if ctx.guild.icon:
            embed.set_thumbnail(url=ctx.guild.icon_url_as(format="png"))
        if ctx.guild.banner:
            embed.set_image(url=ctx.guild.banner_url_as(format="png"))

        embed.set_footer(
            text=f'© {self.bot.user}')

        await ctx.send(embed=embed)