mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 09:16:19 +00:00
🐛 fix(main.py): handle on_application_command_error with proper error handling and response
✨ feat(main.py): add ChatProcess module for handling chat-related functionality 🔧 refactor(main.py): import necessary modules and update bot.add_cog calls 🔧 refactor(server.ts): change port variable case from lowercase port to uppercase PORT to improve semantics ✨ feat(server.ts): add support for process.env.PORT environment variable to be able to run app on a configurable port 🔧 refactor(cogs/__init__.py): import ChannelSetup cog ✨ feat(cogs/channelSetup.py): add ChannelSetup cog for setting up channels and server-wide settings 🔧 refactor(cogs/setup.py): import SlashCommandGroup and guild_only from discord module ✨ feat(cogs/setup.py): add setup_channel command for adding and removing channels ✨ feat(cogs/setup.py): add api command for setting API keys ✨ feat(cogs/setup.py): add premium command for setting guild to premium 🔧 refactor(cogs/settings.py): temporarily disable images command due to maintenance 🔧 refactor(config.py): remove unnecessary code related to moderation table ✨ feat(guild.py): add Guild class for managing guild-specific data and settings ✨ feat(SqlConnector.py): add SQLConnection and _sql classes for managing SQLite connections ✨ feat(variousclasses.py): add models, characters, and apis classes for autocomplete functionality in slash commands
This commit is contained in:
26
src/utils/SqlConnector.py
Normal file
26
src/utils/SqlConnector.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from sqlite3 import connect
|
||||
from random import randint
|
||||
|
||||
|
||||
class SQLConnection:
|
||||
|
||||
def __init__(self,connection):
|
||||
self.connection = connection
|
||||
|
||||
def __enter__(self):
|
||||
return self.connection
|
||||
|
||||
def __exit__(self,exc_type,exc_val,exc_tb):
|
||||
self.connection.commit()
|
||||
self.connection.close()
|
||||
|
||||
|
||||
class _sql:
|
||||
|
||||
@property
|
||||
def mainDb(self):
|
||||
s = connect('./database/data.db')
|
||||
return SQLConnection(s)
|
||||
|
||||
|
||||
sql: _sql = _sql()
|
||||
37
src/utils/variousclasses.py
Normal file
37
src/utils/variousclasses.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from discord import AutocompleteContext
|
||||
|
||||
class models:
|
||||
matchingDict = {
|
||||
"chatGPT (default - free)": "gpt-3.5-turbo",
|
||||
"davinci (premium)": "text-davinci-003",
|
||||
"llama (premium)": "text-llama",
|
||||
"llama 2 (premium)": "text-llama-2",
|
||||
}
|
||||
reverseMatchingDict = {v: k for k, v in matchingDict.items()}
|
||||
default = list(matchingDict.keys())[0]
|
||||
openaimodels = ["gpt-3.5-turbo", "text-davinci-003"]
|
||||
@classmethod
|
||||
async def autocomplete(cls, ctx: AutocompleteContext) -> list[str]:
|
||||
modls = cls.matchingDict.keys()
|
||||
return [model for model in modls if model.find(ctx.value.lower()) != -1]
|
||||
|
||||
class characters:
|
||||
matchingDict = {
|
||||
"Botator (default - free)": "botator",
|
||||
"Aurora (premium)": "aurora",
|
||||
}
|
||||
reverseMatchingDict = {v: k for k, v in matchingDict.items()}
|
||||
default = list(matchingDict.keys())[0]
|
||||
@classmethod
|
||||
async def autocomplete(cls, ctx: AutocompleteContext) -> list[str]:
|
||||
chars = characters = cls.matchingDict.keys()
|
||||
return [character for character in chars if character.find(ctx.value.lower()) != -1]
|
||||
|
||||
class apis:
|
||||
matchingDict = {
|
||||
"OpenAI": "openai",
|
||||
}
|
||||
@classmethod
|
||||
async def autocomplete(cls, ctx: AutocompleteContext) -> list[str]:
|
||||
apiss = cls.matchingDict.keys()
|
||||
return [api for api in apiss if api.find(ctx.value.lower()) != -1]
|
||||
Reference in New Issue
Block a user