utils.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目: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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号