cogs/color/management.py
async def recolor(self, ctx, *, query):
        """Change the way a color looks."""
        colors = db.get(ctx.guild.id, "colors")

        try:
            before, after = query.split("|")
        except ValueError:
            raise UserInputError(
                "Command should be formatted as: $rename <color> | <hexcode>")

        # Find the correct color to remove. or dont.
        color = utils.color_lookup(before.strip(), colors)
        if not color:
            raise UserInputError("Couldn't find that color")

        after = after.strip()
        if not utils.validate_hex(after):
            raise UserInputError(
                "Invalid hexcode. Get help at https://htmlcolorcodes.com/")

        # adjust roles if color is changed
        if color["role"]:
            role = ctx.guild.get_role(color["role"])
            new_color = utils.to_rgb(after)
            await role.edit(color=discord.Color.from_rgb(*new_color))

        # update database
        db.guilds.update_one(
            {"_id": ctx.guild.id, "colors": color},
            {"$set": {"colors.$.hexcode": after}}
        )

        await ctx.invoke(bot.get_command("colors"))
Change the way a color looks.
Change the way a color looks.
Change the way a color looks .
async def recolor(self, ctx, *, query):
        colors = db.get(ctx.guild.id, "colors")
        try:
            before, after = query.split("|")
        except ValueError:
            raise UserInputError(
                "Command should be formatted as: $rename <color> | <hexcode>")
        color = utils.color_lookup(before.strip(), colors)
        if not color:
            raise UserInputError("Couldn't find that color")
        after = after.strip()
        if not utils.validate_hex(after):
            raise UserInputError(
                "Invalid hexcode. Get help at https://htmlcolorcodes.com/")
        if color["role"]:
            role = ctx.guild.get_role(color["role"])
            new_color = utils.to_rgb(after)
            await role.edit(color=discord.Color.from_rgb(*new_color))
        db.guilds.update_one(
            {"_id": ctx.guild.id, "colors": color},
            {"$set": {"colors.$.hexcode": after}}
        )
        await ctx.invoke(bot.get_command("colors"))
async def recolor ( self , ctx , * , query ) : colors = db . get ( ctx . guild . id , "colors" ) try : before , after = query . split ( "|" ) except ValueError : raise UserInputError ( "Command should be formatted as: $rename <color> | <hexcode>" ) color = utils . color_lookup ( before . strip ( ) , colors ) if not color : raise UserInputError ( "Couldn't find that color" ) after = after . strip ( ) if not utils . validate_hex ( after ) : raise UserInputError ( "Invalid hexcode. Get help at https://htmlcolorcodes.com/" ) if color [ "role" ] : role = ctx . guild . get_role ( color [ "role" ] ) new_color = utils . to_rgb ( after ) await role . edit ( color = discord . Color . from_rgb ( * new_color ) ) db . guilds . update_one ( { "_id" : ctx . guild . id , "colors" : color } , { "$set" : { "colors.$.hexcode" : after } } ) await ctx . invoke ( bot . get_command ( "colors" ) )
Change the way a color looks.
Change the way a color looks .
"""Change the way a color looks.""" # Find the correct color to remove. or dont. # adjust roles if color is changed # update database
self
ctx
query