'Is there a way for me to queue Songs using discord.py and FFMpeg that is streamed instead of downloading
Errors
-Let the bot join the channel as soon as the play command is called, but from there it doesn't play the song nor send the embed, it just joins the Voice Channel
-Queue songs instead of stopping when the next song is played
queue = [] #here I tried creating a list to register each song that's next to come
class music(commands.Cog):
def __init__ (self, bot):
self.bot = bot
@commands.command()
async def play(self, ctx, *, url):
global queue
server = ctx.message.guild
voice_channel = server.voice_client
async with ctx.typing():
player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True)
voice_channel.play(player, after=lambda e: print(f'Player error: {e}') if e else None)
del(queue[0])
embed = discord.Embed(description=f"Now Playing: {player.title}", color=0xdfa3ff)
embed.set_footer(text="Song requested by: {}".format(ctx.author.display_name))
await ctx.send(embed=embed)
@play.before_invoke
async def ensure_voice(self, ctx):
if ctx.voice_client is None:
if ctx.author.voice:
await ctx.author.voice.channel.connect()
else:
await ctx.send("You are not connected to a voice channel.")
raise commands.CommandError("Author not connected to a voice channel.")
elif ctx.voice_client.is_playing():
ctx.voice_client.stop()
def setup(bot):
bot.add_cog(music(bot))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
