This commit is contained in:
Paillat
2022-11-27 20:54:36 +01:00
parent 668fcbff59
commit 5db0ea9ee0

View File

@@ -39,13 +39,18 @@ async def setup(ctx, channel: discord.TextChannel, api_key):
return
#check if the guild is already in the database bi checking if there is a key for the guild
c.execute("SELECT * FROM data WHERE guild_id = ?", (ctx.guild.id,))
if c.fetchone()[2] is not None:
await ctx.respond("This guild is already setup", ephemeral=True)
return
#add the guild to the database
c.execute("INSERT INTO data VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (ctx.guild.id, channel.id, api_key, False, 150, 1, 0, 0.6, 0, 5))
conn.commit()
await ctx.respond("Setup complete", ephemeral=True)
if c.fetchone() is not None:
#in this case, the guild is already in the database, so we update the channel id and the api key
c.execute("UPDATE data SET channel_id = ?, api_key = ? WHERE guild_id = ?", (channel.id, api_key, ctx.guild.id))
#we will also set the advanced settings to their default values
c.execute("UPDATE data SET is_active = ?, max_tokens = ?, temperature = ?, frequency_penalty = ?, presence_penalty = ?, uses_count_today = ?, prompt_size = ? WHERE guild_id = ?", (False, 64, 0.9, 0.0, 0.0, 0, 5, ctx.guild.id))
conn.commit()
await ctx.respond("The channel id and the api key have been updated", ephemeral=True)
else:
#in this case, the guild is not in the database, so we add it
c.execute("INSERT INTO data VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (ctx.guild.id, channel.id, api_key, False, 64, 0.9, 0.0, 0.0, 0, 5))
conn.commit()
await ctx.respond("The channel id and the api key have been added", ephemeral=True)
#create a command called "enable" taht only admins can use
@bot.command()
##@discord.commands.permissions(administrator=True)