Beispiel #1
0
 async def emojiinfo_command(self, ctx, target: t.Union[discord.Emoji,
                                                        str]):
     if isinstance(target, discord.Emoji):
         target = await ctx.guild.fetch_emoji(target.id)
         await ctx.send(embed=self.bot.embed.build(
             ctx=ctx,
             header="Information",
             title=f"Emoji information for {target.name}",
             thumbnail=target.url,
             fields=(
                 ("ID", target.id, False),
                 ("Animated?", target.animated, True),
                 ("Managed?", target.managed, True),
                 ("Available?", target.available, True),
                 (
                     "Created by",
                     u.mention if (u := target.user) and ctx.guild.me.
                     guild_permissions.manage_emojis else "-",
                     True,
                 ),
                 ("Created on", chron.long_date(target.created_at), True),
                 ("Existed for",
                  chron.short_delta(dt.datetime.utcnow() -
                                    target.created_at), True),
             ),
         ))
Beispiel #2
0
    async def serverinfo_command(self, ctx):
        bot_count = len([m for m in ctx.guild.members if m.bot])
        human_count = ctx.guild.member_count - bot_count

        await ctx.send(embed=self.bot.embed.build(
            ctx=ctx,
            header="Information",
            title=f"Server information for {ctx.guild.name}",
            thumbnail=ctx.guild.icon_url,
            colour=ctx.guild.owner.colour,
            fields=(
                ("ID", ctx.guild.id, False),
                ("Owner", ctx.guild.owner.mention, True),
                ("Region", ctx.guild.region, True),
                ("Top role", ctx.guild.roles[-1].mention, True),
                ("Members", f"{ctx.guild.member_count:,}", True),
                ("Humans / bots", f"{human_count:,} / {bot_count:,}", True),
                (
                    "Bans",
                    f"{len(await ctx.guild.bans()):,}" if ctx.guild.me.
                    guild_permissions.ban_members else "-",
                    True,
                ),
                ("Roles", f"{len(ctx.guild.roles)-1:,}", True),
                ("Text channels", f"{len(ctx.guild.text_channels):,}", True),
                ("Voice channels", f"{len(ctx.guild.voice_channels):,}", True),
                (
                    "Invites",
                    f"{len(await ctx.guild.invites()):,}" if ctx.guild.me.
                    guild_permissions.manage_guild else "-",
                    True,
                ),
                ("Emojis",
                 f"{len(ctx.guild.emojis):,} / {ctx.guild.emoji_limit*2:,}",
                 True),
                ("Boosts",
                 f"{ctx.guild.premium_subscription_count:,} (level {ctx.guild.premium_tier})",
                 True),
                ("Newest member",
                 max(ctx.guild.members, key=lambda m: m.joined_at).mention,
                 True),
                ("Created on", chron.long_date(ctx.guild.created_at), True),
                ("Existed for",
                 chron.short_delta(dt.datetime.utcnow() -
                                   ctx.guild.created_at), True),
                (
                    "Statuses",
                    (f"🟢 {len([m for m in ctx.guild.members if m.status == discord.Status.online]):,} "
                     f"🟠 {len([m for m in ctx.guild.members if m.status == discord.Status.idle]):,} "
                     f"🔴 {len([m for m in ctx.guild.members if m.status == discord.Status.dnd]):,} "
                     f"⚪ {len([m for m in ctx.guild.members if m.status == discord.Status.offline]):,}"
                     ),
                    False,
                ),
            ),
        ))
Beispiel #3
0
    async def messageinfo_command(self, ctx, target: t.Union[discord.Message,
                                                             str]):
        if isinstance(target, discord.Message):
            await ctx.send(embed=self.bot.embed.build(
                ctx=ctx,
                header="Information",
                title=f"Message information",
                description=
                f"You can see the original message [here]({target.jump_url}).",
                thumbnail=target.author.avatar_url,
                colour=target.author.colour,
                fields=(
                    ("ID", target.id, False),
                    ("System?", target.is_system(), True),
                    ("Embedded?", bool(target.embeds), True),
                    ("Pinned?", target.pinned, True),
                    ("Author", target.author.mention, True),
                    ("Channel", target.channel.mention, True),
                    ("Reactions", f"{len(target.reactions):,}", True),
                    ("Member mentions", f"{len(target.mentions):,}", True),
                    ("Role mentions", f"{len(target.role_mentions):,}", True),
                    ("Attachments", f"{len(target.attachments):,}", True),
                    ("Created on", chron.long_date(target.created_at), True),
                    ("Existed for",
                     chron.short_delta(dt.datetime.utcnow() -
                                       target.created_at), True),
                    ("Last edited on", chron.long_date(target.created_at),
                     True),
                    (
                        "Content",
                        (target.content if len(target.content) <= 1024 else
                         f"{target.content[:1021]}...") or "-",
                        False,
                    ),
                ),
            ))

        else:
            await ctx.send(
                f"{self.bot.cross} Solaris was unable to identify a message with the information provided."
            )
