import nextcord
from nextcord.ext import commands

from events import ai

from userinfo import parsedinfo

class AICommands(commands.Cog):
    def __init__(self, bot):
        self.client = bot

    @commands.command(description="Clear your AI history")
    async def clear(self, ctx: nextcord.Message):
        user = await ai.find(ai.SquogData, "id", ctx.author.id)

        if not user:
            return await ctx.reply("You don't have any AI data.")
        else:
            userIndex = ai.SquogData.index(user)

            parsedinfo.parsed["guild"].remove(userIndex)

            await ai.flush()
            await ctx.reply("Cleared your AI data.")
        return None

def setup(bot):
    bot.add_cog(AICommands(bot))