Skip to content

Commit

Permalink
Cleanup music play command, use new way to skip multiple songs in queue
Browse files Browse the repository at this point in the history
  • Loading branch information
jackra1n committed Feb 5, 2024
1 parent 606d324 commit 2983818
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions bot/cogs/music.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,20 @@ async def play(self, ctx: commands.Context, *, search: str):
if not tracks:
raise NoTracksFound()

if 'http' not in search or len(tracks) == 1:
tracks = tracks[0]

stmt_cleanup = "SELECT music_cleanup FROM discord_server WHERE discord_server_id = $1"
music_cleanup = await self.bot.db.fetchval(stmt_cleanup, ctx.guild.id)
delete_after = 60 if music_cleanup else None

songs_cnt = await player.queue.put_wait(tracks)
embed = discord.Embed(color=EMBED_COLOR)
embed.title = 'Songs Queued'
embed.title += f' ({songs_cnt})' if songs_cnt > 1 else ''
if isinstance(tracks, wavelink.Playlist):
embed.description = f'**[{tracks}]({tracks.url})**' if tracks.url else f'**{tracks}**'
embed.description = f'**[{tracks}]({tracks.url})**' if tracks.url else f'**[{tracks}]({search})**'
else:
tracks = tracks[0]
embed.description = f'**[{tracks}]({tracks.uri})**'

songs_cnt = await player.queue.put_wait(tracks)
embed.title = 'Songs Queued'
embed.title += f' ({songs_cnt})' if songs_cnt > 1 else ''

if not player.playing:
await player.play(player.queue.get())
Expand All @@ -149,8 +148,7 @@ async def skip(self, ctx: commands.Context, amount: int = 1):
if not player.queue and not player.playing:
await player._do_recommendation()
else:
for _ in range(amount - 1):
await player.queue.delete(0)
player.queue._items = player.queue[amount - 1:]
await player.skip()
embed = discord.Embed(title=f'⏭️ Skipped {amount}', color=EMBED_COLOR)
if player.current:
Expand Down

0 comments on commit 2983818

Please sign in to comment.