Beispiel #4
0
    async def roleinfo_command(self, ctx, *,
                               target: t.Optional[t.Union[discord.Role, str]]):
        target = target or ctx.author.top_role

        if isinstance(target, discord.Role):
            ngr = len(ctx.guild.roles)

            await ctx.send(embed=self.bot.embed.build(
                ctx=ctx,
                header="Information",
                title=f"Role information for {target.name}",
                description=
                f"You currently{' ' if target in ctx.author.roles else ' do not '}have this role.",
                thumbnail=ctx.guild.icon_url,
                colour=target.colour,
                fields=(
                    ("ID", target.id, False),
                    ("Hoisted?", target.hoist, True),
                    ("Assignable?", not target.managed, True),
                    ("Mentionable?", target.mentionable, True),
                    ("Admin?", target.permissions.administrator, True),
                    ("Position",
                     f"{string.ordinal(ngr - target.position)} / {ngr:,}",
                     True),
                    ("Colour", f"{str(target.colour)}", True),
                    ("Members", f"{len(target.members):,}", True),
                    ("Created on", chron.long_date(target.created_at), True),
                    ("Existed for",
                     chron.short_delta(dt.datetime.utcnow() -
                                       target.created_at), True),
                ),
            ))

        else:
            await ctx.send(
                f"{self.bot.cross} Solaris was unable to identify a role with the information provided."
            )
Beispiel #5
0
    async def channelinfo_command(
        self,
        ctx,
        *,
        target: t.Optional[t.Union[discord.TextChannel, discord.VoiceChannel,
                                   discord.CategoryChannel, str]],
    ):
        target = target or ctx.channel

        if isinstance(target, discord.TextChannel):
            await ctx.send(embed=self.bot.embed.build(
                ctx=ctx,
                header="Information",
                title=f"Channel information for {target.name}",
                description="This channel is a text channel.",
                thumbnail=ctx.guild.icon_url,
                fields=(
                    ("ID", target.id, False),
                    ("NSFW?", target.is_nsfw(), True),
                    ("News?", target.is_news(), True),
                    ("Synced?", target.permissions_synced, True),
                    ("Category", target.category.name, True),
                    ("Position",
                     f"{string.ordinal(target.position+1)} / {len(ctx.guild.text_channels):,}",
                     True),
                    ("Allowed members", f"{len(target.members):,}", True),
                    ("Overwrites", f"{len(target.overwrites)}", True),
                    (
                        "Invites",
                        f"{len(await target.invites()):,}" if ctx.guild.me.
                        guild_permissions.manage_guild else "-",
                        True,
                    ),
                    ("Pins", f"{len(await target.pins())}", True),
                    ("Slowmode delay", f"{target.slowmode_delay:,} second(s)",
                     True),
                    ("Created on", chron.long_date(target.created_at), True),
                    ("Existed for",
                     chron.short_delta(dt.datetime.utcnow() -
                                       target.created_at), True),
                    ("Topic", target.topic or "-", False),
                ),
            ))

        elif isinstance(target, discord.VoiceChannel):
            await ctx.send(embed=self.bot.embed.build(
                ctx=ctx,
                header="Information",
                title=f"Channel information for {target.name}",
                description="This channel is a voice channel.",
                thumbnail=ctx.guild.icon_url,
                fields=(
                    ("ID", target.id, False),
                    ("Synced?", target.permissions_synced, True),
                    ("Category", target.category.name, True),
                    ("Bitrate", f"{target.bitrate//1000:,.0f} kbps", True),
                    ("Position",
                     f"{string.ordinal(target.position+1)} / {len(ctx.guild.voice_channels):,}",
                     True),
                    ("Overwrites", f"{len(target.overwrites)}", True),
                    (
                        "Invites",
                        f"{len(await target.invites()):,}" if ctx.guild.me.
                        guild_permissions.manage_guild else "-",
                        True,
                    ),
                    ("Members joined",
                     f"{len(target.members):,} / {target.user_limit or '∞'}",
                     True),
                    ("Created on", chron.long_date(target.created_at), True),
                    ("Existed for",
                     chron.short_delta(dt.datetime.utcnow() -
                                       target.created_at), True),
                ),
            ))

        elif isinstance(target, discord.CategoryChannel):
            await ctx.send(embed=self.bot.embed.build(
                ctx=ctx,
                header="Information",
                title=f"Category information for {target.name}",
                thumbnail=ctx.guild.icon_url,
                fields=(
                    ("ID", target.id, False),
                    ("NSFW?", target.is_nsfw(), True),
                    ("Synced?", target.permissions_synced, True),
                    ("Position",
                     f"{string.ordinal(target.position+1)} / {len(ctx.guild.categories):,}",
                     True),
                    ("Channels",
                     f"{len(target.channels):,} / {len(ctx.guild.channels):,}",
                     True),
                    ("Text / voice",
                     f"{len(target.text_channels):,} / {len(target.voice_channels):,}",
                     True),
                    ("Synced channels",
                     f"{len([c for c in target.channels if c.permissions_synced])}",
                     True),
                    ("Overwrites", f"{len(target.overwrites)}", True),
                    ("Created on", chron.long_date(target.created_at), True),
                    ("Existed for",
                     chron.short_delta(dt.datetime.utcnow() -
                                       target.created_at), True),
                ),
            ))

        else:
            await ctx.send(
                f"{self.bot.cross} Solaris was unable to identify a channel with the information provided."
            )
