Ejemplo n.º 1
0
def createEmbed(*,
                title: str = '',
                description: str = '',
                colour=None,
                author: discord.Member = None,
                guild: discord.Guild = None):
    if colour == 'iron':
        colour = 0xffd700
    elif colour == 'rogue':
        colour = 0x7d0a00
    elif colour == 'error':
        colour = 0xff0000
    embed = discord.Embed(title=title,
                          description=description,
                          timestamp=datetime.utcnow())
    if colour:
        embed = discord.Embed(title=title,
                              description=description,
                              timestamp=datetime.utcnow(),
                              colour=colour)
    if author:
        embed.set_author(name=author, icon_url=author.avatar_url)
    if guild:
        embed.set_footer(text=guild.name,
                         icon_url=guild.icon_url_as(format='png', size=128))
        embed.set_thumbnail(url=guild.icon_url_as(format='png', size=512))

    return embed
Ejemplo n.º 2
0
    async def icon(self, ctx: Context, *, guild: Guild = None) -> None:
        """
        Displays a servers icon.
        `guild`: The server of which to get the icon for. Can be it's ID or Name. Defaults to the current server.
        """

        if not guild:
            guild = ctx.guild

        if not guild.icon:
            await ctx.send(
                description=f'The server `{guild}` does not have an icon.',
                color=Color.red())
            return

        embed = Embed(title=f"{guild.name}'s icon",
                      description=f'''
            [PNG]({guild.icon_url_as(format="png")})
            [JPEG]({guild.icon_url_as(format="jpeg")})
            [WEBP]({guild.icon_url_as(format="webp")})
            ''',
                      color=Color.blue())
        embed.set_image(url=str(guild.icon_url_as(format='png')))

        if guild.is_icon_animated():
            embed.description += f'\n[GIF]({guild.icon_url_as(format="gif")})'
            embed.set_image(
                url=str(guild.icon_url_as(size=1024, format='gif')))

        await ctx.send(embed=embed)
Ejemplo n.º 3
0
    async def on_guild_remove(self, guild: discord.Guild) -> None:

        log.info(
            f'Left a guild. Name: {guild.name} | ID: {guild.id} | Owner: {guild.owner} | Members: {len(guild.members)}'
        )

        time = self.bot.utils.format_datetime(datetime=pendulum.now(tz='UTC'))
        embed = discord.Embed(
            colour=discord.Colour.gold(),
            title=f'Left a guild',
            description=
            f'`Name:` {guild.name}\n`ID:` {guild.id}\n`Owner:` {guild.owner}\n`Time:` {time}\n`Members:` {len(guild.members)}'
        )
        embed.set_thumbnail(url=str(
            guild.icon_url_as(
                format='gif' if guild.is_icon_animated() else 'png')))
        await self.bot.logging_webhook.send(
            embed=embed, avatar_url=guild.icon_url_as(format='png'))
Ejemplo n.º 4
0
 async def on_guild_remove(self, guild: discord.Guild):
     leave = discord.Embed(title='{}The Kraken Scared Us Away! {}'.format(
         self.sad, self.sad),
                           timestamp=datetime.datetime.utcnow(),
                           color=0x00ff00)
     leave.set_footer(text='{}'.format(guild.id))
     leave.add_field(name=f'**Server Owner**',
                     value='{} User ID: {}'.format(guild.owner,
                                                   guild.owner_id))
     leave.set_image(url='{}'.format(guild.icon_url_as(format='png')))
     await self.oceans.send(embed=leave)
Ejemplo n.º 5
0
    async def on_guild_join(self, guild: discord.Guild) -> None:

        self.bot.log.info(
            f'Joined a guild. Name: {guild.name} | ID: {guild.id} | Owner: {guild.owner} | Members: {len(guild.members)}'
        )

        time = self.bot.utils.format_datetime(datetime=datetime.now(pytz.UTC))
        embed = discord.Embed(
            colour=discord.Colour.gold(),
            title=f'Joined a guild',
            description=
            f'`Name:` {guild.name}\n`ID:` {guild.id}\n`Owner:` {guild.owner}\n`Time:` {time}\n`Members:` {len(guild.members)}'
        )
        embed.set_thumbnail(url=str(
            guild.icon_url_as(
                format='gif' if guild.is_icon_animated() else 'png')))
        await self.bot.logging_webhook.send(
            embed=embed, avatar_url=guild.icon_url_as(format='png'))

        if guild.id in self.bot.guild_blacklist.keys():
            await guild.leave()
