From fd869d6209a18aecc2003fc22ae8e93ca8f2f6f8 Mon Sep 17 00:00:00 2001 From: Choco <94597336+ChocoMeow@users.noreply.github.com> Date: Fri, 22 Mar 2024 11:30:01 +0800 Subject: [PATCH] Renamed a valuable --- function.py | 14 ++++++++++---- main.py | 6 ++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/function.py b/function.py index 1071603..1f574c3 100644 --- a/function.py +++ b/function.py @@ -2,9 +2,15 @@ import discord, json, os, copy, logging from discord.ext import commands from time import strptime -from typing import Optional, Union, Dict, Any from addons import Settings, TOKENS +from typing import ( + Optional, + Union, + Dict, + Any +) + from motor.motor_asyncio import ( AsyncIOMotorClient, AsyncIOMotorCollection, @@ -29,7 +35,7 @@ LOCAL_LANGS: dict[str, dict[str, str]] = {} #Stores all the localization languag SETTINGS_BUFFER: dict[int, dict[str, Any]] = {} #Cache guild language USERS_BUFFER: dict[str, dict] = {} -USERS_BASE: dict[str, Any] = { +USER_BASE: dict[str, Any] = { 'playlist': { '200': { 'tracks':[], @@ -208,13 +214,13 @@ async def get_user(user_id: int, d_type: Optional[str] = None, need_copy: bool = if not user: user = await USERS_DB.find_one({"_id": user_id}) if not user: - user = {"_id": user_id, **USERS_BASE} + user = {"_id": user_id, **USER_BASE} await USERS_DB.insert_one(user) USERS_BUFFER[user_id] = user if d_type: - user = user.setdefault(d_type, copy.deepcopy(USERS_BASE.get(d_type))) + user = user.setdefault(d_type, copy.deepcopy(USER_BASE.get(d_type))) return copy.deepcopy(user) if need_copy else user diff --git a/main.py b/main.py index c849b6c..aab1d66 100644 --- a/main.py +++ b/main.py @@ -127,10 +127,8 @@ class Vocard(commands.Bot): elif not issubclass(error.__class__, VoicelinkException): error = await func.get_lang(ctx.guild.id, "unknownException") + func.settings.invite_link - if (guildId := ctx.guild.id) not in func.ERROR_LOGS: - func.ERROR_LOGS[guildId] = {} - func.ERROR_LOGS[guildId][round(datetime.timestamp(datetime.now()))] = "".join(traceback.format_exception(type(exception), exception, exception.__traceback__)) - + func.logger.error(f"An unexpected error occurred in the {ctx.command.name} command on the {ctx.guild.name}({ctx.guild.id}).", exc_info=exception) + try: return await ctx.reply(error, ephemeral=True) except: