Skip to content

Commit

Permalink
Fixed a bug that caused songs to not be moved if there were only 2 so…
Browse files Browse the repository at this point in the history
…ngs and a song was being moved back in the queue
  • Loading branch information
Fluxticks committed Jul 27, 2021
1 parent 9b36721 commit ad54045
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/esportsbot/cogs/MusicCog.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ async def move_song(self, context: commands.context, from_pos: str, to_pos: str)
return

from_pos = await self.song_index_str_to_int(context, from_pos)
if not from_pos:
if from_pos is None:
return
to_pos = await self.song_index_str_to_int(context, to_pos)
if to_pos is None:
Expand Down Expand Up @@ -1011,12 +1011,14 @@ async def __move_song(self, guild_id, from_pos, to_pos):
inserted_song = [queue[from_pos]]
queue_middle = queue[to_pos:from_pos]
queue_end = queue[from_pos + 1:]
new_queue = queue_top + inserted_song + queue_middle + queue_end
else:
queue_top = queue[:from_pos]
inserted_song = [queue[from_pos]]
queue_middle = queue[from_pos + 1:to_pos]
queue_end = queue[to_pos:]
new_queue = queue_top + inserted_song + queue_middle + queue_end
queue_middle = queue[from_pos + 1:to_pos + 1]
queue_end = queue[to_pos + 1:]
new_queue = queue_top + queue_middle + inserted_song + queue_end

self.active_guilds.get(guild_id)["queue"] = new_queue
await self.update_messages(guild_id)
return True
Expand Down

0 comments on commit ad54045

Please sign in to comment.