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