Updated localization and moved some commands

This commit is contained in:
bacon
2024-03-09 18:54:26 +03:00
parent 3bd30239ae
commit 01db1c254d
9 changed files with 89 additions and 82 deletions

View File

@@ -5,7 +5,6 @@ from disnake import OptionChoice, Option, OptionType, Member, VoiceState
from disnake.ext import commands
from lib.Logger import logger
from lib.DB_Worker import read_db
from lib.Player import play_audio
from lib.ListGenerator import ListGenerator
@@ -30,19 +29,11 @@ class Audio(commands.Cog, name='Audio'):
# Prepare list of audio
from lib.Comands import read_json
_role = await read_json(member.guild.id, 'tigger_role')
# Read audio from DB
audio_db = await read_db(member.guild.id, member.id, 'defaulttracks')
audio: list = []
if audio_db is not None:
audio = audio_db.split(', ')
else:
for _a in ListGenerator('audio'):
audio.append(_a.name)
for _a in ListGenerator('audio'):
audio.append(_a.name)
if audio_db is not None:
logger.info('Play audio from DB')
await play_audio(f'audio/{random.choice(audio)}', self.bot, after.channel)
elif len(member.roles) == 1 or _role is None:
if len(member.roles) == 1 or _role is None:
logger.info('Skip playing by role')
elif any(str(role.id) in _role for role in member.roles):
logger.info('Play audio from list by role')