Ejemplo n.º 6
0
    async def on_guild_update(self, before: discord.Guild,
                              after: discord.Guild) -> None:
        """Log guild update event to mod log."""
        if before.id != GuildConstant.id:
            return

        diff = DeepDiff(before, after)
        changes = []
        done = []

        diff_values = diff.get("values_changed", {})
        diff_values.update(diff.get("type_changes", {}))

        for key, value in diff_values.items():
            if not key:  # Not sure why, but it happens
                continue

            key = key[5:]  # Remove "root." prefix

            if "[" in key:
                key = key.split("[", 1)[0]

            if "." in key:
                key = key.split(".", 1)[0]

            if key in done:
                continue

            new = value["new_value"]
            old = value["old_value"]

            changes.append(f"**{key.title()}:** `{old}` **→** `{new}`")

            done.append(key)

        if not changes:
            return

        message = ""

        for item in sorted(changes):
            message += f"{Emojis.bullet} {item}\n"

        message = f"**{after.name}** (`{after.id}`)\n{message}"

        await self.send_log_message(Icons.guild_update,
                                    Colour.blurple(),
                                    "Guild updated",
                                    message,
                                    thumbnail=after.icon_url_as(format="png"))
Ejemplo n.º 7
0
    async def on_guild_remove(self, guild: discord.Guild):

        if self.bot.log_channel:

            embed = discord.Embed(colour=discord.Colour.gold())
            embed.set_thumbnail(url=str(
                guild.icon_url_as(
                    format='gif' if guild.is_icon_animated() is True else 'png'
                )))
            embed.title = f'Left a {"blacklisted " if guild.id in self.bot.guild_blacklist.keys() else ""}guild'
            embed.description = f'`Name:` {guild.name}\n`ID:` {guild.id}\n`Owner:` {guild.owner}'
            await self.bot.log_channel.send(embed=embed)

        self.bot.log.info(
            f'Left a guild. Name: {guild.name} | ID: {guild.id} | Owner: {guild.owner}'
        )
Ejemplo n.º 8
0
    async def server_info(self, ctx, g: discord.Guild = None):
        async with ctx.typing():
            await asyncio.sleep(1)
            g = ctx.guild if g is None else g

            embed = discord.Embed(color=discord.Color.orange())

            embed.set_author(name=g.name, icon_url=g.icon_url_as(format="png"))

            embed.add_field(name="Owner", value=self.bot.get_user(g.owner_id).display_name)
            embed.add_field(name="Members", value=g.member_count)

            embed.add_field(name="Roles", value=len(g.roles))
            embed.add_field(name="Channels", value=len(g.channels))
            embed.add_field(name="Emojis", value=len(g.emojis))

            await ctx.send(embed=embed)
Ejemplo n.º 9
0
 async def on_guild_join(self, guild: discord.Guild):
     join = discord.Embed(title="{} I Explored a New Ocean! {}".format(
         self.happy, self.happy),
                          timestamp=datetime.datetime.utcnow(),
                          color=0x03f0fc)
     join.set_footer(text='Server ID: {}'.format(guild.id))
     join.add_field(name=f'**Server Name**', value='{}'.format(guild.name))
     join.add_field(name=f'**Server Owner**',
                    value='{} User ID: {}'.format(guild.owner,
                                                  guild.owner_id))
     join.add_field(name=f'**Server Region**',
                    value='{}'.format(guild.region))
     join.set_image(url='{}'.format(guild.icon_url_as(format='png')))
     await self.oceans.send(embed=join)
     await guild.system_channel.send(
         f'Thanks for inviting me to your server! Remember that this bot is currently in a ALPHA Phase. If ever in doubt for anything please use \'-support\' to get a invite to my support server! Anyways Have fun and enjoy having MultiSquid around!'
     )
Ejemplo n.º 10
0
    async def server_info(self, ctx, g: discord.Guild = None):
        g = ctx.guild if g is None else g

        embed = discord.Embed(color=discord.Color.green())

        embed.set_author(name=g.name, icon_url=g.icon_url_as(format="png"))

        embed.add_field(name="Owner",
                        value=self.bot.get_user(g.owner_id).display_name)
        embed.add_field(name="Difficulty",
                        value=await self.db.get_difficulty(g.id))
        embed.add_field(name="Members", value=g.member_count)

        embed.add_field(name="Roles", value=len(g.roles))
        embed.add_field(name="Channels", value=len(g.channels))
        embed.add_field(name="Emojis", value=len(g.emojis))

        await ctx.send(embed=embed)
