当前位置: 首页>>代码示例>>Python>>正文


Python discord.Colour方法代码示例

本文整理汇总了Python中discord.Colour方法的典型用法代码示例。如果您正苦于以下问题:Python discord.Colour方法的具体用法?Python discord.Colour怎么用?Python discord.Colour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord的用法示例。


在下文中一共展示了discord.Colour方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: challenge

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def challenge(self, ctx: Context, number: int = 1):
        """Show the provided challenge number."""
        challenge = await get_challenge(number)
        description = challenge["challenge"]
        if len(description) > 2048:
            description = description[:2045] + "..."
        embed = Embed(
            title=challenge["title"],
            colour=Colour(0xE5E242),
            url=f"https://www.kingsmathsschool.com/weekly-maths-challenge/{challenge['slug']}",
            description=description,
        )

        embed.set_image(url=challenge["image"])
        embed.set_thumbnail(
            url="https://pbs.twimg.com/profile_images/502115424121528320/hTQzj_-R.png"
        )
        embed.set_author(name="King's Maths School")
        embed.set_footer(
            text=f"Challenge Released: {challenge['published']} | Category: {challenge['category']}"
        )
        return await ctx.send(embed=embed) 
开发者ID:CyberDiscovery,项目名称:cyberdisc-bot,代码行数:24,代码来源:maths.py

示例2: __init__

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def __init__(self, **kwargs) -> None:
        default_kwargs = {
            'id': next(self.discord_id),
            'name': 'role',
            'position': 1,
            'colour': discord.Colour(0xdeadbf),
            'permissions': discord.Permissions(),
        }
        super().__init__(**collections.ChainMap(kwargs, default_kwargs))

        if isinstance(self.colour, int):
            self.colour = discord.Colour(self.colour)

        if isinstance(self.permissions, int):
            self.permissions = discord.Permissions(self.permissions)

        if 'mention' not in kwargs:
            self.mention = f'&{self.name}' 
开发者ID:python-discord,项目名称:bot,代码行数:20,代码来源:helpers.py

示例3: test_roles_command_command

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def test_roles_command_command(self):
        """Test if the `role_info` command correctly returns the `moderator_role`."""
        self.ctx.guild.roles.append(self.moderator_role)

        self.cog.roles_info.can_run = unittest.mock.AsyncMock()
        self.cog.roles_info.can_run.return_value = True

        coroutine = self.cog.roles_info.callback(self.cog, self.ctx)

        self.assertIsNone(asyncio.run(coroutine))
        self.ctx.send.assert_called_once()

        _, kwargs = self.ctx.send.call_args
        embed = kwargs.pop('embed')

        self.assertEqual(embed.title, "Role information (Total 1 role)")
        self.assertEqual(embed.colour, discord.Colour.blurple())
        self.assertEqual(embed.description, f"\n`{self.moderator_role.id}` - {self.moderator_role.mention}\n") 
开发者ID:python-discord,项目名称:bot,代码行数:20,代码来源:test_information.py

示例4: on_member_unban

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def on_member_unban(self, guild: discord.Guild, member: discord.User) -> None:
        """Log member unban event to mod log."""
        if guild.id != GuildConstant.id:
            return

        if member.id in self._ignored[Event.member_unban]:
            self._ignored[Event.member_unban].remove(member.id)
            return

        member_str = escape_markdown(str(member))
        await self.send_log_message(
            Icons.user_unban, Colour.blurple(),
            "User unbanned", f"{member_str} (`{member.id}`)",
            thumbnail=member.avatar_url_as(static_format="png"),
            channel_id=Channels.mod_log
        ) 
开发者ID:python-discord,项目名称:bot,代码行数:18,代码来源:modlog.py

示例5: convert

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def convert(self, ctx, argument):
        arg = argument.replace('0x', '').lower()

        if arg[0] == '#':
            arg = arg[1:]
        try:
            value = int(arg, base=16)
            if not (0 <= value <= 0xFFFFFF):
                raise BadArgument('Colour "{}" is invalid.'.format(arg))
            return discord.Colour(value=value)
        except ValueError:
            arg = arg.replace(' ', '_')
            method = getattr(discord.Colour, arg, None)
            if arg.startswith('from_') or method is None or not inspect.ismethod(method):
                raise BadArgument('Colour "{}" is invalid.'.format(arg))
            return method() 
开发者ID:Rapptz,项目名称:discord.py,代码行数:18,代码来源:converter.py

