How to use the discord.Colour function in discord

To help you get started, we’ve selected a few discord examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aikaterna / aikaterna-cogs / tools / tools.py View on Github external
if role is not None:
            perms = iter(role.permissions)
            perms_we_have = ""
            perms_we_dont = ""
            for x in perms:
                if "True" in str(x):
                    perms_we_have += "{0}\n".format(str(x).split("'")[1])
                else:
                    perms_we_dont += "{0}\n".format(str(x).split("'")[1])
            if perms_we_have == "":
                perms_we_have = "None"
            if perms_we_dont == "":
                perms_we_dont = "None"
            msg = discord.Embed(description="Gathering role stats...", colour=role.color)
            if role.color is None:
                role.color = discord.Colour(value=0x000000)
            loadingmsg = await ctx.send(embed=msg)
            em = discord.Embed(colour=role.colour)
            if caller == "invoke":
                em.add_field(name="Server", value=role.guild.name)
            em.add_field(name="Role Name", value=role.name)
            em.add_field(name="Created", value=self._dynamic_time(role.created_at))
            em.add_field(
                name="Users in Role", value=len([m for m in guild.members if role in m.roles])
            )
            em.add_field(name="ID", value=role.id)
            em.add_field(name="Color", value=role.color)
            em.add_field(name="Position", value=role.position)
            em.add_field(name="Valid Permissons", value="{}".format(perms_we_have))
            em.add_field(name="Invalid Permissons", value="{}".format(perms_we_dont))
            em.set_thumbnail(url=role.guild.icon_url)
        try:
github python-discord / bot / bot / cogs / source.py View on Github external
cog_url = f"{Source.BASE_URL}{module_path}#L{cog_lineno}"

        path_segments = module_path.split("/")
        module_desc = "/".join(
            f"[{segment}]({Source.BASE_URL}{'/'.join(path_segments[:idx])})"
            for idx, segment in enumerate(path_segments, start=1)
        )

        embed = Embed(
            title=f":guild_update: View Source Code",
            description=(
                f"```{constants.Bot.prefix}{command}```\n"
                f"**Cog:** [{cog_name}]({cog_url})\n"
                f"**Module:** {module_desc}\n"
            ),
            colour=Colour.blurple(),
            url=command_url,
        )
        embed.set_footer(
            text=f"{end - start + 1} lines total, (L{start}:L{end})",
        )
        return embed
github Rapptz / RoboDanny / cogs / splatoon.py View on Github external
def to_colour(d):
            return discord.Colour.from_rgb(int(d['r'] * 255), int(d['g'] * 255), int(d['b'] * 255))
github NabDev / NabBot / cogs / tibiawiki.py View on Github external
if spell.price == 0:
            description += "\nIt can be obtained for free."
        else:
            description += f"\nIt can be bought for {spell.price:,} gold coins."
        embed.description = description

        too_long = await cls.get_spell_embed_parse_teachers(embed, spell.taught_by, long, short_limit, voc_list, vocs)
        # Set embed color based on element:
        element_color = {
            "Fire": discord.Colour(0xFF9900),
            "Ice": discord.Colour(0x99FFFF),
            "Energy": discord.Colour(0xCC33FF),
            "Earth": discord.Colour(0x00FF00),
            "Holy": discord.Colour(0xFFFF00),
            "Death": discord.Colour(0x990000),
            "Physical": discord.Colour(0xF70000),
            "Bleed": discord.Colour(0xF70000),
        }
        elemental_emoji = ""
        if spell.element in element_color:
            embed.colour = element_color[spell.element]
            if spell.element == "Bleed":
                spell.element = "Physical"
            if config.use_elemental_emojis:
                elemental_emoji = config.elemental_emojis[spell.element.lower()]
        effect = f"\n\n{elemental_emoji}{spell.effect}"
        embed.description += effect
        if too_long:
            ask_channel = await ctx.ask_channel_name()
            if ask_channel:
                askchannel_string = " or use #" + ask_channel
