python类Colour()的实例源码

Announcer.py 文件源码 项目:youtube 作者: FishyFing 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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))
Roles.py 文件源码 项目:Sparcli 作者: 4Kaylum 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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))
client_helpers.py 文件源码 项目:randi 作者: nhatzHK 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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
Messages.py 文件源码 项目:paobot-Release 作者: cjoeml 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)
levels.py 文件源码 项目:csss-minion 作者: henrymzhao 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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)
roullette.py 文件源码 项目:csss-minion 作者: henrymzhao 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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)
info.py 文件源码 项目:csss-minion 作者: henrymzhao 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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)
announce.py 文件源码 项目:csss-minion 作者: henrymzhao 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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")
modtools.py 文件源码 项目:csss-minion 作者: henrymzhao 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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")
rng.py 文件源码 项目:Chiaki-Nanami 作者: Ikusaba-san 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
rng.py 文件源码 项目:Chiaki-Nanami 作者: Ikusaba-san 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
mod.py 文件源码 项目:Shallus-Bot 作者: cgropp 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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.")
pogoteams.py 文件源码 项目:bursting-cogs 作者: Repulser 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
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))
pogoteams.py 文件源码 项目:bursting-cogs 作者: Repulser 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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))
pogoteams.py 文件源码 项目:bursting-cogs 作者: Repulser 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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))
welcomer.py 文件源码 项目:bursting-cogs 作者: Repulser 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
welcomer.py 文件源码 项目:bursting-cogs 作者: Repulser 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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))
pogoservers.py 文件源码 项目:bursting-cogs 作者: Repulser 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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)
mod.py 文件源码 项目:LunaBot 作者: miraai 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
utils.py 文件源码 项目:GAFBot 作者: DiNitride 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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
utils.py 文件源码 项目:GAFBot 作者: DiNitride 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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)
utils.py 文件源码 项目:GAFBot 作者: DiNitride 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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)
bot.py 文件源码 项目:ModTools 作者: MattBSG 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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))
admin.py 文件源码 项目:Asurix-bot 作者: Beafantles 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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
mod.py 文件源码 项目:Discord-SelfBot 作者: IgneelDxD 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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)
mod.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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.")
embedsay.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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")
embedsay.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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")
embedsay.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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")
embedsay.py 文件源码 项目:KeekoBot 作者: DavidNeon 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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")


问题


面经


文章

微信
公众号

扫码关注公众号