Format with black

This commit is contained in:
2023-07-18 17:51:13 +02:00
parent 4b192f779e
commit 12f13ca6c4
14 changed files with 424 additions and 241 deletions

View File

@@ -3,4 +3,4 @@ from src.cogs.settings import Settings
from src.cogs.help import Help
from src.cogs.chat import Chat
from src.cogs.manage_chat import ManageChat
from src.cogs.moderation import Moderation
from src.cogs.moderation import Moderation

View File

@@ -1,5 +1,6 @@
import discord
class Help(discord.Cog):
def __init__(self, bot: discord.Bot) -> None:
super().__init__()

View File

@@ -32,12 +32,18 @@ class Settings(discord.Cog):
presence_penalty: float = None,
prompt_size: int = None,
):
await ctx.respond("This command has been deprecated since the new model does not need theese settungs to work well", ephemeral=True)
await ctx.respond(
"This command has been deprecated since the new model does not need theese settungs to work well",
ephemeral=True,
)
@discord.slash_command(name="default", description="Default settings")
@default_permissions(administrator=True)
async def default(self, ctx: discord.ApplicationContext):
await ctx.respond("This command has been deprecated since the new model does not need theese settungs to work well", ephemeral=True)
await ctx.respond(
"This command has been deprecated since the new model does not need theese settungs to work well",
ephemeral=True,
)
@discord.slash_command(name="prompt_size", description="Set the prompt size")
@default_permissions(administrator=True)
@@ -45,10 +51,12 @@ class Settings(discord.Cog):
async def prompt_size(
self, ctx: discord.ApplicationContext, prompt_size: int = None
):
#only command that is not deprecated
# only command that is not deprecated
# check if the guild is in the database
try:
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),))
curs_data.execute(
"SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),)
)
data = curs_data.fetchone()
except:
data = None
@@ -60,11 +68,14 @@ class Settings(discord.Cog):
await ctx.respond("You must specify a prompt size", ephemeral=True)
return
if prompt_size < 1 or prompt_size > 15:
await ctx.respond("The prompt size must be between 1 and 15", ephemeral=True)
await ctx.respond(
"The prompt size must be between 1 and 15", ephemeral=True
)
return
# update the prompt size
curs_data.execute(
"UPDATE data SET prompt_size = ? WHERE guild_id = ?", (prompt_size, ctx_to_guid(ctx))
"UPDATE data SET prompt_size = ? WHERE guild_id = ?",
(prompt_size, ctx_to_guid(ctx)),
)
con_data.commit()
await ctx.respond(f"Prompt size set to {prompt_size}", ephemeral=True)
@@ -78,7 +89,9 @@ class Settings(discord.Cog):
# this command sends all the data about the guild, including the api key, the channel id, the advanced settings and the uses_count_today
# check if the guild is in the database
try:
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),))
curs_data.execute(
"SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),)
)
data = curs_data.fetchone()
except:
data = None
@@ -86,7 +99,9 @@ class Settings(discord.Cog):
await ctx.respond("This server is not setup", ephemeral=True)
return
try:
curs_data.execute("SELECT * FROM model WHERE guild_id = ?", (ctx_to_guid(ctx),))
curs_data.execute(
"SELECT * FROM model WHERE guild_id = ?", (ctx_to_guid(ctx),)
)
model = curs_data.fetchone()[1]
except:
model = None
@@ -108,7 +123,9 @@ class Settings(discord.Cog):
@default_permissions(administrator=True)
async def prefix(self, ctx: discord.ApplicationContext, prefix: str = ""):
try:
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),))
curs_data.execute(
"SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),)
)
data = curs_data.fetchone()
api_key = data[2]
except:
@@ -145,7 +162,9 @@ class Settings(discord.Cog):
async def pretend(self, ctx: discord.ApplicationContext, pretend_to_be: str = ""):
# check if the guild is in the database
try:
curs_data.execute("SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),))
curs_data.execute(
"SELECT * FROM data WHERE guild_id = ?", (ctx_to_guid(ctx),)
)
data = curs_data.fetchone()
api_key = data[2]
except:
@@ -229,7 +248,10 @@ class Settings(discord.Cog):
)
@default_permissions(administrator=True)
async def model(self, ctx: discord.ApplicationContext, model: str = "davinci"):
await ctx.respond("This command has been deprecated. Model gpt-3.5-turbo is always used by default", ephemeral=True)
await ctx.respond(
"This command has been deprecated. Model gpt-3.5-turbo is always used by default",
ephemeral=True,
)
async def images_recognition_autocomplete(ctx: discord.AutocompleteContext):
return [state for state in images_recognition if state.startswith(ctx.value)]
@@ -257,7 +279,8 @@ class Settings(discord.Cog):
enable_disable = 0
if data is None:
curs_data.execute(
"INSERT INTO images VALUES (?, ?, ?)", (ctx_to_guid(ctx), 0, enable_disable)
"INSERT INTO images VALUES (?, ?, ?)",
(ctx_to_guid(ctx), 0, enable_disable),
)
else:
curs_data.execute(

View File

@@ -1,18 +1,29 @@
import discord
from discord import default_permissions, guild_only
from discord.ext import commands
from src.config import debug, con_data, curs_data, con_premium, curs_premium, ctx_to_guid
from src.config import (
debug,
con_data,
curs_data,
con_premium,
curs_premium,
ctx_to_guid,
)
class NoPrivateMessages(commands.CheckFailure):
pass
def dms_only():
async def predicate(ctx):
if ctx.guild is not None:
raise NoPrivateMessages('Hey no private messages!')
raise NoPrivateMessages("Hey no private messages!")
return True
return commands.check(predicate)
class Setup(discord.Cog):
def __init__(self, bot: discord.Bot):
super().__init__()
@@ -74,6 +85,7 @@ class Setup(discord.Cog):
await ctx.respond(
"The channel id and the api key have been added", ephemeral=True
)
@discord.slash_command(name="setup_dms", description="Setup the bot in dms")
@discord.option(name="api_key", description="The api key", required=True)
@default_permissions(administrator=True)
@@ -125,9 +137,7 @@ class Setup(discord.Cog):
),
)
con_data.commit()
await ctx.respond(
"The api key has been added", ephemeral=True
)
await ctx.respond("The api key has been added", ephemeral=True)
@discord.slash_command(
name="delete", description="Delete the information about this server"
@@ -173,7 +183,8 @@ class Setup(discord.Cog):
return
# disable the guild
curs_data.execute(
"UPDATE data SET is_active = ? WHERE guild_id = ?", (False, ctx_to_guid(ctx))
"UPDATE data SET is_active = ? WHERE guild_id = ?",
(False, ctx_to_guid(ctx)),
)
con_data.commit()
await ctx.respond("Disabled", ephemeral=True)