github PapyrusThePlant / Scarecrow / cogs / info.py View on Github external
invite = None
        perms = guild.text_channels[0].permissions_for(guild.me)
        if perms.manage_guild:
            # Get only permanent and valid invites
            invites = await guild.invites()
            invites = [inv for inv in invites if not inv.revoked and inv.max_age == 0]
            if invites:
                # Get the invite with the most uses
                invites.sort(key=lambda inv: inv.uses, reverse=True)
                invite = invites[0]

        # Create and fill the embed
        if invite is not None:
            embed = discord.Embed(title='Server invite', url=invite.url, colour=discord.Colour.blurple())
        else:
            embed = discord.Embed(colour=discord.Colour.blurple())
        embed.set_author(name=guild.name, url=guild.icon_url, icon_url=guild.icon_url)
        embed.add_field(name='ID', value=guild.id)
        embed.add_field(name='Owner', value=str(guild.owner))
        embed.add_field(name='Region', value=guild.region.value.title())
        embed.add_field(name='Members', value=members)
        embed.add_field(name='Channels', value=channels)
        embed.add_field(name='Features', value=features)
        embed.add_field(name='Roles', value=roles)
        embed.set_footer(text='Server created the ')
        embed.timestamp = guild.created_at

        await ctx.send(embed=embed)
github nguuuquaaa / Belphegor / belphegor / music.py View on Github external
elif music_player.repeat is False:
            repeat = ""
        try:
            current_song_info = music_player.current_song.info()
        except AttributeError:
            current_song_info = ""
        if music_player.queue:
            return utils.Paginator(
                music_player.queue, 10, separator="\n\n",
                title=f"{state}{repeat} {current_song_info}",
                description=lambda i, x: f"`{i+1}.` **[{x.title}]({x.url})**",
                colour=discord.Colour.green(),
                thumbnail_url="http://i.imgur.com/HKIOv84.png"
                )
        else:
            return discord.Embed(title=f"{state}{repeat} {current_song_info}", colour=discord.Colour.green())
github TrustyJAID / Trusty-cogs / extendedmodlog / eventmixin.py View on Github external
async def get_event_colour(
        self, guild: discord.Guild, event_type: str, changed_object: Union[discord.Role] = None
    ) -> discord.Colour:
        if guild.text_channels:
            cmd_colour = await self.get_colour(guild.text_channels[0])
        else:
            cmd_colour = discord.Colour.red()
        defaults = {
            "message_edit": discord.Colour.orange(),
            "message_delete": discord.Colour.dark_red(),
            "user_change": discord.Colour.greyple(),
            "role_change": changed_object.colour if changed_object else discord.Colour.blue(),
            "role_create": discord.Colour.blue(),
            "role_delete": discord.Colour.dark_blue(),
            "voice_change": discord.Colour.magenta(),
            "user_join": discord.Colour.green(),
            "user_left": discord.Colour.dark_green(),
            "channel_change": discord.Colour.teal(),
            "channel_create": discord.Colour.teal(),
github Rapptz / RoboDanny / cogs / stats.py View on Github external
async def bothealth(self, ctx):
        """Various bot health monitoring tools."""

        # This uses a lot of private methods because there is no
        # clean way of doing this otherwise.

        HEALTHY = discord.Colour(value=0x43B581)
        UNHEALTHY = discord.Colour(value=0xF04947)
        WARNING = discord.Colour(value=0xF09E47)
        total_warnings = 0

        embed = discord.Embed(title='Bot Health Report', colour=HEALTHY)

        # Check the connection pool health.
        pool = self.bot.pool
        total_waiting = len(pool._queue._getters)
        current_generation = pool._generation

        description = [
            f'Total `Pool.acquire` Waiters: {total_waiting}',
            f'Current Pool Generation: {current_generation}',
            f'Connections In Use: {len(pool._holders) - pool._queue.qsize()}'
        ]
github idoneam / Canary / cogs / quotes.py View on Github external
return

        conn.close()
        quote_tuple = random.choice(quotes)
        author_id = int(quote_tuple[0])
        name = quote_tuple[1]
        quote = quote_tuple[2]
        author = discord.utils.get(ctx.guild.members, id=author_id)

        # get author name, if the user is still on the server, their
        # current nick will be displayed, otherwise use the name stored
        # in db

        author_name = author.display_name if author else name
        pfp = author.avatar_url if author else DEFAULT_AVATAR
        embed = discord.Embed(colour=discord.Colour(random.randint(
            0, 16777215)),
                              description=quote)

        img_urls_found = re.findall(IMAGE_REGEX, quote)

        if img_urls_found:
            embed.set_image(url=img_urls_found[0])

        embed.set_author(name=author_name, icon_url=pfp)
        await ctx.send(embed=embed)
github TrustyJAID / Trusty-cogs / starboard / events.py View on Github external
    async def _get_colour(self, channel: discord.TextChannel) -> discord.Colour:
        try:
            if await self.bot.db.guild(channel.guild).use_bot_color():
                return channel.guild.me.colour
            else:
                return await self.bot.db.color()
        except AttributeError:
            return await self.bot.get_embed_colour(channel)