Beispiel #6
0
    async def userinfo_command(
        self, ctx, *,
        target: t.Optional[t.Union[discord.Member, converters.User,
                                   converters.SearchedMember, str]]):
        target = target or ctx.author

        if isinstance(target, discord.Member):
            ps = target.premium_since
            ngr = len(target.guild.roles)

            await ctx.send(embed=self.bot.embed.build(
                ctx=ctx,
                header="Information",
                title=f"User information for {target.name}",
                description=
                (f"This member is also known as {target.display_name} in this server."
                 if target.nick else
                 f"This member does not have a nickname in this server."),
                colour=target.colour,
                thumbnail=target.avatar_url,
                fields=(
                    ("ID", target.id, False),
                    ("Discriminator", target.discriminator, True),
                    ("Bot?", target.bot, True),
                    ("Admin?", target.guild_permissions.administrator, True),
                    ("Created on", chron.long_date(target.created_at), True),
                    ("Joined on", chron.long_date(target.joined_at), True),
                    ("Boosted on", chron.long_date(ps) if ps else "-", True),
                    ("Existed for",
                     chron.short_delta(dt.datetime.utcnow() -
                                       target.created_at), True),
                    ("Member for",
                     chron.short_delta(dt.datetime.utcnow() -
                                       target.joined_at), True),
                    ("Booster for", chron.short_delta(dt.datetime.utcnow() -
                                                      ps) if ps else "-",
                     True),
                    ("Status", str(target.status).title(), True),
                    (
                        "Activity type",
                        str(target.activity.type).title().
                        split(".")[-1] if target.activity is not None else "-",
                        True,
                    ),
                    ("Activity name",
                     target.activity.name if target.activity else "-", True),
                    ("Nº of roles", f"{len(target.roles)-1:,}", True),
                    ("Top role", target.top_role.mention, True),
                    ("Top role position",
                     f"{string.ordinal(ngr - target.top_role.position)} / {ngr:,}",
                     True),
                ),
            ))

        elif isinstance(target, discord.User):
            await ctx.send(embed=self.bot.embed.build(
                ctx=ctx,
                header="Information",
                title=f"User information for {target.name}",
                description=
                "Showing reduced information as the given user is not in this server.",
                thumbnail=target.avatar_url,
                fields=(
                    ("ID", target.id, True),
                    ("Discriminator", target.discriminator, True),
                    ("Bot?", target.bot, True),
                    ("Created on", chron.long_date(target.created_at), True),
                    ("Existed for",
                     chron.short_delta(dt.datetime.utcnow() -
                                       target.created_at), True),
                    ("\u200b", "\u200b", True),
                ),
            ))

        else:
            await ctx.send(
                f"{self.bot.cross} Solaris was unable to identify a user with the information provided."
            )