示例#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 dev_inspect_server(self, ctx, server: int):
        guild = self.bot.get_guild(server)
        if guild is None:
            return await ctx.send(
                f"{self.bot.settings['emojis']['misc']['warn']} | That server doesn't seem to exist. Are you sure the server ID is correct?"
            )
        if not guild.chunked:
            await guild.chunk(cache=True)

        acks = default.server_badges(ctx, guild)
        logging = default.server_logs(ctx, guild)
        people = len([x for x in guild.members if not x.bot])
        bots = len([x for x in guild.members if x.bot])
        botfarm = int(100 / len(guild.members) * bots)
        sperms = dict(guild.me.guild_permissions)
        bl = CM.get(self.bot, 'blacklist', guild.id)
        sug_check = '\n\n*Blocked from suggesting suggestions*' if bl and bl[
            'type'] == 0 else ''
        past = await self.bot.db.fetch(
            "SELECT * FROM bot_history WHERE _id = $1", guild.id)
        prefix = CM.get(self.bot, 'prefix', guild.id)
        muterole = await default.get_muterole(ctx, guild)
        language = self.bot.cache.get(self.bot, 'translations', guild.id)
        mod_role = self.bot.cache.get(self.bot, 'mod_role', guild.id)
        admin_role = self.bot.cache.get(self.bot, 'admin_role', guild.id)
        guild_owner = await self.bot.fetch_user(guild.owner_id)
        perm = []
        invites = ''
        try:
            guildinv = await guild.invites()
            for inv in guildinv[:1]:
                invites += f'{inv}'
        except Exception:
            pass
        name = f'[{guild.name}]({invites})' if invites else f"{guild.name}"

        for p in sperms.keys():
            if sperms[
                    p] is True and guild.me.guild_permissions.administrator is False:
                perm.append(f"`{p.replace('_', ' ').title()}`")
        if guild.me.guild_permissions.administrator:
            perm.append('Administrator')

        e = discord.Embed()
        if botfarm > 75 and guild.member_count > 100:
            e.color = self.bot.settings['colors']['deny_color']
            e.title = f"{self.bot.settings['emojis']['misc']['warn']} This server is a possible bot farm. Make sure they aren't abusing the bot."
        else:
            e.color = self.bot.settings['colors']['embed_color']
        e.add_field(name='Important information:',
                    value=f"""
**Server name:** {name} {acks if acks else ''}
**Server ID:** {guild.id}
**Total Members:** {len(guild.members):,} which {people:,} of them are humans and {bots:,} bots. `[Ratio: {botfarm}%]`
**Server Owner:** {guild_owner} ({guild_owner.id})""",
                    inline=False)
        e.add_field(name='Other information:',
                    value=f"""
**Total channels/roles:** {len(guild.channels)} channels / {len(guild.roles)} roles
**Server created at:** {default.date(guild.created_at)}
**Joined server at:** {btime.human_timedelta(guild.get_member(self.bot.user.id).joined_at.replace(tzinfo=None), source=datetime.utcnow())} ({default.date(guild.get_member(self.bot.user.id).joined_at)})
**Prefix:** {escape_markdown(prefix)}
**Language:** {language}
**Mute role:** {f"{muterole.id}" if muterole else 'Not found'}
**Mod & Admin Roles:** {mod_role}; {admin_role}""",
                    inline=False)
        e.add_field(name="My permissions:", value=", ".join(perm))
        e.add_field(name='Logging:', value=logging)
        if past:
            msg = []
            for num, res in enumerate(past, start=1):
                dev = self.bot.get_user(res['dev'])
                msg.append(
                    f"`[{num}]` {escape_markdown(str(guild), as_needed=False)} - {'Liftable' if res['liftable'] == 0 else 'Not liftable'}\nIssued by **{dev}** {btime.human_timedelta(res['issued'])}\n**Reason:** {res['reason']}\n"
                )
            e.add_field(name='Previous blacklists:',
                        value=f"{sug_check}\n" + ''.join(msg),
                        inline=False)
        e.set_thumbnail(url=guild.icon_url)
        await ctx.send(embed=e)