示例6: _life

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def _life(self, ctx, user: discord.Member=None):
        card_meaning = ["Past", "Present", "Future", "Potential", "Reason"]
        if user is None:
            user = ctx.message.author
        userseed = user.id
        
        random.seed(int(userseed))
        cards = []
        cards = sample((range(1, 78)), 5)
        
        embed = discord.Embed(title="Tarot reading for {}".format(user.display_name),
                              colour=discord.Colour(value=self.get_colour()))
        number = 0
        for card in cards:
            embed.add_field(name="{0}: {1}".format(card_meaning[number], self.tarot_cards[str(card)]["card_name"]),
                            value=self.tarot_cards[str(card)]["card_meaning"])
            number += 1
        await self.bot.send_message(ctx.message.channel, embed=embed) 
开发者ID:TrustyJAID,项目名称:Trusty-cogs-archive,代码行数:20,代码来源:tarot.py

示例7: _reading

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def _reading(self, ctx, user: discord.Member=None):
        card_meaning = ["Past", "Present", "Future", "Potential", "Reason"]
        if user is None:
            user = ctx.message.author
        
        cards = []
        cards = sample((range(1, 78)), 5)
        
        embed = discord.Embed(title="Tarot reading for {}".format(user.display_name),
                              colour=discord.Colour(value=self.get_colour()))
        number = 0
        for card in cards:
            embed.add_field(name="{0}: {1}".format(card_meaning[number], self.tarot_cards[str(card)]["card_name"]),
                            value=self.tarot_cards[str(card)]["card_meaning"])
            number += 1
        await self.bot.send_message(ctx.message.channel, embed=embed) 
开发者ID:TrustyJAID,项目名称:Trusty-cogs-archive,代码行数:18,代码来源:tarot.py

示例8: _card

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def _card(self, ctx, *, msg=None):
        user = ctx.message.author.id
        # msg = message.content
        card = None

        if msg is None:
            card = self.tarot_cards[str(random.randint(1, 78))]

        elif msg.isdigit() and int(msg) > 0 and int(msg) < 79:
            card = self.tarot_cards[str(msg)]
        
        elif not msg.isdigit():
            for cards in self.tarot_cards:
                if msg.lower() in self.tarot_cards[cards]["card_name"].lower():
                    card = self.tarot_cards[cards]
            if card is None:
                await self.bot.say("That card does not exist!")
                return

        embed = discord.Embed(title=card["card_name"],
                              description=card["card_meaning"],
                              colour=discord.Colour(value=self.get_colour()),
                              url=card["card_url"])
        embed.set_image(url=card["card_img"])
        await self.bot.send_message(ctx.message.channel, embed=embed) 
开发者ID:TrustyJAID,项目名称:Trusty-cogs-archive,代码行数:27,代码来源:tarot.py

示例9: get_user

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def get_user(self, ctx, username: str):
        """Get info about the specified user"""
        message = ""
        if username is not None:
            api = await self.authenticate()
            user = api.get_user(username)
            url = "https://twitter.com/" + user.screen_name
            emb = discord.Embed(title=user.name,
                                colour=discord.Colour(value=self.random_colour()),
                                url=url,
                                description=user.description)
            emb.set_thumbnail(url=user.profile_image_url)
            emb.add_field(name="Followers", value=user.followers_count)
            emb.add_field(name="Friends", value=user.friends_count)
            if user.verified:
                emb.add_field(name="Verified", value="Yes")
            else:
                emb.add_field(name="Verified", value="No")
            footer = "Created at " + user.created_at.strftime("%Y-%m-%d %H:%M:%S")
            emb.set_footer(text=footer)
            await self.bot.send_message(ctx.message.channel, embed=emb)
        else:
            message = "Uh oh, an error occurred somewhere!"
            await self.bot.say(message) 
开发者ID:TrustyJAID,项目名称:Trusty-cogs-archive,代码行数:26,代码来源:tweets.py

示例10: _list

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def _list(self, ctx):
        """Lists the autotweet accounts on the server"""
        account_list = ""
        server = ctx.message.server
        server_channels = [x.id for x in server.channels]
        for account in self.settings["accounts"]:
            for channel_id in self.settings["accounts"][account]["channel"]:
                if channel_id in server_channels:
                    account_list += self.settings["accounts"][account]["username"] + ", "
        if account_list != "":
            embed = discord.Embed(title="Twitter accounts posting in {}".format(server.name),
                                  colour=discord.Colour(value=self.random_colour()),
                                  description=account_list[:-2],
                                  timestamp=ctx.message.timestamp)
            embed.set_author(name=server.name, icon_url=server.icon_url)
            await self.bot.send_message(ctx.message.channel, embed=embed)
        else:
            await self.bot.send_message(ctx.message.channel, "I don't seem to have autotweets setup here!") 