Ejemplo n.º 11
0
    async def on_guild_join(self, guild: discord.Guild):

        if self.bot.log_channel:

            embed = discord.Embed(colour=discord.Colour.gold())
            embed.set_thumbnail(url=str(
                guild.icon_url_as(
                    format='gif' if guild.is_icon_animated() is True else 'png'
                )))
            embed.title = f'Joined a guild'
            time = datetime.strftime(guild.me.joined_at,
                                     "%A %d %B %Y at %H:%M:%S")
            embed.description = f'`Name:` {guild.name}\n`ID:` {guild.id}\n`Owner:` {guild.owner}\n`Time:` {time}'
            await self.bot.log_channel.send(embed=embed)

        self.bot.log.info(
            f'Joined a guild. Name: {guild.name} | ID: {guild.id} | Owner: {guild.owner}'
        )

        if guild.id in self.bot.guild_blacklist.keys():
            await guild.leave()
Ejemplo n.º 12
0
	async def get_guild_info(self, guild: discord.Guild):
		"""Get a guild's info and return a fully formatted, ready-made embed fields list.
		returns: [{'name': *name*, 'value': *value*}]"""

		member_info = ""
		bots = 0
		humans = 0
		admins = 0
		total_member_count = guild.member_count
		for member in guild.members:
			if member.bot:
				bots += 1
				continue
			else:
				humans += 1
				if member.guild_permissions.administrator:
					admins += 1
		member_info += f"{total_member_count} total, {bots} bots, {humans} humans ({admins} admins)"

		us = '🇺🇸'
		regions = {
			# these look like weird font letters, but they are actually the flag emojis (when sent in discord).
			'amsterdam': '🇳🇱',
			'brazil': '🇧🇷',
			'eu_central': '🇪🇺',
			'eu_west': '🇪🇺',
			'frankfurt': '🇩🇪',
			'hongkong': '🇨🇳',
			'india': '🇮🇳',
			'japan': '🇯🇵',
			'london': '🇬🇧',
			'russia': '🇷🇺',
			'singapore': '🇸🇬',
			'southafrica': '🇿🇦',
			'sydney': '🇦🇺',
			'us_central': us,
			'us_east': us,
			'us_south': us,
			'us_west': us
		}
		features_dict = {
			"VIP_REGIONS": f'\U00002b50{str(guild.region).lower().replace("-", "_")}',
			"COMMERCE": '\U0001f6d2',
			'NEWS': '\U0001f4f0',
			'BANNER': '\U0001f3f3',
			'ANIMATED_ICON': '',
			'DISCOVERABLE': self.emojis['search'],
			'LURKABLE': self.emojis['lurk'],
			'MORE_EMOJI': '\U00002795\U0001f604',
			'PARTNERED': self.emojis['partner'],
			'VERIFIED': self.emojis['verified'],
			'INVITE_SPLASH': f'{self.emojis["invite"]}\U0001f3f3',
			'VANITY_URL': self.emojis['invite']
		}
		features = guild.features
		fs = ""
		for f in features:
			fs += f"{features_dict[str(f)]} {str(f).lower().replace('_', ' ')}\n"
		region = f"{regions.get(str(guild.region).lower().replace('-', '_')) or ':question:'} {str(guild.region)}"
		verif = str(guild.verification_level).replace('_', ' ')
		notif = str(guild.default_notifications).replace('_', ' ').replace('NotificationLevel.', ' ')
		filter = str(guild.explicit_content_filter).replace('_', ' ')

		system_channel = '#' + str(guild.system_channel) if guild.system_channel else None
		system_channel_flags = []
		for flag, value in guild.system_channel_flags:
			system_channel_flags.append(
				(str(flag).replace('_', ' '), self.emojis['toggles']['on'] if value else self.emojis['toggles']['off']))
		system_channel_flags = ' | '.join([f"{x}: {y}" for x, y in system_channel_flags])

		emojis = len(guild.emojis)

		afk_channel = guild.afk_channel
		afk_timeout = fix_time(guild.afk_timeout)

		icon = str(guild.icon_url_as(static_format='png')) if guild.icon_url else None

		nitro_level = f"Nitro Level: {guild.premium_tier}"
		nitro_subs = f"Boosters: {guild.premium_subscription_count}"

		voice = len(guild.voice_channels)
		text = len(guild.text_channels)
		cat = len(guild.categories)
		ci = f"<:category:614652379278606376> {cat} categories\n <:text_channel:614652616403845120>{text} text channels" \
		     f"\n<:voice_channel:614652616437268636> {voice} voice channels"
		created = ago_time(guild.created_at)
		stuff = []
		stuff.append({"name": "member info", "value": member_info})
		stuff.append({"name": "channel info", "value": ci})
		stuff.append({"name": "region", "value": region})
		stuff.append({"name": "verification level", "value": verif})
		stuff.append({"name": "notification level", "value": notif})
		stuff.append({"name": "filter level", "value": filter})
		stuff.append(
			{"name": "system channel", "value": f"{system_channel}\nSystem channel flags: {system_channel_flags}"})
		stuff.append({"name": "emojis", "value": emojis})
		stuff.append({"name": "afk info",
		              "value": f"Channel: {afk_channel.mention if afk_channel else None}\nTimeout: {afk_timeout}"})
		stuff.append({"name": "nitro boost info", "value": f"{nitro_level}\n{nitro_subs}"})
		stuff.append({"name": "created", "value": created})
		stuff.append({"name": "icon url", "value": icon})
		return stuff
