diff --git a/cogs/audio.py b/cogs/audio.py index efabd55..868febb 100644 --- a/cogs/audio.py +++ b/cogs/audio.py @@ -19,35 +19,39 @@ class Audio(commands.Cog): @commands.Cog.listener() async def on_voice_state_update(self, member, before, after): - 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, 'usertracks') - def_audio_db = await read_db(member.guild.id, member.id, 'defaulttracks') - if audio_db is not None: - audio_db = audio_db.split(', ') # Need to fix creating list - for i in range(len(audio_db)): - audio_db[i] = f'{member.id}/{audio_db[i]}' - if def_audio_db is not None: - def_audio_db = def_audio_db.split(', ') - from lib.Comands import list_files - def_audio_ls = await list_files() - if before.channel is None and not member.bot: - 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 = [] - logging.info(f'Play audio from DB') - full_audio = def_audio_db + audio_db - 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') - audio = random.choice(def_audio_ls) - await play_audio(audio, self.bot, after.channel) - else: - logging.info(f'Skip playing') + if any('Escape from Tarkov' in str(user.activity) for user in after.channel.members): + logging.info('Skip playing by Game') + else: + 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, 'usertracks') + def_audio_db = await read_db(member.guild.id, member.id, 'defaulttracks') + if audio_db is not None: + audio_db = audio_db.split(', ') # Need to fix creating list + for i in range(len(audio_db)): + audio_db[i] = f'{member.id}/{audio_db[i]}' + if def_audio_db is not None: + def_audio_db = def_audio_db.split(', ') + from lib.Comands import list_files + def_audio_ls = await list_files() + if before.channel is None and not member.bot: + 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 = [] + logging.info(f'Play audio from DB') + full_audio = def_audio_db + audio_db + 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') + audio = random.choice(def_audio_ls) + await play_audio(audio, self.bot, after.channel) + else: + logging.info(f'Skip playing') + @commands.command(name="upload_audio") async def upload_audio(self, ctx, user=None): diff --git a/test.py b/test.py index 829464e..c33a49f 100644 --- a/test.py +++ b/test.py @@ -17,10 +17,13 @@ intents = disnake.Intents(messages=True, guilds=True, message_content=True, voice_states=True, - members=True) + members=True, + presences=True + ) bot = commands.Bot(command_prefix=determine_prefix, - intents=intents + intents=intents, + reload=True ) logging.basicConfig(stream=sys.stdout, filemode='w', level='INFO', @@ -73,4 +76,4 @@ async def slash_cogs(inter, what_do): await inter.response.send_message('You`re not bot owner', ephemeral=True) -bot.run('OTQ3OTUzOTAxNzgzNjIxNjYy.GTXbMv.KrztaTO7-ivsPEAVjsyikSQ-GP-ANwULmDraig') +bot.run('OTQ2ODE5MDA0MzE0NTcwODUy.YhkP6Q.dhFqi2MJMrxzHt5FtjK5Cl-5BI8')