fix: naprawa działania pętli utworu - wyłączanie pętli pojedynczego utworu przy ręcznym pominięciu (/skip, przycisk w web)
This commit is contained in:
2 files changed
+8
-1
No files matched your search
@@ -444,7 +444,10 @@ class MusicBot(commands.Cog):
|
|||||||
@app_commands.command(name="skip", description="Pomiń aktualny utwór")
|
@app_commands.command(name="skip", description="Pomiń aktualny utwór")
|
||||||
async def skip(self, interaction: discord.Interaction):
|
async def skip(self, interaction: discord.Interaction):
|
||||||
"""Pomiń aktualny utwór"""
|
"""Pomiń aktualny utwór"""
|
||||||
if interaction.guild.voice_client.is_playing():
|
guild_id = interaction.guild.id
|
||||||
|
if self.get_loop_current(guild_id):
|
||||||
|
self.set_loop_current(guild_id, False)
|
||||||
|
if interaction.guild.voice_client and (interaction.guild.voice_client.is_playing() or interaction.guild.voice_client.is_paused()):
|
||||||
interaction.guild.voice_client.stop()
|
interaction.guild.voice_client.stop()
|
||||||
await self.trigger_state_change()
|
await self.trigger_state_change()
|
||||||
await interaction.response.send_message(
|
await interaction.response.send_message(
|
||||||
|
|||||||
@@ -290,10 +290,14 @@ async def api_resume():
|
|||||||
|
|
||||||
@app.post("/api/skip")
|
@app.post("/api/skip")
|
||||||
async def api_skip():
|
async def api_skip():
|
||||||
|
music_cog = bot.get_cog("MusicBot")
|
||||||
guild = get_active_guild()
|
guild = get_active_guild()
|
||||||
if not guild:
|
if not guild:
|
||||||
raise HTTPException(status_code=400, detail="Bot has no active server context")
|
raise HTTPException(status_code=400, detail="Bot has no active server context")
|
||||||
|
|
||||||
|
if music_cog and music_cog.get_loop_current(guild.id):
|
||||||
|
music_cog.set_loop_current(guild.id, False)
|
||||||
|
|
||||||
voice_client = discord.utils.get(bot.voice_clients, guild__id=guild.id)
|
voice_client = discord.utils.get(bot.voice_clients, guild__id=guild.id)
|
||||||
if voice_client and (voice_client.is_playing() or voice_client.is_paused()):
|
if voice_client and (voice_client.is_playing() or voice_client.is_paused()):
|
||||||
voice_client.stop()
|
voice_client.stop()
|
||||||
|
|||||||
Reference in new issue
Block a user