fix: Add more missing checks.

This commit is contained in:
Lemon4ksan
2025-03-02 14:03:50 +03:00
parent 0c980483d2
commit 32f9e6e2c8
6 changed files with 86 additions and 39 deletions

View File

@@ -18,7 +18,7 @@ class PlayButton(Button, VoiceExtension):
async def callback(self, interaction: Interaction) -> None:
logging.debug(f"[FIND] Callback triggered for type: '{type(self.item).__name__}'")
if not interaction.guild:
if not interaction.guild_id:
logging.info("[FIND] No guild found in PlayButton callback")
await interaction.respond("❌ Эта команда доступна только на серверах.", ephemeral=True, delete_after=15)
return
@@ -26,7 +26,7 @@ class PlayButton(Button, VoiceExtension):
if not await self.voice_check(interaction):
return
guild = await self.db.get_guild(interaction.guild.id, projection={'current_track': 1, 'current_menu': 1, 'vote_add': 1, 'vibing': 1})
guild = await self.db.get_guild(interaction.guild_id, projection={'current_track': 1, 'current_menu': 1, 'vote_add': 1, 'vibing': 1})
if guild['vibing']:
await interaction.respond("❌ Нельзя добавлять треки в очередь, пока запущена волна.", ephemeral=True, delete_after=15)
return
@@ -100,7 +100,7 @@ class PlayButton(Button, VoiceExtension):
await response.add_reaction('')
await self.db.update_vote(
interaction.guild.id,
interaction.guild_id,
response.id,
{
'positive_votes': list(),
@@ -119,11 +119,11 @@ class PlayButton(Button, VoiceExtension):
if guild['current_track']:
logging.debug(f"[FIND] Adding tracks to queue")
await self.db.modify_track(interaction.guild.id, tracks, 'next', 'extend')
await self.db.modify_track(interaction.guild_id, tracks, 'next', 'extend')
else:
logging.debug(f"[FIND] Playing track")
track = tracks.pop(0)
await self.db.modify_track(interaction.guild.id, tracks, 'next', 'extend')
await self.db.modify_track(interaction.guild_id, tracks, 'next', 'extend')
if not await self.play_track(interaction, track):
await interaction.respond('Не удалось воспроизвести трек.', ephemeral=True, delete_after=15)

View File

@@ -593,7 +593,7 @@ class MenuView(View, VoiceExtension):
if not self.ctx.guild_id:
return self
self.guild = await self.db.get_guild(self.ctx.guild_id, projection={'repeat': 1, 'shuffle': 1, 'current_track': 1, 'vibing': 1})
self.guild = await self.db.get_guild(self.ctx.guild_id, projection={'repeat': 1, 'shuffle': 1, 'current_track': 1, 'current_menu': 1, 'vibing': 1})
if self.guild['repeat']:
self.repeat_button.style = ButtonStyle.success