Fixed the pings on repeated loops
This commit is contained in:
parent
f53f6a1173
commit
24bf918b9e
28
audio.py
28
audio.py
@ -127,21 +127,19 @@ async def play_next(interaction: discord.Interaction):
|
||||
if repeat_modes.get(guild_id) == "one" and current_tracks.get(guild_id):
|
||||
song_url, title = current_tracks[guild_id]
|
||||
music_queues[guild_id].insert(0, (song_url, title)) # Re-add the current song to the front of the queue
|
||||
|
||||
# Handle Repeat All
|
||||
# Skip sending an alert for the repeated song
|
||||
voice_client = voice_clients[guild_id]
|
||||
elif repeat_modes.get(guild_id) == "all" and not music_queues[guild_id]:
|
||||
# Move completed songs back to the queue
|
||||
song_url, title = current_tracks.get(guild_id, (None, None))
|
||||
if song_url and title:
|
||||
music_queues[guild_id].append((song_url, title))
|
||||
music_queues[guild_id].extend(current_tracks.values())
|
||||
# Recycle the current track into the queue
|
||||
if current_tracks.get(guild_id):
|
||||
music_queues[guild_id].append(current_tracks[guild_id])
|
||||
|
||||
# Proceed to play the next song
|
||||
# If no songs are left in the queue
|
||||
if not music_queues[guild_id]:
|
||||
await interaction.followup.send("❌ **No more songs in the queue.**")
|
||||
return
|
||||
|
||||
voice_client = voice_clients[guild_id]
|
||||
# Get the next song from the queue
|
||||
song_url, title = music_queues[guild_id].pop(0)
|
||||
current_tracks[guild_id] = (song_url, title)
|
||||
|
||||
@ -152,6 +150,7 @@ async def play_next(interaction: discord.Interaction):
|
||||
}
|
||||
|
||||
try:
|
||||
voice_client = voice_clients[guild_id]
|
||||
source = discord.FFmpegPCMAudio(song_url, **ffmpeg_options)
|
||||
volume = volumes.get(guild_id, default_volume)
|
||||
source = discord.PCMVolumeTransformer(source, volume=volume)
|
||||
@ -164,9 +163,16 @@ async def play_next(interaction: discord.Interaction):
|
||||
),
|
||||
)
|
||||
|
||||
await interaction.followup.send(f"🎵 **Now playing:** {title}")
|
||||
# Only alert if the song is new
|
||||
if repeat_modes.get(guild_id) != "one":
|
||||
embed = discord.Embed(
|
||||
title="🎵 Now Playing",
|
||||
description=f"**{title}**",
|
||||
color=discord.Color.green()
|
||||
)
|
||||
await interaction.followup.send(embed=embed)
|
||||
except Exception as e:
|
||||
await interaction.followup.send(f"Failed to play the next song. Error: {str(e)}")
|
||||
await interaction.followup.send(f"❌ **Error:** Failed to play the next song. {str(e)}")
|
||||
|
||||
|
||||
async def stop_audio(interaction: discord.Interaction):
|
||||
|
Loading…
x
Reference in New Issue
Block a user