-
-
Save EvieePy/ab667b74e9758433b3eb806c53a19f34 to your computer and use it in GitHub Desktop.
| """A Rewrite example of a cross guild music player with playlist support. | |
| Please understand Music bots are complex, and that even this basic example can be daunting to a beginner. | |
| For this reason it's highly advised you familiarize yourself with discord.py, python and asyncio, BEFORE | |
| you attempt to write a music bot. | |
| This example makes use of: Python 3.6 and the Rewrite Branch of Discord.py. | |
| For a more basic voice example please read: | |
| https://github.com/Rapptz/discord.py/blob/rewrite/examples/basic_voice.py | |
| """ | |
| import discord | |
| from discord.ext import commands | |
| import asyncio | |
| import async_timeout | |
| import youtube_dl | |
| opts = { | |
| 'format': 'bestaudio/best', | |
| 'outtmpl': 'downloads/%(extractor)s-%(id)s-%(title)s.%(ext)s', | |
| 'restrictfilenames': True, | |
| 'noplaylist': True, | |
| 'nocheckcertificate': True, | |
| 'ignoreerrors': False, | |
| 'logtostderr': False, | |
| 'quiet': True, | |
| 'no_warnings': True, | |
| 'default_search': 'auto', | |
| 'source_address': '0.0.0.0' # ipv6 addresses cause issues sometimes | |
| } | |
| ytdl = youtube_dl.YoutubeDL(opts) | |
| ffmpeg_options = { | |
| 'before_options': '-nostdin', | |
| 'options': '-vn' | |
| } | |
| class YTDLSource(discord.PCMVolumeTransformer): | |
| """A class which uses YTDL to retrieve a song and returns it as a source for Discord.""" | |
| def __init__(self, source, *, data, volume=.4): | |
| super().__init__(source, volume) | |
| self.data = data | |
| self.title = data.get('title') | |
| self.url = data.get('url') | |
| @classmethod | |
| async def from_url(cls, url, *, loop=None): | |
| loop = loop or asyncio.get_event_loop() | |
| data = await loop.run_in_executor(None, ytdl.extract_info, url) | |
| if 'entries' in data: | |
| data = data['entries'][0] | |
| filename = ytdl.prepare_filename(data) | |
| return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data) | |
| class MusicPlayer: | |
| """Music Player instance. | |
| Each guild using music will have a separate instance.""" | |
| def __init__(self, bot, ctx): | |
| self.bot = bot | |
| self.queue = asyncio.Queue() | |
| self.next = asyncio.Event() | |
| self.die = asyncio.Event() | |
| self.guild = ctx.guild | |
| self.default_chan = ctx.channel | |
| self.current = None | |
| self.volume = .4 | |
| self.now_playing = None | |
| self.player_task = self.bot.loop.create_task(self.player_loop()) | |
| self.inactive_task = self.bot.loop.create_task(self.inactive_check(ctx)) | |
| async def inactive_check(self, ctx): | |
| await self.die.wait() | |
| await ctx.invoke(self.bot.get_command('stop')) | |
| async def player_loop(self): | |
| await self.bot.wait_until_ready() | |
| while not self.bot.is_closed(): | |
| self.next.clear() | |
| try: | |
| with async_timeout.timeout(10): # Auto leave after 5 minutes of inactivity. | |
| entry = await self.queue.get() | |
| except asyncio.TimeoutError: | |
| await self.default_chan.send('I have been inactive for 5 minutes. Goodbye!') | |
| return self.die.set() | |
| try: | |
| info = await YTDLSource.from_url(entry.query, loop=self.bot.loop) | |
| info.volume = self.volume | |
| except Exception: | |
| await self.default_chan.send(f'There was an error with the request: `{entry.query}`') | |
| continue | |
| channel = entry.channel | |
| requester = entry.requester | |
| self.guild.voice_client.play(info, after=lambda s: self.bot.loop.call_soon_threadsafe(self.next.set())) | |
| self.now_playing = await channel.send(f'**Now Playing:** `{info.title}` requested by `{requester}`') | |
| await self.next.wait() # Wait until the players after function is called. | |
| try: | |
| await self.now_playing.delete() | |
| except (discord.Forbidden, discord.HTTPException): | |
| pass | |
| class MusicEntry: | |
| def __init__(self, ctx, query): | |
| self.requester = ctx.author | |
| self.channel = ctx.channel | |
| self.query = query | |
| class Music: | |
| """Music Cog containing various commands for playing music. | |
| This cog supports cross guild music playing and implements a queue for playlists.""" | |
| def __init__(self, bot): | |
| self.bot = bot | |
| self.players = {} | |
| async def __local_check(self, ctx): | |
| """A check which applies to all commands in Music.""" | |
| if not ctx.guild: | |
| await ctx.send('Music commands can not be used in DMs.') | |
| return False | |
| def get_player(self, ctx): | |
| try: | |
| player = self.players[ctx.guild.id] | |
| except KeyError: | |
| player = MusicPlayer(self.bot, ctx) | |
| self.players[ctx.guild.id] = player | |
| return player | |
| @commands.command(name='connect', aliases=['summon', 'join', 'move']) | |
| async def voice_connect(self, ctx, *, channel: discord.VoiceChannel=None): | |
| """Summon the bot to a voice channel. | |
| This command handles both summoning and moving the bot.""" | |
| channel = getattr(ctx.author.voice, 'channel', channel) | |
| vc = ctx.guild.voice_client | |
| if not channel: | |
| return await ctx.send('No channel to join. Please either specify a valid channel or join one.') | |
| if not vc: | |
| try: | |
| await channel.connect(timeout=10) | |
| except asyncio.TimeoutError: | |
| return await ctx.send('Unable to connect to the voice channel at this time. Please try again.') | |
| await ctx.send(f'Connected to: **{channel}**', delete_after=15) | |
| else: | |
| if channel == vc.channel: | |
| return | |
| try: | |
| await vc.move_to(channel) | |
| except Exception: | |
| return await ctx.send('Unable to move this channel. Perhaps missing permissions?') | |
| await ctx.send(f'Moved to: **{channel}**', delete_after=15) | |
| @commands.command(name='play') | |
| async def play_song(self, ctx, *, query: str): | |
| """Add a song to the queue. | |
| Uses YTDL to auto search for a song. A URL may also be provided.""" | |
| vc = ctx.guild.voice_client | |
| if vc is None: | |
| await ctx.invoke(self.voice_connect) | |
| if not ctx.guild.voice_client: | |
| return | |
| else: | |
| if ctx.author not in vc.channel.members: | |
| return await ctx.send(f'You must be in **{vc.channel}** to request songs.', delete_after=30) | |
| player = self.get_player(ctx) | |
| entry = MusicEntry(ctx, query) | |
| await player.queue.put(entry) | |
| await ctx.send(f'Added: `{query}` to the queue.', delete_after=30) | |
| @commands.command(name='stop') | |
| async def stop_player(self, ctx): | |
| """Stops the player and clears the queue.""" | |
| vc = ctx.guild.voice_client | |
| if vc is None: | |
| return | |
| player = self.get_player(ctx) | |
| inact = player.inactive_task | |
| vc.stop() | |
| try: | |
| player.player_task.cancel() | |
| del self.players[ctx.guild.id] | |
| except Exception as e: | |
| return print(e) | |
| await vc.disconnect() | |
| await ctx.send('Disconnected from voice and cleared your queue. Goodbye!', delete_after=15) | |
| try: | |
| inact.cancel() | |
| except Exception as e: | |
| print(e) | |
| @commands.command(name='pause') | |
| async def pause_song(self, ctx): | |
| """Pause the currently playing song.""" | |
| vc = ctx.guild.voice_client | |
| if vc is None or not vc.is_playing(): | |
| return await ctx.send('I am not currently playing anything.', delete_after=20) | |
| if vc.is_paused(): | |
| return await ctx.send('I am already paused.', delete_after=20) | |
| vc.pause() | |
| await ctx.send(f'{ctx.author.mention} has paused the song.') | |
| @commands.command(name='resume') | |
| async def resume_song(self, ctx): | |
| """Resume a song if it is currently paused.""" | |
| vc = ctx.guild.voice_client | |
| if vc is None or not vc.is_connected(): | |
| return await ctx.send('I am not currently playing anything.', delete_after=20) | |
| if vc.is_paused(): | |
| vc.resume() | |
| await ctx.send(f'{ctx.author.mention} has resumed the song.') | |
| @commands.command(name='skip') | |
| async def skip_song(self, ctx): | |
| """Skip the current song.""" | |
| vc = ctx.guild.voice_client | |
| if vc is None or not vc.is_connected(): | |
| return await ctx.send('I am not currently playing anything.', delete_after=20) | |
| vc.stop() | |
| await ctx.send(f'{ctx.author.mention} has skipped the song.') | |
| @commands.command(name='current', aliases=['currentsong', 'nowplaying', 'np']) | |
| async def current_song(self, ctx): | |
| """Return some information about the current song.""" | |
| vc = ctx.guild.voice_client | |
| if not vc.is_playing(): | |
| return await ctx.send('Not currently playing anything.') | |
| player = self.get_player(ctx) | |
| msg = player.now_playing.content | |
| try: | |
| await player.now_playing.delete() | |
| except (discord.Forbidden, discord.HTTPException): | |
| pass | |
| player.now_playing = await ctx.send(msg) | |
| @commands.command(name='volume', aliases=['vol']) | |
| async def adjust_volume(self, ctx, *, vol: int): | |
| """Adjust the player volume.""" | |
| if not 0 < vol < 101: | |
| return await ctx.send('Please enter a value between 1 and 100.') | |
| vc = ctx.guild.voice_client | |
| if vc is None: | |
| return await ctx.send('I am not currently connected to voice.') | |
| player = self.get_player(ctx) | |
| adj = float(vol) / 100 | |
| try: | |
| vc.source.volume = adj | |
| except AttributeError: | |
| pass | |
| finally: | |
| player.volume = adj | |
| await ctx.send(f'Changed player volume to: **{vol}%**') | |
| def setup(bot): | |
| bot.add_cog(Music(bot)) |
How would I modify this to play local files?
I wouldn't use this code if I were you, It is good it shows the basics of Discord Music Clients, but in reality this script is jack
YouTube links/gates have expiry times so if you try to play anything after a set amount of 25-30 seconds the gate expiry's
I wouldn't use this code if I were you, It is good it shows the basics of Discord Music Clients, but in reality this script is jack
YouTube links/gates have expiry times so if you try to play anything after a set amount of 25-30 seconds the gate expiry's
You do realise it handles that?
Although even though it does handle it. I would suggest using Lavalink. If you can handle a few Linux commands and have a VPS to run it on you will have a much better time with running a music bot. You can also checkout my lib, WaveLink, which is a powerful wrapper around Lavalink for discord.py.
I’m using lavalink, but after a while I get NodeNotFound error
how can i add a loop command?
If its loop as in replay Queue. I would suggest just setting queue position to 0
How would you add a loop command for a single song?
Don't clear the queue, and repeat it. even if its 1 song, you can add it to queue. OR
You can play the last-played song at the end of each song, If its repeated it will play the same song.
how can i add a loop command?
If its loop as in replay Queue. I would suggest just setting queue position to 0
How would you add a loop command for a single song?
Don't clear the queue, and repeat it. even if its 1 song, you can add it to queue. OR
You can play the last-played song at the end of each song, If its repeated it will play the same song.I've been trying to code it where it doesn't clear the queue, and it repeats it instead. However, I have been unable to do this. Can you please tell me specifically the code that would be required to do this?
Mate, I'm just saying how you can do it. I'm not gonna now do a full tutorial just for you so you can copy & paste it.
I have enough stuff to do.
Pls help
Command raised an exception: RuntimeError: PyNaCl library needed in order to ise voice
Pls help
Command raised an exception: RuntimeError: PyNaCl library needed in order to ise voice
mate it literally tells you what you need, Install PyNaCI
using python -m pip install PyNaCI
so im getting the error in the command play. would appreciate if someone were to explain this to me
Ignoring exception in command play:
Traceback (most recent call last):
File "/home/mysteri0us/Code/discord bot/music.py", line 232, in get_player
player = self.players[ctx.guild.id]
KeyError: 835749310712119307
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mysteri0us/Code/discord bot/music.py", line 293, in play_
player = self.get_player(ctx)
File "/home/mysteri0us/Code/discord bot/music.py", line 234, in get_player
player = MusicPlayer(ctx)
NameError: name 'MusicPlayer' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'MusicPlayer' is not defined
Ignoring exception in command play:
Traceback (most recent call last):
File "/home/mysteri0us/Code/discord bot/music.py", line 232, in get_player
player = self.players[ctx.guild.id]
KeyError: 835749310712119307
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mysteri0us/Code/discord bot/music.py", line 293, in play_
player = self.get_player(ctx)
File "/home/mysteri0us/Code/discord bot/music.py", line 234, in get_player
player = MusicPlayer(ctx)
NameError: name 'MusicPlayer' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'MusicPlayer' is not defined
^Cmysteri0us@Mysteri0us-Computer:~/Code$ /usr/bin/python3 "/home/mysteri0us/Code/discord bot/index.py"
We have logged in as testiu887878#2253
Ignoring exception in command play:
Traceback (most recent call last):
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
await self.prepare(ctx)
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 706, in _parse_arguments
kwargs[name] = await self.transform(ctx, param)
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: search is a required argument that is missing.
Ignoring exception in command play:
Traceback (most recent call last):
File "/home/mysteri0us/Code/discord bot/music.py", line 232, in get_player
player = self.players[ctx.guild.id]
KeyError: 835749310712119307
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mysteri0us/Code/discord bot/music.py", line 293, in play_
player = self.get_player(ctx)
File "/home/mysteri0us/Code/discord bot/music.py", line 234, in get_player
player = MusicPlayer(ctx)
NameError: name 'MusicPlayer' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'MusicPlayer' is not defined
Ignoring exception in command play:
Traceback (most recent call last):
File "/home/mysteri0us/Code/discord bot/music.py", line 232, in get_player
player = self.players[ctx.guild.id]
KeyError: 835749310712119307
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mysteri0us/Code/discord bot/music.py", line 293, in play_
player = self.get_player(ctx)
File "/home/mysteri0us/Code/discord bot/music.py", line 234, in get_player
player = MusicPlayer(ctx)
NameError: name 'MusicPlayer' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mysteri0us/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'MusicPlayer' is not defined
it might be caused due to something in get_player i think
can you do a loop command?
Please make a loop command :)
Hi, I'm having this error
TypeError: 'coroutine' object is not iterable
in the line 358
fmt = '\n'.join(f'**{_["title"]}**' for _ in upcoming)
I tried to search why this happens but most sources I've found say that it must have await outside the function but if I'm not wrong it already is in here, any help is welcome :)
edit.
Nvm apparently any having @bot.command which also iterates list brake the thing. I solved it by encasing those commands in a class and making them @commands.command.
I added bot = commands.Bot(prefix='!') and did bot.run with my token at the bottom but when I tried to use the commands I get "no such command" error. What could be causing that?
fsr it gives me a error: ERROR: No video formats found
can someone help me?
Hello, Im using your code which is amazing very smart by the way. Im having some troubles where it brings up that play is not an attribute, i have the error code posted below this. This only happens once and while and its normally in the middle of a song. If someone could please help that would be great.
Task exception was never retrieved
future: <Task finished name='Task-180' coro=<MusicPlayer.player_loop() done, defined at /home/runner/Fusion-Music/cogs/music.py:118> exception=AttributeError("'NoneType' object has no attribute 'play'")>
Traceback (most recent call last):
File "/home/runner/Fusion-Music/cogs/music.py", line 145, in player_loop
self._guild.voice_client.play(source, after=lambda _: self.bot.loop.call_soon_threadsafe(self.next.set))
AttributeError: 'NoneType' object has no attribute 'play'
Hi, your code works perfectly, fast and easy to use. I'm only having a problem with playing playlists. If I link a playlist with the play command it only queue the first song. Looking at the console, it returns this error:
Ignoring exception in command play:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/Users/admin/Documents/GitHub/chickennuggetsbot/app.py", line 296, in play_
source = await YTDLSource.create_source(ctx, search, loop=self.bot.loop, download=False)
File "/Users/admin/Documents/GitHub/chickennuggetsbot/app.py", line 86, in create_source
if 'entries' in data:
TypeError: argument of type 'NoneType' is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: argument of type 'NoneType' is not iterableDoing a print of data variable it seems to be None value. What should I do?
Hi, your code works perfectly, fast and easy to use. I'm only having a problem with playing playlists. If I link a playlist with the play command it only queue the first song. Looking at the console, it returns this error:
Ignoring exception in command play: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/Users/admin/Documents/GitHub/chickennuggetsbot/app.py", line 296, in play_ source = await YTDLSource.create_source(ctx, search, loop=self.bot.loop, download=False) File "/Users/admin/Documents/GitHub/chickennuggetsbot/app.py", line 86, in create_source if 'entries' in data: TypeError: argument of type 'NoneType' is not iterable The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke await injected(*ctx.args, **ctx.kwargs) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: argument of type 'NoneType' is not iterableDoing a print of data variable it seems to be None value. What should I do?
What URL are you passing? There are some types of YouTube playlists that aren’t collections of songs and ytdl doesn’t recognize them as a list to iterate through. I fixed this by being more selective about the urls I passed into it.
I'm testing with this one:
https://youtube.com/playlist?list=PLov8ST38VcFSYhPl56Ggba12RFA0mjueG
i tried with hidden and public @moviebrain
@davidesidoti I tested it in my fork of music.py and everything loads except the second song in your playlist Jonas Blue. That song appears to be blocked in the USA and is why YTDL is throwing the error. Give music py a minute or two to ingest the whole 91 other songs and it’ll start playing without a problem (or, rather, did for me)
@moviebrain After waiting a little bit it actually load but queue only the first song for me. I am in Europe, could it be that all the other songs are blocked here?
@davidesidoti this gets off topic for this python program, but you can pass the playlist url to YouTube-dl and list the stream formats for every playlist item. If the song is unavailable from where ever you are it’ll output “Error: Video Unavailable” instead of the webm/mp4/etc info by using the following command in a terminal:
youtube-dl —list-formats {playlist url}
Or you can click each of those individual videos and see if YouTube gets mad.
@moviebrain I'll try, thank you for your help 😄
Added a command with bot.add_command(Music.play_), but when I try to use the command, I get
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Music.play_() missing 1 required positional argument: 'ctx'
Any ideas?
Added a command with
bot.add_command(Music.play_), but when I try to use the command, I getdiscord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Music.play_() missing 1 required positional argument: 'ctx'
Any ideas?
Maybe try passing (ctx) as an argument to the function. That's what the error suggests atleast.
Anyone else have the bot skip to the next song in queue at the middle of the song?
Anyone else have the bot skip to the next song in queue at the middle of the song?
I am experiencing that also, I have no idea how to fix it. For me it cuts out partially through at roughly the same spot in the song and its different depending on the song, and it does not continue to the next song in the queue.
Anyone else have the bot skip to the next song in queue at the middle of the song?
I am experiencing that also, I have no idea how to fix it. For me it cuts out partially through at roughly the same spot in the song and its different depending on the song, and it does not continue to the next song in the queue.
I believe this behavior is because YouTube has changed how streaming links expire, and the mechanism by which the stream links are regathered in this code no longer work due to this aggressive new policy. I’ve modified the behavior to prefer downloads and play “locally” with ffmpeg transformer instead of streaming links until it’s discovered why streaming can’t be regathered or refreshed.
Thanks for posting this! This helped me build my music bot cog
Its with
ffmpeg, Its multiple reasons tbh, Its also YouTube, your bandwidth, ffmpeg and discord.py[voice]