bot.py 文件源码

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

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


问题


面经


文章

微信
公众号

扫码关注公众号