code cleanup
This commit is contained in:
@@ -5,31 +5,7 @@ Some prepare for commands
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import dotenv
|
||||
|
||||
|
||||
def preload_checks():
|
||||
dotenv.load_dotenv()
|
||||
if not os.path.isfile('.env') or not os.getenv('CONF_FILE'):
|
||||
with open('.env', 'a', encoding='utf-8') as f:
|
||||
f.write("CONF_FILE='config.json'\n")
|
||||
dotenv.load_dotenv()
|
||||
if not os.path.isfile(os.getenv('CONF_FILE')):
|
||||
with open(os.getenv('CONF_FILE'), 'a', encoding='utf-8') as f:
|
||||
f.write("")
|
||||
|
||||
|
||||
async def list_files(fold: str = 'audio'):
|
||||
if fold != 'audio':
|
||||
fold = f'audio/{fold}'
|
||||
fl = []
|
||||
for filenames in os.walk(fold):
|
||||
fl.extend(filenames)
|
||||
break
|
||||
files = {}
|
||||
for x in fl[2]:
|
||||
files[x] = x
|
||||
return fl[2]
|
||||
from disnake.ext import commands
|
||||
|
||||
|
||||
async def read_json(guild: int, _param: str):
|
||||
@@ -73,7 +49,7 @@ async def write_json(guild: int, param_name: str, param: str or int):
|
||||
json.dump(_json, f, indent=4)
|
||||
|
||||
|
||||
def determine_prefix(bot, msg):
|
||||
def determine_prefix(bot: commands.Bot, msg):
|
||||
"""
|
||||
Determite per-server bot prefix
|
||||
:param bot: Disnake Bot object
|
||||
@@ -92,23 +68,3 @@ def determine_prefix(bot, msg):
|
||||
except KeyError:
|
||||
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(os.getenv('CONF_FILE'), encoding='utf-8') as f: # Open the JSON
|
||||
try:
|
||||
_json = json.load(f) # Load the custom prefixes
|
||||
except json.JSONDecodeError:
|
||||
_json = {}
|
||||
try:
|
||||
parameter = _json[f"{msg.guild.id}"]["seconds"] # Read prefix from json if is setted up
|
||||
|
||||
except KeyError:
|
||||
pass
|
||||
return parameter
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import sqlite3
|
||||
|
||||
|
||||
from lib import logger
|
||||
|
||||
|
||||
@@ -148,18 +147,3 @@ async def read_db(guild: int, user: int, column: str):
|
||||
return record[_col_dict[column]]
|
||||
except sqlite3.Error as _error:
|
||||
pass
|
||||
|
||||
|
||||
async def check_exist_audio(ctx, guild: int, user: int, column: str, audio: str):
|
||||
_list_str = await read_db(guild, user, column)
|
||||
print(type(_list_str))
|
||||
if _list_str is not None:
|
||||
_list = _list_str.split(',')
|
||||
if audio in _list:
|
||||
await ctx.reply("File in list")
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
else:
|
||||
_list = 'None'
|
||||
|
||||
@@ -10,7 +10,7 @@ async def play_audio(audio, bot, vc):
|
||||
await sleep(1)
|
||||
vp = await vc.connect()
|
||||
if not vp.is_playing():
|
||||
vp.play(FFmpegOpusAudio(f'{audio}'), after=lambda e: print('done', e))
|
||||
vp.play(FFmpegOpusAudio(f'{audio}'))
|
||||
while vp.is_playing():
|
||||
await sleep(0.5)
|
||||
await sleep(1)
|
||||
|
||||
Reference in New Issue
Block a user