Use discord.py instead of Hikari so we can use user commands

This commit is contained in:
2024-12-30 01:38:56 +01:00
parent e27d043e2c
commit 0c20e496c1
5 changed files with 160 additions and 137 deletions

29
settings.py Normal file
View File

@ -0,0 +1,29 @@
from __future__ import annotations
import os
from dataclasses import dataclass
from functools import lru_cache
from dotenv import load_dotenv
load_dotenv(verbose=True)
@dataclass
class Settings:
"""Class to hold settings for the bot."""
discord_token: str
openai_api_key: str
@classmethod
@lru_cache(maxsize=1)
def from_env(cls) -> Settings:
"""Create a new instance of the class from environment variables.
Returns:
A new instance of the class with the settings.
"""
discord_token: str = os.getenv("DISCORD_TOKEN", "")
openai_api_key: str = os.getenv("OPENAI_TOKEN", "")
return cls(discord_token, openai_api_key)