开发者ID:TrustyJAID,项目名称:Trusty-cogs-archive,代码行数:20,代码来源:tweets.py

示例11: getcolour

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def getcolour(self, ctx, *, colour_codes):
        """Posts color of given hex"""
        await ctx.message.delete()
        colour_codes = colour_codes.split()
        size = (60, 80) if len(colour_codes) > 1 else (200, 200)
        if len(colour_codes) > 5:
            return await ctx.send(self.bot.bot_prefix + "Sorry, 5 colour codes maximum")
        for colour_code in colour_codes:
            if not colour_code.startswith("#"):
                colour_code = "#" + colour_code
            image = Image.new("RGB", size, colour_code)
            with io.BytesIO() as file:
                image.save(file, "PNG")
                file.seek(0)
                await ctx.send("Colour with hex code {}:".format(colour_code), file=discord.File(file, "colour_file.png"))
            await asyncio.sleep(1)  # Prevent spaminess 
开发者ID:appu1232,项目名称:Discord-Selfbot,代码行数:18,代码来源:utility.py

示例12: _colour

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
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) 
开发者ID:lehnification,项目名称:Discord-SelfBot,代码行数:20,代码来源:mod.py

示例13: process_command_invoke_error

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def process_command_invoke_error(self, ctx: context.NabCtx, error: commands.CommandInvokeError):
        """Handles CommandInvokeError.

        This exception is raised when an exception is raised during command execution."""
        error_name = error.original.__class__.__name__
        if isinstance(error.original, errors.NetworkError):
            log.error(f"{error_name} in command {ctx.clean_prefix}{ctx.command.qualified_name}: {error.original}")
            return await ctx.error("I'm having network issues right now. Please try again in a moment.")
        log.error(f"{self.tag} Exception in command: {ctx.message.clean_content}", exc_info=error.original)
        if isinstance(error.original, discord.HTTPException):
            await ctx.error("Sorry, the message was too long to send.")
        else:
            if ctx.bot_permissions.embed_links:
                embed = discord.Embed(colour=discord.Colour(0xff1414))
                embed.set_author(name="Support Server", url="https://discord.gg/NmDvhpY",
                                 icon_url=self.bot.user.avatar_url)
                embed.set_footer(text="Please report this bug in the support server.")
                embed.add_field(name=f"{ctx.tick(False)}Command Error",
                                value=f"```py\n{error_name}: {error.original}```",
                                inline=False)
                await ctx.send(embed=embed)
            else:
                await ctx.error(f'Command error:\n```py\n{error_name}: {error.original}```') 
开发者ID:NabDev,项目名称:NabBot,代码行数:25,代码来源:core.py

示例14: get_item_embed_adjust_city

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def get_item_embed_adjust_city(cls, name, city, embed):
        name = name.lower()
        if name == 'alesar' or name == 'yaman':
            embed.colour = discord.Colour.green()
            return "Green Djinn's Fortress"
        elif name == "nah'bob" or name == "haroun":
            embed.colour = discord.Colour.blue()
            return "Blue Djinn's Fortress"
        elif name == 'rashid':
            embed.colour = discord.Colour(0xF0E916)
            return cls.get_rashid_position().city
        elif name == 'yasir':
            return 'his boat'
        elif name == 'briasol':
            embed.colour = discord.Colour(0xA958C4)
        return city 
开发者ID:NabDev,项目名称:NabBot,代码行数:18,代码来源:tibiawiki.py

示例15: banner

# 需要导入模块: import discord [as 别名]
# 或者: from discord import Colour [as 别名]
def banner(
        self, ctx: commands.Context, colour: Optional[discord.Colour] = (255, 0, 0), *, text: str
    ) -> None:
        """
            Generate a scrolling text gif banner
        """
        if isinstance(colour, discord.Colour):
            colour = colour.to_rgb() + (0,)
        async with ctx.channel.typing():
            task = functools.partial(self.make_banner, text=text, colour=colour)
            task = ctx.bot.loop.run_in_executor(None, task)
            try:
                image = await asyncio.wait_for(task, timeout=60)
            except asyncio.TimeoutError:
                return
            file = discord.File(image)
            await ctx.send(files=[file]) 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:19,代码来源:imagemaker.py


注:本文中的discord.Colour方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。