added requirements.txt

This commit is contained in:
2022-08-28 19:25:39 +03:00
parent a603898f2d
commit 78a477f21a
8 changed files with 175 additions and 125 deletions

View File

@@ -1,5 +1,8 @@
import logging
from os import listdir
from disnake.ext import commands
"""
Loads, unloads Cogs files
cog_list: return list of cog filenames
@@ -18,7 +21,19 @@ def cog_list():
async def work_with_cogs(what_do, bot):
for _filename in cog_list():
if what_do == "load":
bot.load_extension(f'cogs.{_filename}')
try:
bot.load_extension(f'cogs.{_filename}')
logging.info(f'Loaded cog {_filename}')
except commands.ExtensionNotFound:
logging.error(f"Error: {_filename} couldn't be found to load.")
except commands.ExtensionFailed as error:
logging.error(f'Error: {_filename} failed to load properly.', error)
except commands.ExtensionError:
logging.error(f'Error: unknown error with {_filename}')
elif what_do == 'unload':
bot.unload_extension(f'cogs.{_filename}')
elif what_do == 'reload':

View File

@@ -68,8 +68,7 @@ def determine_prefix(bot, msg):
parameter = '$'
with open('prefix.json', 'r', encoding='utf-8') as fp: # Open the JSON
try:
from json import load
_json = load(fp) # Load the custom prefixes
_json = json.load(fp) # Load the custom prefixes
except:
_json = {}
try:
@@ -78,3 +77,23 @@ def determine_prefix(bot, msg):
except:
pass
return parameter
def determine_time(msg):
"""
Determite per-server bot prefix
:param msg: Disnake msg object
:return: prefix for server, default is $
"""
parameter = 15
with open('prefix.json', 'r', encoding='utf-8') as fp: # Open the JSON
try:
_json = json.load(fp) # Load the custom prefixes
except:
_json = {}
try:
parameter = _json[f"{msg.guild.id}"]["seconds"] # Read prefix from json if is setted up
except:
pass
return parameter