Python discord 模块,Colour() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用discord.Colour()

项目:youtube    作者:FishyFing    | 项目源码 | 文件源码
def _list_channels(self, ctx):
        """Lists YouTube channels with announcements enabled"""
        guild = ctx.message.guild
        if guild.id in self.ids:
            try:
                data = discord.Embed(
                    title="**__Announcement Channels__**\n", colour=discord.Colour(value=11735575))
                k = self.ids[guild.id]['yt_channel']
                data.add_field(
                    name="YouTube Channel", value=k)
                data.add_field(
                    name="Discord Channel", value=self.ids[guild.id]['channel'])
                data.set_footer(
                    text="Made with \U00002665 by Francis#6565. Support server: https://discord.gg/yp8WpMh")
                await ctx.send(embed=data)
            except IndexError as e:
                logger.exception(
                    "An error occured while pulling data from list... {}".format(e))
项目:Sparcli    作者:4Kaylum    | 项目源码 | 文件源码
def changecolour(self, ctx, roleColour: str, *, roleName: str):
        '''
        Changes the colour of a specified role
        '''

        # Get the role colour
        roleColour = colourFixer(roleColour)

        # Get the role itself
        role = await getTextRoles(ctx, roleName, speak=True, sparcli=self.sparcli)
        if type(role) == int: return

        # Change the role colour
        colour = Colour(int(roleColour, 16))
        await self.sparcli.edit_role(ctx.message.server, role, colour=colour)
        await self.sparcli.say('The colour of the role `{0.name}` has been changed to value `{1.value}`.'.format(role, colour))
项目:randi    作者:nhatzHK    | 项目源码 | 文件源码
def generate_help(commands, config):
    e_title = config['help']['title']
    e_colour = discord.Colour (0x123654)
    e_url = config['help']['url']
    e_desc = config['help']['description']
    for com in commands:
        if 'usage' in commands[com]:
            h = f"**{com}** \n\t{commands[com]['description']}\
                    \n\t`@xkcd {commands[com]['usage']}`"

            if 'alias' in commands[com]:
                h += f"\n\tAliases: `{'`, `'.join(commands[com]['alias'])}`"

            e_desc += f"\n\n{h}"

    h_embed = discord.Embed (
            title = e_title,
            colour = e_colour,
            url = e_url,
            description = f"{e_desc}\n\n")
    h_embed.set_footer (
            text = config['help']['footer'],
            icon_url = config['help']['icon_url'])

    return h_embed
项目:paobot-Release    作者:cjoeml    | 项目源码 | 文件源码
def helpful_link(self, ctx, link: str):
        """Currently the most useless function in the world"""

        author = ctx.message.author
        description = ("Have a helpful link: "
                       "[LINK]({})".format(link))
        field_name = "Link name"
        field_contents = "This is link"
        footer_text = "Check out this link or not, who even cares."

        embed = discord.Embed(colour=0xFF0000, description=description) # Can use discord.Colour() as well
        embed.title = "Linky link"
        embed.set_author(name=str(author.name), icon_url=author.avatar_url)
        embed.add_field(name=field_name, value=field_contents) # Can add multiple fields.
        embed.set_footer(text=footer_text)

        await self.bot.say(embed=embed)
项目:csss-minion    作者:henrymzhao    | 项目源码 | 文件源码
def rank(self, ctx):
    if len(ctx.message.mentions) > 0:
      ctx.message.author = ctx.message.mentions[0]
    self.cur.execute('SELECT * FROM (SELECT *, row_number() OVER(ORDER BY exp DESC) FROM experience) AS filter WHERE filter.user_id={}'.format(ctx.message.author.id))
    res = list(self.cur.fetchone())
    self.cur.execute('SELECT count(*) from experience')
    totalUsers = self.cur.fetchone()[0]
    level = res[4]
    totalExperience = res[3]
    currentExperience = self.currentExp(level, totalExperience)
    rank = res[6]
    nextLevel = self.calcLevel(int(level))

    embed = discord.Embed(colour=discord.Colour(0x1d86c9))
    embed.set_author(name=ctx.message.author.name, icon_url=ctx.message.author.avatar_url)
    embed.set_footer(text="CSSS-Minion")
    embed.add_field(name="Rank", value="{}/{}".format(rank, totalUsers), inline=True)
    embed.add_field(name="Level", value=level, inline=True)
    embed.add_field(name="Experience", value="{} / {} XP [{} total]".format(int(currentExperience), int(nextLevel), int(totalExperience)), inline=True)
    await self.bot.say(embed=embed)
项目:csss-minion    作者:henrymzhao    | 项目源码 | 文件源码
def help(self):


        embed = discord.Embed(title="gameR Commands", colour=discord.Colour(0xdc4643), timestamp=datetime.datetime.utcfromtimestamp(1490339531))

        embed.set_thumbnail(url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")
        embed.set_author(name="CSSS-Minion", icon_url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")
        embed.set_footer(text="CSSS-Minion", icon_url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")

        embed.add_field(name=".help", value="Displays this help menu.")
        embed.add_field(name=".new <game>", value="Start a new game and join it with the given id")
        embed.add_field(name=".join <game>", value="Joins the given game id")
        embed.add_field(name=".players <game>", value="Lists players in a game")
        embed.add_field(name=".list", value="Lists all games")
        embed.add_field(name=".start", value="Starts the current game your in")
        embed.add_field(name=".fire", value="When its your turn fire the curretly loaded chamber in the gun")
        embed.add_field(name=".spin", value="When its your turn, randomize the location of the bullet and fire, everytime you spin you fire once more")
        embed.add_field(name=".leave", value="Once a game is done you can leave the room")
        embed.add_field(name=".restart", value="Once a game is done, reset the room to get ready to start again, and let new people join")
        embed.add_field(name=".room", value="Displays your current game")
        embed.add_field(name="Source Code", value="https://github.com/henrymzhao/csss-minion/")

        await self.bot.say(embed=embed)
        await removeAfterDelay(self.bot,ctx.message)
项目:csss-minion    作者:henrymzhao    | 项目源码 | 文件源码
def mc(self, ctx):
        """Display the help menu for the minecraft server"""
        if ctx.message.channel.name != "minecraft":
            await self.bot.say("Please move to #minecraft for this command.")
        else:
            embed = discord.Embed(title="CSSS-Minion Minecraft Commands", colour=discord.Colour(
                0xdc4643), timestamp=datetime.datetime.utcfromtimestamp(1490339531))
            embed.set_thumbnail(
                url="https://media-elerium.cursecdn.com/avatars/13/940/635581309636616244.png")
            embed.set_author(
                name="CSSS-Minion", icon_url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")
            embed.set_footer(
                text="CSSS-Minion", icon_url="https://s-media-cache-ak0.pinimg.com/originals/aa/65/70/aa657074a12fb0d961a1789c671b73e3.jpg")
            embed.add_field(name=".help mc", value="Displays this help menu.\n")
            embed.add_field(name=".status", value="Displays the current server status.\n")
            embed.add_field(name=".info", value="Information about how to connect to server.\n")
            await self.bot.say(embed=embed)
项目:csss-minion    作者:henrymzhao    | 项目源码 | 文件源码
def announce(self, ctx, title, desc):
        """Make an announcement
        Usage: announce <title> <body>
        Restricted command
        """
        author = ctx.message.author
        if author.permissions_in(ctx.message.channel).manage_channels or author.server_permissions.manage_channels:

            try:
                color = author.colour
            except Exception:
                color = discord.Colour(r.randrange(0xffffff))
            embed = discord.Embed(title = title, description = desc, color = color, timestamp = datetime.datetime.utcnow())
            embed.set_thumbnail(url=author.avatar_url)
            embed.set_author(name=author.display_name, icon_url = author.avatar_url)
            await self.bot.say(embed = embed)
        try:
            await self.bot.delete_message(ctx.message)
        except Exception:
            #thats ok
            print("Not allowed to delete message")
项目:csss-minion    作者:henrymzhao    | 项目源码 | 文件源码
def modsay(self, ctx, *msg):
    """Give a stern message.
       Heavily inspired by brenfan's .em code <3
    """
    author = ctx.message.author
    if author.permissions_in(ctx.message.channel).manage_channels or author.server_permissions.manage_channels:

      try:
        color = red
      except Exception:
        color = discord.Colour(0xff0000)
      string = "\n\n["+" ".join(msg)+"]()"
      embed = discord.Embed(description = string, color = color, title="An Echo From the Heavens Says...", footer="Moderator Warning")
      embed.set_author(name=author.display_name, icon_url = author.avatar_url)
      embed.set_footer(text="Moderator Warning")
      await self.bot.say(embed=embed)
    try:
      await self.bot.delete_message(ctx.message)
    except Exception:
      print("Not allowed to delete message")
项目:Chiaki-Nanami    作者:Ikusaba-san    | 项目源码 | 文件源码
def ball(self, ctx, *, question: str):
        """...it's a 8-ball"""
        if not question.endswith('?'):
            return await ctx.send(f"{ctx.author.mention}, that's not a question, I think.")

        colour = discord.Colour(random.randint(0, 0xFFFFFF))

        eight_ball_field_name = '\N{BILLIARDS} 8-ball'
        embed = (discord.Embed(colour=colour)
                 .add_field(name='\N{BLACK QUESTION MARK ORNAMENT} Question', value=question)
                 .add_field(name=eight_ball_field_name, value='\u200b', inline=False)
                 )

        msg = await ctx.send(content=ctx.author.mention, embed=embed)

        new_colour = discord.Colour.from_rgb(*(round(c * 0.7) for c in colour.to_rgb()))
        default = _8default._replace(colour=new_colour)

        async with ctx.typing():
            for answer in (default, random.choice(BALL_ANSWERS)):
                await asyncio.sleep(random.uniform(0.75, 1.25) * 2)
                embed.colour = answer.colour
                embed.set_field_at(-1, name=eight_ball_field_name, value=answer.answer, inline=False)
                await msg.edit(embed=embed)
项目:Chiaki-Nanami    作者:Ikusaba-san    | 项目源码 | 文件源码
def colour(self, ctx):
        """Generates a random colo(u)r."""
        colour = discord.Colour(random.randint(0, 0xFFFFFF))
        as_str = str(colour)
        rgb = colour.to_rgb()
        h, s, v = colorsys.rgb_to_hsv(*(v / 255 for v in rgb))
        hsv = h * 360, s * 100, v * 100


        colour_embed = (discord.Embed(title=as_str, colour=colour)
                       .set_thumbnail(url=f'http://colorhexa.com/{as_str[1:]}.png')
                       .add_field(name="RGB", value='%d, %d, %d' % rgb)
                       .add_field(name="HSV", value='%.03f, %.03f, %.03f' % hsv))
        if webcolors:
            colour_embed.description = get_colour_name(rgb)
        await ctx.send(embed=colour_embed)
项目:Shallus-Bot    作者:cgropp    | 项目源码 | 文件源码
def colour(self, ctx, role: discord.Role, value: discord.Colour):
        """Edits a role's colour

        Use double quotes if the role contains spaces.
        Colour must be in hexadecimal format.
        \"http://www.w3schools.com/colors/colors_picker.asp\"
        Examples:
        !editrole colour \"The Transistor\" #ff0000
        !editrole colour Test #ff9900"""
        author = ctx.message.author
        try:
            await self.bot.edit_role(ctx.message.server, role, color=value)
            logger.info("{}({}) changed the colour of role '{}'".format(
                author.name, author.id, role.name))
            await self.bot.say("Done.")
        except discord.Forbidden:
            await self.bot.say("I need permissions to manage roles first.")
        except Exception as e:
            print(e)
            await self.bot.say("Something went wrong.")
项目:bursting-cogs    作者:Repulser    | 项目源码 | 文件源码
def valor(self, ctx):
        user = ctx.message.author
        server = ctx.message.server
        roles = [role.name.replace('@', '@\u200b') for role in user.roles]
        if 'Valor' in roles:
            await self.bot.say("You already joined that team!")
        elif 'Mystic' in roles or 'Instinct' in roles:
            await self.bot.say("You have already joined a team please leave a team before adding a new one")
        else:
            serverroles = [role.name.replace('@', '@\u200b') for role in server.roles]
            if 'Mystic' in serverroles and 'Valor' in serverroles and 'Instinct' in serverroles:
                valor = discord.utils.find(lambda r: r.name == 'Valor', ctx.message.server.roles)
                await self.bot.add_roles(user, valor)
                await self.bot.say("Team succesfuly joined! :+1:")

            else:
                await self.bot.say("No roles found, creating them now.... ")
                valor = await self.bot.create_role(ctx.message.server)
                mystic = await self.bot.create_role(ctx.message.server)
                instinct = await self.bot.create_role(ctx.message.server)
                await self.bot.edit_role(ctx.message.server, valor, name='Valor', colour=discord.Colour(value=15995914))
                await self.bot.edit_role(ctx.message.server, mystic, name='Mystic', colour=discord.Colour(value=423919))
                await self.bot.edit_role(ctx.message.server, instinct, name='Instinct', colour=discord.Colour(value=16501507))
项目:bursting-cogs    作者:Repulser    | 项目源码 | 文件源码
def mystic(self, ctx):
        server = ctx.message.server
        user = ctx.message.author
        roles = [role.name.replace('@', '@\u200b') for role in user.roles]
        if 'Mystic' in roles:
            await self.bot.say("You already joined that team!")
        elif 'Valor' in roles or 'Instinct' in roles:
            await self.bot.say("You have already joined a team please leave a team before adding a new one")
        else:
            serverroles = [role.name.replace('@', '@\u200b') for role in server.roles]
            if 'Mystic' in serverroles and 'Valor' in serverroles and 'Instinct' in serverroles:
                mystic = discord.utils.find(lambda r: r.name == 'Mystic', ctx.message.server.roles)
                await self.bot.add_roles(user, mystic)
                await self.bot.say("Team succesfuly joined! :+1:")

            else:
                await self.bot.say("No roles found, creating them now.... ")
                valor = await self.bot.create_role(ctx.message.server)
                mystic = await self.bot.create_role(ctx.message.server)
                instinct = await self.bot.create_role(ctx.message.server)
                await self.bot.edit_role(ctx.message.server, valor, name='Valor', colour=discord.Colour(value=15995914))
                await self.bot.edit_role(ctx.message.server, mystic, name='Mystic', colour=discord.Colour(value=423919))
                await self.bot.edit_role(ctx.message.server, instinct, name='Instinct', colour=discord.Colour(value=16501507))
项目:bursting-cogs    作者:Repulser    | 项目源码 | 文件源码
def instinct(self, ctx):
        server = ctx.message.server
        user = ctx.message.author
        roles = [role.name.replace('@', '@\u200b') for role in user.roles]
        if 'Instinct' in roles:
            await self.bot.say("You already joined that team!")
        elif 'Mystic' in roles or 'Valor' in roles:
            await self.bot.say("You have already joined a team please leave a team before adding a new one")
        else:
            serverroles = [role.name.replace('@', '@\u200b') for role in server.roles]
            if 'Mystic' in serverroles and 'Valor' in serverroles and 'Instinct' in serverroles:
                instinct = discord.utils.find(lambda r: r.name == 'Instinct', ctx.message.server.roles)
                await self.bot.add_roles(user, instinct)
                await self.bot.say("Team succesfuly joined! :+1:")

            else:
                await self.bot.say("No roles found, creating them now.... ")
                valor = await self.bot.create_role(ctx.message.server)
                mystic = await self.bot.create_role(ctx.message.server)
                instinct = await self.bot.create_role(ctx.message.server)
                await self.bot.edit_role(ctx.message.server, valor, name='Valor', colour=discord.Colour(value=15995914))
                await self.bot.edit_role(ctx.message.server, mystic, name='Mystic', colour=discord.Colour(value=423919))
                await self.bot.edit_role(ctx.message.server, instinct, name='Instinct', colour=discord.Colour(value=16501507))
项目:bursting-cogs    作者:Repulser    | 项目源码 | 文件源码
def status(self, ctx):
        """Shows the servers settings for welcomer."""
        db = fileIO(self.load, "load")
        if ctx.message.server.id not in db:
            await self.bot.say(":x: **Welcomer has not been configured for this server, use `welcomer channel` first**")
            return
        server = ctx.message.server
        color = ''.join([choice('0123456789ABCDEF') for x in range(6)])
        color = int(color, 16)
        e = discord.Embed(colour=discord.Colour(value=color), description="\n\a")
        role = discord.utils.get(ctx.message.server.roles, id=db[server.id]["botrole"])
        e.set_author(name="Settings for " + server.name, icon_url=server.icon_url)
        e.add_field(name="Welcomer Channel:", value="#" + self.bot.get_channel(db[server.id]["Channel"]).name if self.bot.get_channel(db[server.id]["Channel"]) else None, inline=True)
        e.add_field(name="Join Toggle:", value=db[server.id]["join"], inline=True)
        e.add_field(name="Leave Toggle:", value=db[server.id]["leave"], inline=True)
        e.add_field(name="Bot Role:", value=role.name if role else None)
        e.add_field(name="Bot Role Toggle:", value=db[server.id]["botroletoggle"])  
        e.add_field(name="Embed", value=db[server.id]["Embed"], inline=True)
        e.add_field(name="Leave Message:", value=db[server.id]["leavemessage"], inline=False)
        e.add_field(name="Join Message:", value=db[server.id]["joinmessage"], inline=False)
        try:
            await self.bot.say(embed=e)
        except Exception as e:
            await self.bot.say(e)
项目:bursting-cogs    作者:Repulser    | 项目源码 | 文件源码
def on_member_remove(self, member):
        server = member.server
        db = fileIO(self.load, "load")
        if not server.id in db:
            return
        if db[server.id]['leave'] is False:
            return
        message = db[server.id]['leavemessage']
        channel = db[server.id]["Channel"]
        if db[server.id]["Embed"]:
            color = ''.join([choice('0123456789ABCDEF') for x in range(6)])
            color = int(color, 16)
            data = discord.Embed(title="Member Left!".format(member.id),
                                 description=message.format(member, server),
                                 colour=discord.Colour(value=color))
            data.set_thumbnail(url=member.avatar_url)
            await self.bot.send_message(server.get_channel(channel), embed=data)
        else:
            await self.bot.send_message(server.get_channel(channel), message.format(member, server))
项目:bursting-cogs    作者:Repulser    | 项目源码 | 文件源码
def pogoservers(self, ctx):
        url = "http://cmmcd.com/PokemonTrainerClub/"
        resp = await self.session.get(url, headers={'User-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3'})
        soup = BeautifulSoup(await resp.text(), "html.parser")
        links = soup.find_all('font')
        for item in links:
            level = item.text
        url = "http://cmmcd.com/PokemonGo/"
        resp = await self.session.get(url, headers={'User-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3'})
        soup = BeautifulSoup(await resp.text(), "html.parser")
        links = soup.find_all('font')
        for item in links:
            level2 = item.text
        color = ''.join([choice('0123456789ABCDEF') for x in range(6)])
        color = int(color, 16)
        data = discord.Embed(description=level, colour=discord.Colour(value=color))
        data.add_field(name="Pokémon Go Server Status", value=level2)
        data.set_author(name="PTC Login status")
        await self.bot.say(embed=data)
项目:LunaBot    作者:miraai    | 项目源码 | 文件源码
def colour(self, ctx, colour : discord.Colour, *, role : discord.Role):
        """Changes the colour of a role.

        The colour must be a hexadecimal value, e.g. FF2AEF. Don't prefix it
        with a pound (#) as it won't work. Colour names are also not supported.

        To use this command you must have the Manage Roles permission or
        have the Bot Admin role. The bot must also have Manage Roles permissions.

        This command cannot be used in a private message.
        """
        try:
            await self.bot.edit_role(ctx.message.server, role, colour=colour)
        except discord.Forbidden:
            await self.bot.say('The bot must have Manage Roles permissions to use this.')
        else:
            await self.bot.say('\U0001f44c')

    #changes the name of the role
    #NOTE: Currently CANNOT change default bot role name (BotName=DafaultRoleName)
项目:GAFBot    作者:DiNitride    | 项目源码 | 文件源码
def whois(self, ctx, user_id: int):
        """
        Searches for a user via ID
        """
        try:
            with ctx.channel.typing():
                user = await self.bot.get_user_info(user_id)
                embed = discord.Embed(colour=discord.Colour(0x30f9c7), description="ID: {}".format(user.id),
                                      timestamp=datetime.datetime.now())
                embed.set_thumbnail(
                    url=user.avatar_url)
                embed.set_author(name=user)
                embed.set_footer(text="Who Is: User")
                embed.add_field(name="Bot?", value=user.bot, inline=False)
                embed.add_field(name="Account Creation Date", value=user.created_at, inline=False)
                await ctx.send(embed=embed)
        except discord.NotFound:
            await ctx.send("`No user found under this ID`")
        except discord.HTTPException:
            await ctx.send("`Error collecting user information`")
            return
项目:GAFBot    作者:DiNitride    | 项目源码 | 文件源码
def about(self, ctx, user: discord.Member = None):
        """
        Shows information about a user
        """
        if user is None:
            user = ctx.author
        with ctx.channel.typing():
            embed = discord.Embed(colour=discord.Colour(0x30f9c7), description="ID: {}".format(user.id),
                                  timestamp=datetime.datetime.now())
            embed.set_thumbnail(
                url=user.avatar_url)
            embed.set_author(name=user)
            embed.set_footer(text="All about {}".format(user))
            embed.add_field(name="Bot?", value=user.bot)
            embed.add_field(name="Roles", value="{}".format(len(user.roles) - 1))
            embed.add_field(name="Account Creation Date", value=user.created_at)
            embed.add_field(name="Date Joined Guild", value=user.joined_at)
            embed.add_field(name="Game", value=user.game)
            embed.add_field(name="Status", value=user.status)
            embed.add_field(name="Voice State", value=user.voice)
            embed.add_field(name="Display Name", value=user.display_name)
            await ctx.send(embed=embed)
项目:GAFBot    作者:DiNitride    | 项目源码 | 文件源码
def server(self, ctx):
        """
        Provides information on the server
        """
        with ctx.channel.typing():
            embed = discord.Embed(title="ID: 58934178071780", colour=discord.Colour.gold(),
                                  timestamp=datetime.datetime.now())
            embed.set_thumbnail(
                url=ctx.guild.icon_url)
            embed.set_author(name=ctx.guild.name)
            embed.set_footer(text="About Server")
            embed.add_field(name="Members", value=str(len(ctx.guild.members)))
            embed.add_field(name="Roles", value=str(len(ctx.guild.roles) - 1))
            embed.add_field(name="Channels", value=str(len(ctx.guild.channels)))
            embed.add_field(name="AFK Channel", value=ctx.guild.afk_channel)
            embed.add_field(name="AFK Timeout", value=str(ctx.guild.afk_timeout / 60))
            embed.add_field(name="Owner", value=ctx.guild.owner)
            embed.add_field(name="Creation Date", value=ctx.guild.created_at)
            embed.add_field(name="Region", value=ctx.guild.region)
            embed.add_field(name="Verification Level", value=ctx.guild.verification_level)

            embed.set_footer(text="About Server")
            await ctx.send(embed=embed)
项目:ModTools    作者:MattBSG    | 项目源码 | 文件源码
def cmd_rolecolor(self, message, author, server, rolename, new_hex, reason=None):
        """
        Usage: {command_prefix}rolecolor ["role name"] "#hex color code" ["reason"]
        Changes the color of a role to whatever hexadecimal color code is provided
        """
        if await self.has_roles(message.channel, author, server, command='rolecolor'):
            check = re.compile('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$')
            if check.match(new_hex):
                try:
                    role = discord.utils.get(server.roles, name=rolename)
                    if not role:
                        int('this')
                except:
                    raise CommandError('Invalid Role: {}'.format(rolename))
                new_int = new_hex.replace('#', '0x')
                new_int = int(new_int, 0)
                await self.edit_role(server, role, colour=discord.Colour(value=new_int))
                await self.write_to_modlog(message, author, server, reason)
            else:
                raise CommandError('Invalid Hex Code: {}'.format(new_hex))
项目:Asurix-bot    作者:Beafantles    | 项目源码 | 文件源码
def get_embed(self, bot):
        """Returns an embed corresponding to the log"""
        embed = discord.Embed()
        user = discord.utils.find(lambda u: u.id == self.user_id, \
                                    bot.get_all_members())
        if user:
            embed.title = user.name + "#" + user.discriminator + " (" + user.id + ")"
            embed.set_thumbnail(url=user.avatar_url)
        else:
            embed.title = "Unknown member (" + self.user_id + ")"
        responsible = discord.utils.find(lambda u: u.id == self.responsible_id, \
                                    bot.get_all_members())
        if responsible:
            embed.add_field(name="Responsible", \
                        value=responsible.name + "#" + responsible.discriminator + \
                        " (" + responsible.id + ")", inline=False)
        else:
            embed.add_field(name="Responsible", \
                        value="Uknown responsible (" + self.responsible_id + ")", inline=False)

        embed.timestamp = datetime.strptime(self.date, "%d/%m/%Y %H:%M:%S")
        embed.colour = discord.Colour(value=COLORS[self.type])
        embed.set_author(name="Case #" + str(self.log_id))
        embed.add_field(name="Reason", value=self.reason, inline=False)
        return embed
项目:Discord-SelfBot    作者:IgneelDxD    | 项目源码 | 文件源码
def _colour(self, ctx, role: str, colour: str):
        """Set the Color of a Role."""
        role = getRole(ctx, role)
        colour = getColor(colour)
        if not role:
            return await edit(ctx, content="\N{HEAVY EXCLAMATION MARK SYMBOL} Role not found", ttl=5)
        elif not colour:
            return await edit(ctx, content="\N{HEAVY EXCLAMATION MARK SYMBOL} Colour not found", ttl=5)
        else:
            value = discord.Colour(int((colour.hex_l.strip('#')), 16))
            try:
                await role.edit(colour=value)
            except discord.HTTPException:
                await edit(ctx, content="\N{HEAVY EXCLAMATION MARK SYMBOL} Missing permissions to edit this role", ttl=5)
            else:
                e = discord.Embed(color=value)
                e.set_author(name="Changed Role Color of: " + str(role))
                await edit(ctx, embed=e)
项目:KeekoBot    作者:DavidNeon    | 项目源码 | 文件源码
def colour(self, ctx, role: discord.Role, value: discord.Colour):
        """Edits a role's colour

        Use double quotes if the role contains spaces.
        Colour must be in hexadecimal format.
        \"http://www.w3schools.com/colors/colors_picker.asp\"
        Examples:
        !editrole colour \"The Transistor\" #ff0000
        !editrole colour Test #ff9900"""
        author = ctx.message.author
        try:
            await self.bot.edit_role(ctx.message.server, role, color=value)
            logger.info("{}({}) changed the colour of role '{}'".format(
                author.name, author.id, role.name))
            await self.bot.say("Done.")
        except discord.Forbidden:
            await self.bot.say("I need permissions to manage roles first.")
        except Exception as e:
            print(e)
            await self.bot.say("Something went wrong.")
项目:KeekoBot    作者:DavidNeon    | 项目源码 | 文件源码
def embedsay(self, ctx, *, text: str):
        """Says Something as the bot in a embed"""

        colour = ''.join([choice('0123456789ABCDEF') for x in range(6)])
        colour = int(colour, 16)

        randnum = randint(1, 10)
        empty = u"\u2063"
        emptyrand = empty * randnum

        data = discord.Embed(description=str(
            text), colour=discord.Colour(value=colour))

        if ctx.message.author.avatar_url:
            data.set_author(name=ctx.message.author.name,
                            url=ctx.message.author.avatar_url, icon_url=ctx.message.author.avatar_url)
        else:
            data.set_author(name=ctx.message.author.name)

        try:
            await self.bot.say(emptyrand, embed=data)
        except:
            await self.bot.say("I need the `Embed links` permission to send this")
项目:KeekoBot    作者:DavidNeon    | 项目源码 | 文件源码
def embedsayadmin(self, ctx, *, text: str):
        """Says Something as the bot without any trace of the message author in a embed"""

        if ctx.message.server.me.bot:
            try:
                await self.bot.delete_message(ctx.message)
            except:
                await self.bot.send_message(ctx.message.author, 'Could not delete your message on ' + ctx.message.server.name)

        colour = ''.join([choice('0123456789ABCDEF') for x in range(6)])
        colour = int(colour, 16)

        randnum = randint(1, 10)
        empty = u"\u2063"
        emptyrand = empty * randnum

        data = discord.Embed(description=str(
            text), colour=discord.Colour(value=colour))

        try:
            await self.bot.say(emptyrand, embed=data)
        except:
            await self.bot.say("I need the `Embed links` permission "
                               "to send this")
项目:KeekoBot    作者:DavidNeon    | 项目源码 | 文件源码
def embedcoloradmin(self, ctx, color: str, *, text: str):
        """Says Something as the bot without any trace of the message author in a colored embed"""

        if ctx.message.server.me.bot:
            try:
                await self.bot.delete_message(ctx.message)
            except:
                await self.bot.send_message(ctx.message.author, 'Could not delete your message on ' + ctx.message.server.name)

        color = color.replace("#", "")
        color = color.replace("0x", "")
        color = int(color, 16)

        randnum = randint(1, 10)
        empty = u"\u2063"
        emptyrand = empty * randnum

        data = discord.Embed(description=str(
            text), colour=discord.Colour(value=color))

        try:
            await self.bot.say(emptyrand, embed=data)
        except:
            await self.bot.say("I need the `Embed links` permission to send this")
项目:KeekoBot    作者:DavidNeon    | 项目源码 | 文件源码
def embedsay(self, ctx, *, text: str):
        """Says Something as the bot in a embed"""

        colour = ''.join([choice('0123456789ABCDEF') for x in range(6)])
        colour = int(colour, 16)

        randnum = randint(1, 10)
        empty = u"\u2063"
        emptyrand = empty * randnum

        data = discord.Embed(description=str(
            text), colour=discord.Colour(value=colour))

        if ctx.message.author.avatar_url:
            data.set_author(name=ctx.message.author.name,
                            url=ctx.message.author.avatar_url, icon_url=ctx.message.author.avatar_url)
        else:
            data.set_author(name=ctx.message.author.name)

        try:
            await self.bot.say(emptyrand, embed=data)
        except:
            await self.bot.say("I need the `Embed links` permission to send this")
项目:KeekoBot    作者:DavidNeon    | 项目源码 | 文件源码
def embedsayto(self, ctx, channel: discord.Channel, *, text: str):
        """Says Something as the bot in a embed"""

        colour = ''.join([choice('0123456789ABCDEF') for x in range(6)])
        colour = int(colour, 16)

        randnum = randint(1, 10)
        empty = u"\u2063"
        emptyrand = empty * randnum

        data = discord.Embed(description=str(
            text), colour=discord.Colour(value=colour))

        if ctx.message.author.avatar_url:
            data.set_author(name=ctx.message.author.name,
                            url=ctx.message.author.avatar_url, icon_url=ctx.message.author.avatar_url)
        else:
            data.set_author(name=ctx.message.author.name)

        try:
            await self.bot.send_message(channel, emptyrand, embed=data)
        except:
            await self.bot.say("I need the `Embed links` permission to send this")
项目:KeekoBot    作者:DavidNeon    | 项目源码 | 文件源码
def embedsayadmin(self, ctx, *, text: str):
        """Says Something as the bot without any trace of the message author in a embed"""

        if ctx.message.server.me.bot:
            try:
                await self.bot.delete_message(ctx.message)
            except:
                await self.bot.send_message(ctx.message.author, 'Could not delete your message on ' + ctx.message.server.name)

        colour = ''.join([choice('0123456789ABCDEF') for x in range(6)])
        colour = int(colour, 16)

        randnum = randint(1, 10)
        empty = u"\u2063"
        emptyrand = empty * randnum

        data = discord.Embed(description=str(
            text), colour=discord.Colour(value=colour))

        try:
            await self.bot.say(emptyrand, embed=data)
        except:
            await self.bot.say("I need the `Embed links` permission "
                               "to send this")
项目:KeekoBot    作者:DavidNeon    | 项目源码 | 文件源码
def Nep(self):
        """Displays a random Nep."""

        nep = choice(self.nep)

        nepsay = choice(self.nepsay)

        if not nep or not nepsay:
            await self.bot.say('Something went wrong')
            return

        colour = ''.join([choice('0123456789ABCDEF') for x in range(6)])
        colour = int(colour, 16)

        data = discord.Embed(
            title=nepsay, colour=discord.Colour(value=colour))
        data.set_image(url=nep)

        try:
            await self.bot.say(embed=data)
        except:
            await self.bot.say("I need the `Embed links` permission "
                               "to send this")
项目:dango.py    作者:khazhyk    | 项目源码 | 文件源码
def resolve_color(value):
    """Resolve a custom or pre-defined color.

    This allows html style #123456.
    """
    if value.startswith('#'):
        value = value[1:]  # assumes no named color starts with #

    try:
        intval = int(value, 16)
    except ValueError:
        pass
    else:
        if intval >= (1 << 24):
            raise errors.BadArgument("Invalid color {} is too big!".format(value))
        return discord.Colour(intval)
    try:
        return getattr(discord.Colour, value)()
    except AttributeError:
        raise errors.BadArgument("Invalid color {}".format(value))
项目:PTSCogs    作者:PlanetTeamSpeakk    | 项目源码 | 文件源码
def colorrole(self, ctx, color):
        """Creates a colored role for you!

        Example
        [p]colorrole #8C5200
        Hex pls."""
        if not color.startswith("#"):
            await send_cmd_help(ctx)
            return
        colorhex = color[1:]
        color_role = await self.bot.create_role(server=ctx.message.server, name=color, colour=discord.Colour(value=int(colorhex, 16)))
        await self.bot.add_roles(ctx.message.author, color_role)
        await self.bot.say("Done!")
项目:Sparcli    作者:4Kaylum    | 项目源码 | 文件源码
def setcolour(self, ctx, colour:str, user:Member=None):
        '''
        Creates a new role with a given colour, and assigns it to a user
        '''

        # Fix up some variables
        server = ctx.message.server
        user = ctx.message.author if not user else user

        # Fix the colour string
        colour = colourFixer(colour)
        colourObj = Colour(int(colour, 16))
        # permissions=Permissions(permissions=0)

        # Find the role
        tempRoleFinder = [i for i in server.roles if user.id in i.name]
        if len(tempRoleFinder) > 0:
            role = tempRoleFinder[0]
            await self.sparcli.edit_role(server, role, colour=colourObj)
            created = False
        else:
            role = await self.sparcli.create_role(server, name='SPARCLI - {}'.format(user.id), colour=colourObj)
            await self.sparcli.add_roles(user, role)
            created = True

        # Print out to user
        await self.sparcli.say(
            'This role has been successfully {}. \n'
            'You may need to move the positions of other roles to make it work properly.'.format({True:'created',False:'edited'}[created])
        )
项目:Sparcli    作者:4Kaylum    | 项目源码 | 文件源码
def asetcolour(self, ctx, colour:str):
        '''
        Creates a new role with a given colour, and assigns it to yourself
        Requires enabling
        '''

        # Fix up some variables
        server = ctx.message.server
        user = ctx.message.author

        # Fix the colour string
        colour = colourFixer(colour)
        colourObj = Colour(int(colour, 16))
        # permissions=Permissions(permissions=0)

        # Find the role
        tempRoleFinder = [i for i in server.roles if user.id in i.name]
        if len(tempRoleFinder) > 0:
            role = tempRoleFinder[0]
            await self.sparcli.edit_role(server, role, colour=colourObj)
            created = False
        else:
            role = await self.sparcli.create_role(server, name='SPARCLI - {}'.format(user.id), colour=colourObj)
            await self.sparcli.add_roles(user, role)
            created = True

        # Print out to user
        await self.sparcli.say(
            'This role has been successfully {}. \n'
            'You may need to move the positions of other roles to make it work properly.'.format({True:'created',False:'edited'}[created])
        )
项目:Godavaru    作者:Godavaru    | 项目源码 | 文件源码
def randomColour(self):
        co = ["A", "B", "C", "D", "E", "F", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
        a = int(random.random() * len(co))
        b = int(random.random() * len(co))
        c = int(random.random() * len(co))
        d = int(random.random() * len(co))
        e = int(random.random() * len(co))
        f = int(random.random() * len(co))
        col = "{}{}{}{}{}{}".format(co[a], co[b], co[c], co[d], co[e], co[f])
        return discord.Colour(int(col, 16))
项目:AutomaBot    作者:73VW    | 项目源码 | 文件源码
def make_embed_message(title, datas, bot, message=None):
    """
    Return an embed message for discord.

    Datas must be a simple dict
    """
    # embed properties
    embed_title = title
    embed_colour = discord.Colour(0x3c6d46)
    embed_timestamp = datetime.datetime.utcnow()
    embed = discord.Embed(title=embed_title, colour=embed_colour,
                          timestamp=embed_timestamp)

    # author properties
    if message is not None:
        author = message.author.name
        url = message.author.avatar_url
    else:
        author = datas.pop("author")
        url = bot.user.avatar_url

    author_name = author
    author_icon_url = url
    embed.set_author(name=author_name, icon_url=author_icon_url)

    # footer properties
    footer_text = bot.user.name
    footer_icon_url = bot.user.avatar_url
    embed.set_footer(text=footer_text, icon_url=footer_icon_url)

    # content
    inline = False
    for key, data in datas.items():
        if isinstance(data, bool):
            data = states[data]
        embed.add_field(name=key.title(), value=data, inline=inline)

    return embed
项目:randi    作者:nhatzHK    | 项目源码 | 文件源码
def create_embed(xkcd):
    comic = xkcd['comic']

    embed_comic = discord.Embed \
           (title = '{}: {}'.format(comic['num'], comic['title']), \
            colour = discord.Colour(0x00ff00), url = comic['img'])

    embed_comic.set_footer(text = '{}'.format(comic['alt']))
    embed_comic.set_image(url = comic['img'])
    embed_comic.set_author(name = 'xkcd', \
            url = 'https://xkcd.com/{}'.format(comic['num']))

    return embed_comic
项目:clifford-discord-bot    作者:jwill89    | 项目源码 | 文件源码
def games(self, ctx):
        """Manages games for the roster."""

        # Handle Database
        try:
            with db.cursor() as cursor:
                sql = "SELECT `abv`, `name` FROM games ORDER BY `name`"
                cursor.execute(sql)
                result = cursor.fetchall()
                cursor.close()
        except Exception as e:
            await self.bot.send_message(ctx.message.channel, "{0.mention}, there was an error getting the list of games"
                                                             " for you. I'm sorry! ".format(ctx.message.author) + str(
                e))
            return

        # Create Variables for Embed Table
        abvs = ''
        names = ''

        for row in result:
            abvs += (row['abv'] + '\n')
            names += (row['name'] + '\n')

        # Create Embed Table
        embed = discord.Embed(title="Games List", colour=discord.Colour(0x55ff),
                              description="*The list of available games for the roster commands, as well as their "
                                          "abbreviations for use in those commands.*")
        embed.set_author(name="Zealot Gaming", url="https://www.zealotgaming.com",
                         icon_url="http://www.zealotgaming.com/discord/logos/zg.png")
        embed.set_thumbnail(url="http://www.zealotgaming.com/discord/logos/zg.png")
        embed.add_field(name="Abbreviation", value=abvs, inline=True)
        embed.add_field(name="Game Name", value=names, inline=True)

        # Send Table to User Privately
        await self.bot.send_message(ctx.message.channel, embed=embed)

    # COMMAND: !games add
项目:discordbot.py    作者:rauenzi    | 项目源码 | 文件源码
def _setcolor(self, *, color : discord.Colour):
        """Sets the default color of embeds."""
        data = self.bot.config.get("meta", {})
        data['default_color'] = str(color)
        await self.bot.config.put('meta', data)
        await self.bot.responses.basic(message="The default color has been updated.")
项目:SESTREN    作者:SirThane    | 项目源码 | 文件源码
def color(self):
        """
        :return: attr of discord.Colour for player's default avatar
        """
        name = self.current_player.default_avatar.name
        if name == "grey":
            name = "light_grey"
        return getattr(discord.Colour, name)()

    # @property
    # def valid_moves(self):
    #     """
    #     :return: List of position coords (list x, y) that are not full
    #     """
    #     return [[self.board[i][-1], i] for i in self.order if self.board[i][-1] != 6]
项目:SESTREN    作者:SirThane    | 项目源码 | 文件源码
def __init__(self, bot):
        self.bot = bot
        self.db = bot.db
        self.app_name = bot.app_name
        self.sessions = {}
        self.timeout = 120
        self.timeout_incr = 5
        self.message_icon = ["?", "?", "?"]  # :information_source:, :warning:, :no_entry:
        self.message_color = [discord.Colour.blue(), discord.Colour.orange(), discord.Colour.red()]
项目:SESTREN    作者:SirThane    | 项目源码 | 文件源码
def send_board(self, ctx, init=False, win=None):
        session = self.session(ctx)
        session.ctx = ctx
        if session.msg is not None:
            await session.msg.delete()

        if win:
            if win == "Draw":
                turn = f"Game ended in a Draw."
                color = discord.Colour.dark_grey()
            elif win == "Forfeit":
                turn = f"Game Over. {ctx.author.name} Forfeits."
                color = discord.Colour.dark_grey()
            elif win == "Timeout":
                turn = f"Time Out. {session.current_player.name} Forfeits."
                color = discord.Colour.dark_grey()
            else:
                turn = f"Game Over!\n{win.name} wins! ??"
                color = 0xFDFF00
        else:
            turn = "New game! Turn: 1" if init else f"Turn: {(session.turn + 2) // 2}"
            color = session.color

        em = discord.Embed(title=f"{session.player_chip(session.p1)}{session.p1.name} ?? "
                                 f"{session.p2.name}{session.player_chip(session.p2)}",
                           description=f"{turn}\n\n:one::two::three::four::five::six::seven:\n{session.draw_board}",
                           color=color)

        if win:
            self.sessions.pop(ctx.channel.id)
            await ctx.send(embed=em)
        else:
            em.set_footer(text=f"{session.current_player.name}'s turn: {session.current_player_chip}")
            session.msg = await ctx.send(embed=em)

        if not win == "Timeout" and session.current_player.member is not ctx.guild.me:
            if ctx.channel.permissions_for(ctx.guild.me).manage_messages:
                await ctx.message.delete()
项目:royal-bot-the-third    作者:Steffo99    | 项目源码 | 文件源码
def generate_discord_embed(self):
        embed = discord.Embed(type="rich")
        # TODO: change the icon
        embed.set_author(name="League of Legends", url="http://euw.leagueoflegends.com/", icon_url="https://cdn.discordapp.com/attachments/152150752523976704/307558194824216578/icon.png")
        embed.add_field(name="Summoner", value=str(self.summoner_name))
        embed.add_field(name="Level", value=str(self.level))
        if self.soloq_tier is not None:
            embed.add_field(name="Solo/duo SR", value=f"{lol.tiers[self.soloq_tier].capitalize()} {lol.divisions[self.soloq_division]}", inline=False)
            embed.set_thumbnail(url=f"https://royal.steffo.me/loltiers/{lol.tiers[self.soloq_tier].lower()}_{lol.divisions[self.soloq_division].lower()}.png")
        if self.flexq_tier is not None:
            embed.add_field(name="Flex SR", value=f"{lol.tiers[self.flexq_tier].capitalize()} {lol.divisions[self.flexq_division]}", inline=False)
        if self.ttq_tier is not None:
            embed.add_field(name="Twisted Treeline", value=f"{lol.tiers[self.ttq_tier].capitalize()} {lol.divisions[self.ttq_division]}", inline=False)
        embed.colour = discord.Colour(0x09AEBB)
        return embed
项目:csss-minion    作者:henrymzhao    | 项目源码 | 文件源码
def inspect(self, ctx):
    for role in ctx.message.author.roles:
      if self.bot.Henry(ctx) or role.id == '321832268282855436': #bot devs
        theObject = None
        if len(ctx.message.mentions) > 0:
          theObject = ctx.message.mentions[0]
        elif len(ctx.message.channel_mentions) > 0:
          theObject = ctx.message.channel_mentions[0]
        elif len(ctx.message.role_mentions) > 0:
          theObject = ctx.message.role_mentions[0]
        else:
          self.bot.say("I didn't understand what you are inspecting.")

        if theObject is not None:
          items = []
          dictionary = [x for x in dir(theObject) if not x.startswith('_')]
          for name in dictionary:
            attr = getattr(theObject, name)
            if 'object' not in str(attr) and 'method' not in str(attr):
              items.append([str(name), str(attr), False])
          p = Pages(self.bot, message=ctx.message, entries = items, per_page=10)
          p.embed = discord.Embed(title="Inspection Results", colour=discord.Colour(0xdc4643))
          p.embed.set_thumbnail(url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")
          p.embed.set_author(name="CSSS-Minion", icon_url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")
          p.embed.set_footer(text="CSSS-Minion", icon_url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")

          await p.paginate()
      else:
        self.bot.say("You not a dev, shoo!")
项目:csss-minion    作者:henrymzhao    | 项目源码 | 文件源码
def levels(self, ctx):
    self.cur.execute('SELECT * FROM (SELECT *, row_number() OVER(ORDER BY exp DESC) FROM experience) AS filter')
    res = list(self.cur.fetchall())
    # print(res)
    items = []
    for item in res:
      items.append(['#{}. {}'.format(str(item[6]), str(item[1])), 'Level: {} \nExperience: {}'.format(str(item[4]), str(int(item[3])))])

    p = Pages(self.bot, message=ctx.message, entries = items, per_page=10)
    p.embed = discord.Embed(title="Server Level Rankings", colour=discord.Colour(0xdc4643))
    p.embed.set_thumbnail(url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")
    p.embed.set_author(name="CSSS-Minion", icon_url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")
    p.embed.set_footer(text="CSSS-Minion", icon_url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")

    await p.paginate()
项目:csss-minion    作者:henrymzhao    | 项目源码 | 文件源码
def __init__(self, bot):
        self.bot = bot

    # Voting done, command disabled
    # @commands.command()
    # async def vote():
    #     embed = discord.Embed(colour=discord.Colour(0xdc4643), timestamp=datetime.datetime.utcfromtimestamp(1490339531))

    #     embed.set_thumbnail(url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")
    #     embed.set_author(name="CSSS-Minion", icon_url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")
    #     embed.set_footer(text="CSSS-Minion", icon_url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")

    #     embed.add_field(name="CSSS Voting Information", value="The voting period for the Computing Science Student Society General Elections for the 2017-2018 term begins on Monday March 20th, 2017 at 11:59 PM and closes on Monday March 27th, 2017 at 11:59 PM. \n\nVisit https://www.sfu.ca/~pjalali/speeches.html to view candidate speeches, and http://websurvey.sfu.ca/survey/273372327 to vote.")

    #     await bot.say(embed=embed)

    # @commands.command(pass_context = True)
    # async def voteresult(self, ctx):
    #     """Return the voting results from the previous CSSS election."""
    #     if ctx.invoked_subcommand is None:
    #         embed = discord.Embed(title="CSSS Exec Positions", colour=discord.Colour(0xdc4643), timestamp=datetime.datetime.utcfromtimestamp(1490339531))

    #         embed.set_thumbnail(url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")
    #         embed.set_author(name="CSSS-Minion", icon_url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")
    #         embed.set_footer(text="CSSS-Minion", icon_url="https://cdn.discordapp.com/app-icons/293110345076047893/15e2a6722723827ff9bd53ca787df959.jpg")

    #         embed.add_field(name="President", value="David Miiller")
    #         embed.add_field(name="Vice President", value="Jon Loewen")
    #         embed.add_field(name="Treasurer", value="Dustin Cao")
    #         embed.add_field(name="Director of Resources", value="Kiarash Mirsalehi")
    #         embed.add_field(name="Director of Events", value="Brendan Chan")
    #         embed.add_field(name="Director of Communications", value="Henry Zhao")
    #         embed.add_field(name="Director of Archives", value="Josh Wu")
    #         embed.add_field(name="Source Code", value="https://github.com/henrymzhao/csss-minion/")

    #         await self.bot.say(embed=embed)


    # the following several functions are inspired by formatterhelper and default_help command
项目:csss-minion    作者:henrymzhao    | 项目源码 | 文件源码
def em(self, ctx, *desc):
        """Make an embedded message
        Usage: em <body>
        Restricted command
        """
        author = ctx.message.author
        if author.permissions_in(ctx.message.channel).manage_channels or author.server_permissions.manage_channels:

            try:
                color = author.colour
            except Exception:
                color = discord.Colour(r.randrange(0xffffff))
            string = ""
            for w in desc:
                string += w + " "
            string = string.strip()
            embed = discord.Embed(description = string, color = color)
            #embed.set_thumbnail(url=author.avatar_url)
            embed.set_author(name=author.display_name, icon_url = author.avatar_url)
            await self.bot.say(embed = embed)
        try:
            await self.bot.delete_message(ctx.message)
        except Exception:
            #thats ok
            print("Not allowed to delete message")


    #@commands.command(pass_context = True)
    #async def allowedEmbed(self, ctx):
    #    #echoes permissions
    #    await self.bot.say(ctx.message.author.permissions_in(ctx.message.channel).manage_channels)