diff --git a/commands/voice.py b/commands/voice.py index 906cbb6..e52f97c 100644 --- a/commands/voice.py +++ b/commands/voice.py @@ -44,6 +44,12 @@ async def queue_or_play(message): action="store_true", help="remove all queued songs", ) + parser.add_argument( + "-n", + "--now", + action="store_true", + help="play the specified song immediately", + ) parser.add_argument( "-t", "--remove-title", @@ -103,7 +109,11 @@ async def queue_or_play(message): return queued = youtubedl.QueuedSong(player, message.author.id) - players[message.guild.id].queue_add(queued) + + if args.now: + players[message.guild.id].queue_add_front(queued) + else: + players[message.guild.id].queue_add(queued) if ( not message.guild.voice_client.is_playing() @@ -111,6 +121,9 @@ async def queue_or_play(message): ): await utils.reply(message, f"**0.** {queued.format()}") play_next(message) + elif args.now: + message.guild.voice_client.stop() + await utils.reply(message, f"**0.** {queued.format()}") else: await utils.reply( message, diff --git a/youtubedl.py b/youtubedl.py index dc350f4..c67dd89 100644 --- a/youtubedl.py +++ b/youtubedl.py @@ -1,10 +1,10 @@ import asyncio from typing import Any, Optional -import constants import disnake import yt_dlp +import constants import utils ytdl = yt_dlp.YoutubeDL(constants.YTDL_OPTIONS) @@ -58,6 +58,9 @@ class QueuedPlayer: def queue_add(self, item): self.queue.append(item) + def queue_add_front(self, item): + self.queue.insert(0, item) + class QueuedSong: def __init__(self, player, queuer):