Ejemplo n.º 13
0
 async def serverinfo_embed(self,
                            guild: discord.Guild,
                            guild_type="standard"):
     if guild_type is "standard":
         name = guild.name
         membercount = guild.member_count
         guild_icon = guild.icon_url_as(format="png")
         owner = guild.owner
         guild_id = guild.id
         mfa_level = {0: "disabled", 1: "enabled"}.get(guild.mfa_level)
         verification_level = {
             discord.VerificationLevel.none:
             "No criteria set.",
             discord.VerificationLevel.low:
             "Members must have a verified email on their Discord "
             "account.",
             discord.VerificationLevel.medium:
             "Members must have a verified email and be registered "
             "on Discord for more than five minutes.",
             discord.VerificationLevel.high:
             "Members must have a verified email, be registered on "
             "Discord for more than five minutes, and be a member of "
             "the guild itself for more than ten minutes.",
             discord.VerificationLevel.extreme:
             "Members must have a verified phone on their Discord "
             "account."
         }.get(guild.verification_level)
         explicit_content_filter = {
             discord.ContentFilter.disabled:
             "This guild does not have the content "
             "filter enabled.",
             discord.ContentFilter.no_role:
             "This guild has the content filter enabled "
             "for members without a role.",
             discord.ContentFilter.all_members:
             "This guild has the content filter enabled "
             "for every member."
         }.get(guild.explicit_content_filter)
         special_features = guild.features
         splash = guild.splash_url
         role_count = len(guild.roles)
         voice_channel_count = len(guild.voice_channels)
         text_channel_count = len(guild.text_channels)
         category_count = len(guild.categories)
         creation_date = f"{str(guild.created_at).split('.', 1)[0]} UTC"
         server_region = guild.region
         guild_icon_main_color = await self.color.compute_average_image_color(
             guild_icon)
         rgb_format = guild_icon_main_color.get("colors")
         hex_format = guild_icon_main_color.get("hex")
         embed = discord.Embed(color=discord.Color.from_rgb(
             rgb_format.get("red"), rgb_format.get("green"),
             rgb_format.get("blue")),
                               description=f"ID: {guild_id}")
         embed.add_field(
             name="General information:",
             value=
             f"> Creation date: {creation_date}\n> Channel category count: {category_count}\n> Text channel "
             f"count: {text_channel_count}\n> Voice channel count: {voice_channel_count}\n"
             f"> Role count: {role_count}\n> Member count: {membercount}\n> Owner ID: {owner.id}\n"
             f"> Server region: {server_region}\n> Avarage color of the guilds icon: {hex_format}"
         )
         if len(special_features) > 0:
             special_features_ = ""
             for item in special_features:
                 if item == "INVITE_SPLASH":
                     special_features += f"> {item}(<{splash}>), "
                 else:
                     special_features += f"> {item}, "
             embed.add_field(name="Special features:",
                             value=f"{special_features_}")
         embed.set_author(name=name, icon_url=guild_icon)
         embed.set_thumbnail(url=guild_icon)
         embed.add_field(
             name="Security settings:",
             value=f"> Verification level: {verification_level}\n"
             f"> Explicit Content filter: {explicit_content_filter}\n"
             f"> Two factor authorisation is {mfa_level}",
         )
     else:
         embed = discord.Embed(
             color=discord.Color.dark_blue(),
             description=f"General information:\n"
             f"> ID: {guild.id}\n> Creation date: {str(guild.created_at).split('.', 1)[0]} UTC"
         )
         embed.set_author(name=guild.name)
         embed.set_footer(
             text=
             "This is a minimised but global version of the serverinfo command."
         )
     return embed
Ejemplo n.º 14
0
def get_icon(guild: discord.Guild) -> str:
    fmt = 'gif' if guild.is_icon_animated() else 'png'
    return str(guild.icon_url_as(format=fmt))