diff --git a/.env Example b/.env Example deleted file mode 100644 index e61ca82..0000000 --- a/.env Example +++ /dev/null @@ -1,12 +0,0 @@ -TOKEN = YOUR_BOT_TOKEN -CLIENT_ID = YOUR_BOT_CLIENT_ID -CLIENT_SECRET_ID = YOUR_BOT_CLIENT_SECRET_ID -SERCET_KEY = DASHBOARD_SERCET_KEY - -SPOTIFY_CLIENT_ID = YOUR_SPOTIFY_CLIENT_ID -SPOTIFY_CLIENT_SECRET = YOUR_SPOTIFY_CLIENT_SECRET - -GENIUS_TOKEN = YOUR_GENIUS_TOKEN - -MONGODB_URL = YOUR_MONGODB_URL -MONGODB_NAME = YOUR_MONGODB_DB_NAME diff --git a/addons/__init__.py b/addons/__init__.py index a19a379..a835660 100644 --- a/addons/__init__.py +++ b/addons/__init__.py @@ -1,3 +1,3 @@ from .lyrics import lyricsPlatform from .placeholders import Placeholders -from .settings import Settings, TOKENS \ No newline at end of file +from .settings import Settings \ No newline at end of file diff --git a/addons/lyrics.py b/addons/lyrics.py index d4edc4b..34de9f9 100644 --- a/addons/lyrics.py +++ b/addons/lyrics.py @@ -173,7 +173,7 @@ class A_ZLyrics(LyricsPlatform): class Genius(LyricsPlatform): def __init__(self) -> None: self.module = import_module("lyricsgenius") - self.genius = self.module.Genius(func.tokens.genius_token) + self.genius = self.module.Genius(func.settings.genius_token) async def get_lyrics(self, title: str, artist: str) -> Optional[dict[str, str]]: song = self.genius.search_song(title=title, artist=artist) diff --git a/addons/settings.py b/addons/settings.py index 0f2d876..0937fe3 100644 --- a/addons/settings.py +++ b/addons/settings.py @@ -1,6 +1,3 @@ -import os - -from dotenv import load_dotenv from typing import ( Dict, List, @@ -10,6 +7,14 @@ from typing import ( class Settings: def __init__(self, settings: Dict) -> None: + self.token: str = settings.get("token") + self.client_id: int = int(settings.get("client_id", 0)) + self.spotify_client_id: str = settings.get("spotify_client_id") + self.spotify_client_secret: str = settings.get("spotify_client_secret") + self.genius_token: str = settings.get("genius_token") + self.mongodb_url: str = settings.get("mongodb_url") + self.mongodb_name: str = settings.get("mongodb_name") + self.invite_link: str = "https://discord.gg/wRCgB7vBQv" self.nodes: Dict[str, Dict[str, Union[str, int, bool]]] = settings.get("nodes", {}) self.max_queue: int = settings.get("default_max_queue", 1000) @@ -23,19 +28,5 @@ class Settings: self.aliases_settings: Dict[str, List[str]] = settings.get("aliases", {}) self.controller: Dict[str, Dict[str, Any]] = settings.get("default_controller", {}) self.lyrics_platform: str = settings.get("lyrics_platform", "A_ZLyrics").lower() - self.ipc_server: Dict[str, Union[str, bool, int]] = settings.get("ipc_server", {}) - self.version: str = settings.get("version", "") - -class TOKENS: - def __init__(self) -> None: - load_dotenv() - - self.token = os.getenv("TOKEN") - self.client_id = os.getenv("CLIENT_ID") - self.client_secret_id = os.getenv("CLIENT_SECRET_ID") - self.sercet_key = os.getenv("SERCET_KEY") - self.spotify_client_id = os.getenv("SPOTIFY_CLIENT_ID") - self.spotify_client_secret = os.getenv("SPOTIFY_CLIENT_SECRET") - self.genius_token = os.getenv("GENIUS_TOKEN") - self.mongodb_url = os.getenv("MONGODB_URL") - self.mongodb_name = os.getenv("MONGODB_NAME") \ No newline at end of file + self.ipc_client: Dict[str, Union[str, bool, int]] = settings.get("ipc_client", {}) + self.version: str = settings.get("version", "") \ No newline at end of file diff --git a/cogs/listeners.py b/cogs/listeners.py index 55c2bb2..ca76f55 100644 --- a/cogs/listeners.py +++ b/cogs/listeners.py @@ -44,8 +44,8 @@ class Listeners(commands.Cog): try: await self.voicelink.create_node( bot=self.bot, - spotify_client_id=func.tokens.spotify_client_id, - spotify_client_secret=func.tokens.spotify_client_secret, + spotify_client_id=func.settings.spotify_client_id, + spotify_client_secret=func.settings.spotify_client_secret, logger=func.logger, **n ) diff --git a/function.py b/function.py index 74a78ca..458daf2 100644 --- a/function.py +++ b/function.py @@ -2,7 +2,7 @@ import discord, json, os, copy, logging from discord.ext import commands from time import strptime -from addons import Settings, TOKENS +from addons import Settings from typing import ( Optional, @@ -22,7 +22,6 @@ if not os.path.exists(os.path.join(ROOT_DIR, "settings.json")): raise Exception("Settings file not set!") #--------------- Cache Var --------------- -tokens: TOKENS = TOKENS() settings: Settings logger: logging.Logger = logging.getLogger("vocard") diff --git a/main.py b/main.py index 4a5b53e..92a8dfe 100644 --- a/main.py +++ b/main.py @@ -97,7 +97,7 @@ class Vocard(commands.Bot): func.logger.info(f"Python Version: {sys.version}") func.logger.info("------------------") - func.tokens.client_id = self.user.id + func.settings.client_id = self.user.id func.LOCAL_LANGS.clear() async def on_command_error(self, ctx: commands.Context, exception, /) -> None: @@ -138,8 +138,8 @@ class CommandCheck(discord.app_commands.CommandTree): await interaction.response.send_message("This command can only be used in guilds!") return False - return await super().interaction_check(interaction) - + return True + async def get_prefix(bot, message: discord.Message): settings = await func.get_settings(message.guild.id) return settings.get("prefix", func.settings.bot_prefix) @@ -166,7 +166,7 @@ if (LOG_FILE := LOG_SETTINGS.get("file", {})).get("enable", True): # Setup the bot object intents = discord.Intents.default() intents.message_content = True if func.settings.bot_prefix else False -intents.members = func.settings.ipc_server.get("enable", False) +intents.members = func.settings.ipc_client.get("enable", False) intents.voice_states = True member_cache = discord.MemberCacheFlags( voice=True, @@ -186,4 +186,4 @@ bot = Vocard( if __name__ == "__main__": update.check_version(with_msg=True) - bot.run(func.tokens.token, root_logger=True) \ No newline at end of file + bot.run(func.settings.token, root_logger=True) \ No newline at end of file diff --git a/settings Example.json b/settings Example.json index 98f7af7..2b1be9f 100644 --- a/settings Example.json +++ b/settings Example.json @@ -1,4 +1,11 @@ { + "token": "YOUR_BOT_TOKEN", + "client_id": "YOUR_BOT_CLIENT_ID", + "spotify_client_id": "YOUR_SPOTIFY_CLIENT_ID", + "spotify_client_secret": "YOUR_SPOTIFY_CLIENT_SECRET", + "genius_token": "YOUR_GENIUS_TOKEN", + "mongodb_url": "YOUR_MONGODB_URL", + "mongodb_name": "YOUR_MONGODB_DB_NAME", "nodes": { "DEFAULT": { "host": "127.0.0.1", @@ -9,7 +16,7 @@ } }, "prefix": "?", - "activity":[ + "activity": [ {"type": "listening", "name": "/help", "status": "online"} ], "logging": { @@ -19,15 +26,17 @@ }, "level": { "discord": "INFO", - "vocard": "INFO" + "vocard": "INFO", + "ipc_client": "INFO" }, "max-history": 30 }, "bot_access_user": [], "embed_color":"0xb3b3b3", "default_max_queue": 1000, - "lyrics_platform": "A_ZLyrics", + "lyrics_platform": "lyrist", "ipc_server": { + "sercet_key": "YOUR_PASSWORD", "host": "127.0.0.1", "port": 8000, "enable": false