cogs/theme/management.py
async def save_theme(self, ctx, *, name=""):
        """Save the current state of the guilds colors"""
        colors, themes = db.get_many(ctx.guild.id, "colors", "themes")

        if not colors:
            raise CommandError("There must be colors to save a theme")

        if len(themes) >= cfg.theme_limit:
            raise CommandError(f"Theme Limit Reached ({len(themes)}/10)")

        # Verufy name
        if "|" in name or len(name) >= 100:
            raise UserInputError(
                "Color names must be shorter than 100 characters and cannot include `|`")

        if not name:
            name = f"Theme {len(themes) + 1}"

        # Remove unnecessary role attribute from database
        for color in colors:
            del color["role"]

        # create and add color
        new_theme = {
            "name": name,
            "colors": colors,
        }

        # update database
        db.guilds.update_one(
            {"_id": ctx.guild.id},
            {"$push": {"themes": new_theme}}
        )
        await ctx.invoke(self.bot.get_command("themes"))
Save the current state of the guilds colors
Save the current state of the guilds colors
Save the current state of the guilds colors
async def save_theme(self, ctx, *, name=""):
        colors, themes = db.get_many(ctx.guild.id, "colors", "themes")
        if not colors:
            raise CommandError("There must be colors to save a theme")
        if len(themes) >= cfg.theme_limit:
            raise CommandError(f"Theme Limit Reached ({len(themes)}/10)")
        if "|" in name or len(name) >= 100:
            raise UserInputError(
                "Color names must be shorter than 100 characters and cannot include `|`")
        if not name:
            name = f"Theme {len(themes) + 1}"
        for color in colors:
            del color["role"]
        new_theme = {
            "name": name,
            "colors": colors,
        }
        db.guilds.update_one(
            {"_id": ctx.guild.id},
            {"$push": {"themes": new_theme}}
        )
        await ctx.invoke(self.bot.get_command("themes"))
async def save_theme ( self , ctx , * , name = "" ) : colors , themes = db . get_many ( ctx . guild . id , "colors" , "themes" ) if not colors : raise CommandError ( "There must be colors to save a theme" ) if len ( themes ) >= cfg . theme_limit : raise CommandError ( f"Theme Limit Reached ({len(themes)}/10)" ) if "|" in name or len ( name ) >= 100 : raise UserInputError ( "Color names must be shorter than 100 characters and cannot include `|`" ) if not name : name = f"Theme {len(themes) + 1}" for color in colors : del color [ "role" ] new_theme = { "name" : name , "colors" : colors , } db . guilds . update_one ( { "_id" : ctx . guild . id } , { "$push" : { "themes" : new_theme } } ) await ctx . invoke ( self . bot . get_command ( "themes" ) )
Save the current state of the guilds colors
Save the current state of the guilds colors
"""Save the current state of the guilds colors""" # Verufy name # Remove unnecessary role attribute from database # create and add color # update database
self
ctx
name