mirror of
https://github.com/deadcxap/YandexMusicDiscordBot.git
synced 2026-01-10 12:21:45 +03:00
impr: Minor code improvement.
This commit is contained in:
@@ -273,7 +273,7 @@ class VoiceExtension:
|
||||
await self.stop_playing(ctx)
|
||||
return await self.play_track(ctx, next_tracks[0], button_callback=button_callback)
|
||||
|
||||
async def voice_check(self, ctx: ApplicationContext | Interaction) -> bool:
|
||||
async def voice_check(self, ctx: ApplicationContext | Interaction, *, check_vibe_privilage: bool = True) -> bool:
|
||||
"""Check if bot can perform voice tasks and respond if failed.
|
||||
|
||||
Args:
|
||||
@@ -309,12 +309,13 @@ class VoiceExtension:
|
||||
await ctx.respond("❌ Добавьте бота в голосовой канал при помощи команды /voice join.", delete_after=15, ephemeral=True)
|
||||
return False
|
||||
|
||||
guild = self.db.get_guild(ctx.guild.id)
|
||||
member = cast(discord.Member, ctx.user)
|
||||
if guild['vibing'] and ctx.user.id != guild['current_viber_id'] and not member.guild_permissions.manage_channels:
|
||||
logging.debug("[VIBE] Context user is not the current viber")
|
||||
await ctx.respond("❌ Вы не можете взаимодействовать с чужой волной!", delete_after=15, ephemeral=True)
|
||||
return False
|
||||
if check_vibe_privilage:
|
||||
guild = self.db.get_guild(ctx.guild.id)
|
||||
member = cast(discord.Member, ctx.user)
|
||||
if guild['vibing'] and ctx.user.id != guild['current_viber_id'] and not member.guild_permissions.manage_channels:
|
||||
logging.debug("[VIBE] Context user is not the current viber")
|
||||
await ctx.respond("❌ Вы не можете взаимодействовать с чужой волной!", delete_after=15, ephemeral=True)
|
||||
return False
|
||||
|
||||
logging.debug("[VC_EXT] Voice requirements met")
|
||||
return True
|
||||
|
||||
@@ -52,7 +52,7 @@ class Voice(Cog, VoiceExtension):
|
||||
if current_menu:
|
||||
logging.info(f"[VOICE] Disabling current menu for guild {gid} due to multiple members")
|
||||
|
||||
self.db.update(gid, {'current_menu': None, 'repeat': False, 'shuffle': False})
|
||||
self.db.update(gid, {'current_menu': None, 'repeat': False, 'shuffle': False, 'vibing': False})
|
||||
try:
|
||||
message = await channel.fetch_message(current_menu)
|
||||
await message.delete()
|
||||
@@ -240,8 +240,9 @@ class Voice(Cog, VoiceExtension):
|
||||
await ctx.respond("❌ У вас нет прав для выполнения этой команды.", delete_after=15, ephemeral=True)
|
||||
return
|
||||
|
||||
if await self.voice_check(ctx):
|
||||
if (vc := await self.get_voice_client(ctx)) and await self.voice_check(ctx):
|
||||
await self.stop_playing(ctx, full=True)
|
||||
await vc.disconnect(force=True)
|
||||
await ctx.respond("Отключение успешно!", delete_after=15, ephemeral=True)
|
||||
logging.info(f"[VOICE] Successfully disconnected from voice channel in guild {ctx.guild.id}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user