edditing code

This commit is contained in:
2022-08-23 20:44:19 +03:00
parent 10990a86a4
commit 8ac74ccd44
9 changed files with 133 additions and 53 deletions

View File

@@ -1,4 +1,5 @@
import logging
import random
import tempfile
from os import path, makedirs, rename, remove
@@ -23,16 +24,6 @@ class Audio(commands.Cog):
# Read audio from DB
audio_db = await read_db(member.guild.id, member.id, 'usertracks')
def_audio_db = await read_db(member.guild.id, member.id, 'defaulttracks')
print(f'Trigger role: {_role}')
print(f' Memder roles {member.roles}')
print(role.id in _role for role in member.roles)
print(f'Audio DB: {audio_db}')
print(f'Def audio DB: {def_audio_db}')
print(f' Memder is bot {member.bot}')
print(f' Before channel {before.channel}')
print('------------------------------------------')
if audio_db is not None:
audio_db = audio_db.split(', ') # Need to fix creating list
for i in range(len(audio_db)):
@@ -45,16 +36,16 @@ class Audio(commands.Cog):
if def_audio_db or audio_db is not None:
if def_audio_db is None: def_audio_db = []
if audio_db is None: audio_db = []
print(audio_db, def_audio_db)
logging.info(f'Play audio from DB')
full_audio = def_audio_db + audio_db
if not self.bot.voice_clients:
await play_audio(full_audio, self.bot, after.channel)
elif (role.id in _role for role in member.roles):
audio = random.choice(full_audio)
await play_audio(audio, self.bot, after.channel)
elif len(member.roles) == 1 or _role is None:
logging.info(f'Skip playing')
elif any(str(role.id) in _role for role in member.roles):
logging.info(f'Play audio from list by role')
if not self.bot.voice_clients:
await play_audio(def_audio_ls, self.bot, after.channel)
audio = random.choice(def_audio_ls)
await play_audio(audio, self.bot, after.channel)
else:
logging.info(f'Skip playing')