From 677b645e444eafeecc03784f0e5d7d00848665c6 Mon Sep 17 00:00:00 2001 From: Choco <94597336+ChocoMeow@users.noreply.github.com> Date: Sat, 18 Feb 2023 20:14:32 +0800 Subject: [PATCH] Flx some bugs --- function.py | 14 ++++++++------ main.py | 6 +++--- update.py | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/function.py b/function.py index 3a1887a..36f5d8f 100644 --- a/function.py +++ b/function.py @@ -12,7 +12,9 @@ from io import BytesIO from pymongo import MongoClient from typing import Optional -if not os.path.exists("./settings.json"): +root_dir = os.path.dirname(__file__) + +if not os.path.exists(root_dir + "/settings.json"): print("Error: Settings file not set!") exit() @@ -79,23 +81,23 @@ def update_settings(guildid:int, data, mode="Set"): return def langs_setup(): - for language in os.listdir('./langs'): + for language in os.listdir(root_dir + './langs'): if language.endswith('.json'): - with open(f'./langs/{language}', encoding="utf8") as json_file: + with open(f'{root_dir}/langs/{language}', encoding="utf8") as json_file: lang = json.load(json_file) langs[language[:-5]] = lang - for language in os.listdir('./local_langs'): + for language in os.listdir(root_dir + './local_langs'): if language.endswith('.json'): - with open(f'./local_langs/{language}', encoding="utf8") as json_file: + with open(f'{root_dir}/local_langs/{language}', encoding="utf8") as json_file: lang = json.load(json_file) local_langs[language[:-5]] = lang return def settings_setup(): - with open('./settings.json', encoding="utf8") as json_file: + with open(root_dir + '/settings.json', encoding="utf8") as json_file: rawSettings = json.load(json_file) global nodes, embed_color, bot_access_user, emoji_source_raw, bot_prefix, max_queue, cooldowns_settings, aliases_settings diff --git a/main.py b/main.py index 27ae058..b1c3a43 100644 --- a/main.py +++ b/main.py @@ -19,8 +19,8 @@ class Translator(discord.app_commands.Translator): print("Unload Translator") async def translate(self, string: discord.app_commands.locale_str, locale: discord.Locale, context: discord.app_commands.TranslationContext): - if str(locale) in local_langs: - return local_langs[str(locale)].get(string.message, None) + if str(locale) in function.local_langs: + return function.local_langs[str(locale)].get(string.message, None) return None class Vocard(commands.Bot): @@ -36,7 +36,7 @@ class Vocard(commands.Bot): async def setup_hook(self): function.langs_setup() - for module in os.listdir('./cogs'): + for module in os.listdir(function.root_dir + '/cogs'): if module.endswith('.py'): try: await self.load_extension(f"cogs.{module[:-3]}") diff --git a/update.py b/update.py index e0fb528..c5f9bca 100644 --- a/update.py +++ b/update.py @@ -3,7 +3,7 @@ from io import BytesIO root_dir = __file__.replace("update.py", "") filename = root_dir + "Vocard.zip" -__version__ = "v2.5.3" +__version__ = "v2.5.4" def checkVersion(withMsg = False): resp = requests.get("https://api.github.com/repos/ChocoMeow/Vocard/releases/latest") @@ -12,7 +12,7 @@ def checkVersion(withMsg = False): if version == __version__: print(f"Your bot is up-to-date! - {version}") else: - print(f"Your bot is not up-to-date! This latest version is {version} and you are currently running version {__version__}\n. Run `python update --start` to update your bot!") + print(f"Your bot is not up-to-date! This latest version is {version} and you are currently running version {__version__}\n. Run `python update.py --start` to update your bot!") return version def downloadFile(version:str = None):