added .env

This commit is contained in:
2022-08-28 20:36:58 +03:00
parent 78a477f21a
commit caa8d6b20e
9 changed files with 59 additions and 29 deletions

View File

@@ -1,13 +1,16 @@
"""
lib.CogsPrepare
~~~~~~~~~~~~~
Loads, unloads Cogs files
cog_list: return list of cog filenames
work_with_cogs: loads, reloads and unloads cogs files
"""
import logging
from os import listdir
from disnake.ext import commands
"""
Loads, unloads Cogs files
cog_list: return list of cog filenames
"""
def cog_list():

View File

@@ -1,14 +1,21 @@
import json
from os import walk
import os
"""
Some prepare for commands
"""
def check_conf():
if not os.path.isfile(os.getenv('conf_file')):
with open(os.getenv('conf_file'), 'w+', encoding='utf-8') as f:
f.write("")
async def list_files(fold: str = 'audio'):
fl = []
for filenames in walk(fold):
for filenames in os.walk(fold):
fl.extend(filenames)
break
files = {}
@@ -24,11 +31,11 @@ async def read_json(guild: int, _param: str):
:param _param: Parameter in json file
:return: value of parameter.
"""
with open('prefix.json', 'r', encoding='utf-8') as fp: # Open the JSON
parameter = None
parameter = None
with open(os.getenv('conf_file'), 'r', encoding='utf-8') as f: # Open the JSON
try:
_json = json.load(fp) # Load the custom prefixes
except TypeError:
_json = json.load(f) # Load the custom prefixes
except json.decoder.JSONDecodeError:
_json = {}
if guild: # If the guild exists
try:
@@ -43,7 +50,7 @@ async def read_json(guild: int, _param: str):
async def write_json(guild: int, param_name: str, param: str or int):
with open('prefix.json', 'r', encoding='utf-8') as f:
with open(os.getenv('conf_file'), 'r', encoding='utf-8') as f:
try:
_json = json.load(f)
except json.decoder.JSONDecodeError:
@@ -54,7 +61,7 @@ async def write_json(guild: int, param_name: str, param: str or int):
_json.update({f'{guild}': {}})
_guild = _json[f'{guild}']
_guild.update({f'{param_name}': f'{param}'})
with open('prefix.json', 'w', encoding='utf-8') as f:
with open(os.getenv('conf_file'), 'w', encoding='utf-8') as f:
json.dump(_json, f, indent=4)
@@ -66,9 +73,9 @@ def determine_prefix(bot, msg):
:return: prefix for server, default is $
"""
parameter = '$'
with open('prefix.json', 'r', encoding='utf-8') as fp: # Open the JSON
with open(os.getenv('conf_file'), 'r', encoding='utf-8') as f: # Open the JSON
try:
_json = json.load(fp) # Load the custom prefixes
_json = json.load(f) # Load the custom prefixes
except:
_json = {}
try:
@@ -86,9 +93,9 @@ def determine_time(msg):
:return: prefix for server, default is $
"""
parameter = 15
with open('prefix.json', 'r', encoding='utf-8') as fp: # Open the JSON
with open(os.getenv('conf_file'), 'r', encoding='utf-8') as f: # Open the JSON
try:
_json = json.load(fp) # Load the custom prefixes
_json = json.load(f) # Load the custom prefixes
except:
_json = {}
try:

View File

@@ -0,0 +1,10 @@
"""
lib
~~~~~~~~~~~~~
Some libs for the bot whitch help him
"""
from .DB import *
from .Player import *
from .Comands import *
from .CogsPrepare import *