Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple music bot written using discord.py rewrite and youtube_dl.
# -*- coding: utf-8 -*-
"""
Copyright (c) 2019 Valentin B.
A simple music bot written in discord.py using youtube-dl.
Though it's a simple example, music bots are complex and require much time and knowledge until they work perfectly.
Use this as an example or a base for your own bot and extend it as you want. If there are any bugs, please let me know.
Requirements:
Python 3.5+
pip install -U discord.py pynacl youtube-dl
You also need FFmpeg in your PATH environment variable or the FFmpeg.exe binary in your bot's directory on Windows.
"""
import asyncio
import functools
import itertools
import math
import random
import discord
import youtube_dl
from async_timeout import timeout
from discord.ext import commands
# Silence useless bug reports messages
youtube_dl.utils.bug_reports_message = lambda: ''
class VoiceError(Exception):
pass
class YTDLError(Exception):
pass
class YTDLSource(discord.PCMVolumeTransformer):
YTDL_OPTIONS = {
'format': 'bestaudio/best',
'extractaudio': True,
'audioformat': 'mp3',
'outtmpl': '%(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',
}
FFMPEG_OPTIONS = {
'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
'options': '-vn',
}
ytdl = youtube_dl.YoutubeDL(YTDL_OPTIONS)
def __init__(self, ctx: commands.Context, source: discord.FFmpegPCMAudio, *, data: dict, volume: float = 0.5):
super().__init__(source, volume)
self.requester = ctx.author
self.channel = ctx.channel
self.data = data
self.uploader = data.get('uploader')
self.uploader_url = data.get('uploader_url')
date = data.get('upload_date')
self.upload_date = date[6:8] + '.' + date[4:6] + '.' + date[0:4]
self.title = data.get('title')
self.thumbnail = data.get('thumbnail')
self.description = data.get('description')
self.duration = self.parse_duration(int(data.get('duration')))
self.tags = data.get('tags')
self.url = data.get('webpage_url')
self.views = data.get('view_count')
self.likes = data.get('like_count')
self.dislikes = data.get('dislike_count')
self.stream_url = data.get('url')
def __str__(self):
return '**{0.title}** by **{0.uploader}**'.format(self)
@classmethod
async def create_source(cls, ctx: commands.Context, search: str, *, loop: asyncio.BaseEventLoop = None):
loop = loop or asyncio.get_event_loop()
partial = functools.partial(cls.ytdl.extract_info, search, download=False, process=False)
data = await loop.run_in_executor(None, partial)
if data is None:
raise YTDLError('Couldn\'t find anything that matches `{}`'.format(search))
if 'entries' not in data:
process_info = data
else:
process_info = None
for entry in data['entries']:
if entry:
process_info = entry
break
if process_info is None:
raise YTDLError('Couldn\'t find anything that matches `{}`'.format(search))
webpage_url = process_info['webpage_url']
partial = functools.partial(cls.ytdl.extract_info, webpage_url, download=False)
processed_info = await loop.run_in_executor(None, partial)
if processed_info is None:
raise YTDLError('Couldn\'t fetch `{}`'.format(webpage_url))
if 'entries' not in processed_info:
info = processed_info
else:
info = None
while info is None:
try:
info = processed_info['entries'].pop(0)
except IndexError:
raise YTDLError('Couldn\'t retrieve any matches for `{}`'.format(webpage_url))
return cls(ctx, discord.FFmpegPCMAudio(info['url'], **cls.FFMPEG_OPTIONS), data=info)
@staticmethod
def parse_duration(duration: int):
minutes, seconds = divmod(duration, 60)
hours, minutes = divmod(minutes, 60)
days, hours = divmod(hours, 24)
duration = []
if days > 0:
duration.append('{} days'.format(days))
if hours > 0:
duration.append('{} hours'.format(hours))
if minutes > 0:
duration.append('{} minutes'.format(minutes))
if seconds > 0:
duration.append('{} seconds'.format(seconds))
return ', '.join(duration)
class Song:
__slots__ = ('source', 'requester')
def __init__(self, source: YTDLSource):
self.source = source
self.requester = source.requester
def create_embed(self):
embed = (discord.Embed(title='Now playing',
description='```css\n{0.source.title}\n```'.format(self),
color=discord.Color.blurple())
.add_field(name='Duration', value=self.source.duration)
.add_field(name='Requested by', value=self.requester.mention)
.add_field(name='Uploader', value='[{0.source.uploader}]({0.source.uploader_url})'.format(self))
.add_field(name='URL', value='[Click]({0.source.url})'.format(self))
.set_thumbnail(url=self.source.thumbnail))
return embed
class SongQueue(asyncio.Queue):
def __getitem__(self, item):
if isinstance(item, slice):
return list(itertools.islice(self._queue, item.start, item.stop, item.step))
else:
return self._queue[item]
def __iter__(self):
return self._queue.__iter__()
def __len__(self):
return self.qsize()
def clear(self):
self._queue.clear()
def shuffle(self):
random.shuffle(self._queue)
def remove(self, index: int):
del self._queue[index]
class VoiceState:
def __init__(self, bot: commands.Bot, ctx: commands.Context):
self.bot = bot
self._ctx = ctx
self.current = None
self.voice = None
self.next = asyncio.Event()
self.songs = SongQueue()
self._loop = False
self._volume = 0.5
self.skip_votes = set()
self.audio_player = bot.loop.create_task(self.audio_player_task())
def __del__(self):
self.audio_player.cancel()
@property
def loop(self):
return self._loop
@loop.setter
def loop(self, value: bool):
self._loop = value
@property
def volume(self):
return self._volume
@volume.setter
def volume(self, value: float):
self._volume = value
@property
def is_playing(self):
return self.voice and self.current
async def audio_player_task(self):
while True:
self.next.clear()
if not self.loop:
# Try to get the next song within 3 minutes.
# If no song will be added to the queue in time,
# the player will disconnect due to performance
# reasons.
try:
async with timeout(180): # 3 minutes
self.current = await self.songs.get()
except asyncio.TimeoutError:
self.bot.loop.create_task(self.stop())
return
self.current.source.volume = self._volume
self.voice.play(self.current.source, after=self.play_next_song)
await self.current.source.channel.send(embed=self.current.create_embed())
await self.next.wait()
def play_next_song(self, error=None):
if error:
raise VoiceError(str(error))
self.next.set()
def skip(self):
self.skip_votes.clear()
if self.is_playing:
self.voice.stop()
async def stop(self):
self.songs.clear()
if self.voice:
await self.voice.disconnect()
self.voice = None
class Music(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
self.voice_states = {}
def get_voice_state(self, ctx: commands.Context):
state = self.voice_states.get(ctx.guild.id)
if not state:
state = VoiceState(self.bot, ctx)
self.voice_states[ctx.guild.id] = state
return state
def cog_unload(self):
for state in self.voice_states.values():
self.bot.loop.create_task(state.stop())
def cog_check(self, ctx: commands.Context):
if not ctx.guild:
raise commands.NoPrivateMessage('This command can\'t be used in DM channels.')
return True
async def cog_before_invoke(self, ctx: commands.Context):
ctx.voice_state = self.get_voice_state(ctx)
async def cog_command_error(self, ctx: commands.Context, error: commands.CommandError):
await ctx.send('An error occurred: {}'.format(str(error)))
@commands.command(name='join', invoke_without_subcommand=True)
async def _join(self, ctx: commands.Context):
"""Joins a voice channel."""
destination = ctx.author.voice.channel
if ctx.voice_state.voice:
await ctx.voice_state.voice.move_to(destination)
return
ctx.voice_state.voice = await destination.connect()
@commands.command(name='summon')
@commands.has_permissions(manage_guild=True)
async def _summon(self, ctx: commands.Context, *, channel: discord.VoiceChannel = None):
"""Summons the bot to a voice channel.
If no channel was specified, it joins your channel.
"""
if not channel and not ctx.author.voice:
raise VoiceError('You are neither connected to a voice channel nor specified a channel to join.')
destination = channel or ctx.author.voice.channel
if ctx.voice_state.voice:
await ctx.voice_state.voice.move_to(destination)
return
ctx.voice_state.voice = await destination.connect()
@commands.command(name='leave', aliases=['disconnect'])
@commands.has_permissions(manage_guild=True)
async def _leave(self, ctx: commands.Context):
"""Clears the queue and leaves the voice channel."""
if not ctx.voice_state.voice:
return await ctx.send('Not connected to any voice channel.')
await ctx.voice_state.stop()
del self.voice_states[ctx.guild.id]
@commands.command(name='volume')
async def _volume(self, ctx: commands.Context, *, volume: int):
"""Sets the volume of the player."""
if not ctx.voice_state.is_playing:
return await ctx.send('Nothing being played at the moment.')
if 0 > volume > 100:
return await ctx.send('Volume must be between 0 and 100')
ctx.voice_state.volume = volume / 100
await ctx.send('Volume of the player set to {}%'.format(volume))
@commands.command(name='now', aliases=['current', 'playing'])
async def _now(self, ctx: commands.Context):
"""Displays the currently playing song."""
await ctx.send(embed=ctx.voice_state.current.create_embed())
@commands.command(name='pause')
@commands.has_permissions(manage_guild=True)
async def _pause(self, ctx: commands.Context):
"""Pauses the currently playing song."""
if not ctx.voice_state.is_playing and ctx.voice_state.voice.is_playing():
ctx.voice_state.voice.pause()
await ctx.message.add_reaction('⏯')
@commands.command(name='resume')
@commands.has_permissions(manage_guild=True)
async def _resume(self, ctx: commands.Context):
"""Resumes a currently paused song."""
if not ctx.voice_state.is_playing and ctx.voice_state.voice.is_paused():
ctx.voice_state.voice.resume()
await ctx.message.add_reaction('⏯')
@commands.command(name='stop')
@commands.has_permissions(manage_guild=True)
async def _stop(self, ctx: commands.Context):
"""Stops playing song and clears the queue."""
ctx.voice_state.songs.clear()
if not ctx.voice_state.is_playing:
ctx.voice_state.voice.stop()
await ctx.message.add_reaction('⏹')
@commands.command(name='skip')
async def _skip(self, ctx: commands.Context):
"""Vote to skip a song. The requester can automatically skip.
3 skip votes are needed for the song to be skipped.
"""
if not ctx.voice_state.is_playing:
return await ctx.send('Not playing any music right now...')
voter = ctx.message.author
if voter == ctx.voice_state.current.requester:
await ctx.message.add_reaction('⏭')
ctx.voice_state.skip()
elif voter.id not in ctx.voice_state.skip_votes:
ctx.voice_state.skip_votes.add(voter.id)
total_votes = len(ctx.voice_state.skip_votes)
if total_votes >= 3:
await ctx.message.add_reaction('⏭')
ctx.voice_state.skip()
else:
await ctx.send('Skip vote added, currently at **{}/3**'.format(total_votes))
else:
await ctx.send('You have already voted to skip this song.')
@commands.command(name='queue')
async def _queue(self, ctx: commands.Context, *, page: int = 1):
"""Shows the player's queue.
You can optionally specify the page to show. Each page contains 10 elements.
"""
if len(ctx.voice_state.songs) == 0:
return await ctx.send('Empty queue.')
items_per_page = 10
pages = math.ceil(len(ctx.voice_state.songs) / items_per_page)
start = (page - 1) * items_per_page
end = start + items_per_page
queue = ''
for i, song in enumerate(ctx.voice_state.songs[start:end], start=start):
queue += '`{0}.` [**{1.source.title}**]({1.source.url})\n'.format(i + 1, song)
embed = (discord.Embed(description='**{} tracks:**\n\n{}'.format(len(ctx.voice_state.songs), queue))
.set_footer(text='Viewing page {}/{}'.format(page, pages)))
await ctx.send(embed=embed)
@commands.command(name='shuffle')
async def _shuffle(self, ctx: commands.Context):
"""Shuffles the queue."""
if len(ctx.voice_state.songs) == 0:
return await ctx.send('Empty queue.')
ctx.voice_state.songs.shuffle()
await ctx.message.add_reaction('✅')
@commands.command(name='remove')
async def _remove(self, ctx: commands.Context, index: int):
"""Removes a song from the queue at a given index."""
if len(ctx.voice_state.songs) == 0:
return await ctx.send('Empty queue.')
ctx.voice_state.songs.remove(index - 1)
await ctx.message.add_reaction('✅')
@commands.command(name='loop')
async def _loop(self, ctx: commands.Context):
"""Loops the currently playing song.
Invoke this command again to unloop the song.
"""
if not ctx.voice_state.is_playing:
return await ctx.send('Nothing being played at the moment.')
# Inverse boolean value to loop and unloop.
ctx.voice_state.loop = not ctx.voice_state.loop
await ctx.message.add_reaction('✅')
@commands.command(name='play')
async def _play(self, ctx: commands.Context, *, search: str):
"""Plays a song.
If there are songs in the queue, this will be queued until the
other songs finished playing.
This command automatically searches from various sites if no URL is provided.
A list of these sites can be found here: https://rg3.github.io/youtube-dl/supportedsites.html
"""
if not ctx.voice_state.voice:
await ctx.invoke(self._join)
async with ctx.typing():
try:
source = await YTDLSource.create_source(ctx, search, loop=self.bot.loop)
except YTDLError as e:
await ctx.send('An error occurred while processing this request: {}'.format(str(e)))
else:
song = Song(source)
await ctx.voice_state.songs.put(song)
await ctx.send('Enqueued {}'.format(str(source)))
@_join.before_invoke
@_play.before_invoke
async def ensure_voice_state(self, ctx: commands.Context):
if not ctx.author.voice or not ctx.author.voice.channel:
raise commands.CommandError('You are not connected to any voice channel.')
if ctx.voice_client:
if ctx.voice_client.channel != ctx.author.voice.channel:
raise commands.CommandError('Bot is already in a voice channel.')
bot = commands.Bot('music.', description='Yet another music bot.')
bot.add_cog(Music(bot))
@bot.event
async def on_ready():
print('Logged in as:\n{0.user.name}\n{0.user.id}'.format(bot))
bot.run('Token')
@collectVood

This comment has been minimized.

Copy link

@collectVood collectVood commented Jan 17, 2019

Getting this error after some time of not using the bot.
Any ideas?

[tls @ 0x20ece50] error:00000000:lib(0):func(0):reason(0)

@fleesu

This comment has been minimized.

Copy link

@fleesu fleesu commented Mar 1, 2019

was ctx.state.voice removed from discord.py because it gives me an AttributeError "Context has no attribute 'ctx.state'" and how should it be replaced?

@vbe0201

This comment has been minimized.

Copy link
Owner Author

@vbe0201 vbe0201 commented Apr 9, 2019

https://gist.github.com/vbe0201/ade9b80f2d3b64643d854938d40a0a2d#gistcomment-2851052
Strange, I'll investigate into this. ctx.state has never been part of discord.py anyways. There's

async def __before_invoke(self, ctx):
    ctx.state = self.get_voice_state(ctx)

which attaches the state attribute which is an instance of VoiceState to the context object before the actual command method gets called.

@vbe0201

This comment has been minimized.

Copy link
Owner Author

@vbe0201 vbe0201 commented Apr 9, 2019

https://gist.github.com/vbe0201/ade9b80f2d3b64643d854938d40a0a2d#gistcomment-2812754
Unfortunately not. At first sight I suppose this is an issue with FFmpeg. Not sure though.

@vbe0201

This comment has been minimized.

Copy link
Owner Author

@vbe0201 vbe0201 commented Aug 23, 2019

Hey @huujin1611, thanks for reporting this. I will investigate when I have time. If you manage to get it to working in the meantime, it would be awesome if you could provide a patch.

@Minecon724

This comment has been minimized.

Copy link

@Minecon724 Minecon724 commented Sep 20, 2019

Stopping does not work, no error is displayed.

@iFuckEggs

This comment has been minimized.

Copy link

@iFuckEggs iFuckEggs commented Nov 3, 2019

@vbe0201 @Minecon724 To fix the stop command not working, just replace if not ctx.voice_state.is_playing: to if ctx.voice_state.is_playing: .

@jornjan

This comment has been minimized.

Copy link

@jornjan jornjan commented Nov 20, 2019

@vbe0201 I'm trying to include your code as a cog in my bot, however for some reason when calling _join, it never gets beyond:
ctx.voice_state.voice = await destination.connect()
Since, the play command invokes the join command, the bot is unable to play music.
Calling play a second time, causes the error An error occurred: Bot is already in a voice channel.
Calling leave after causes the error Not connected to any voice channel.
Which is contradicting, any ideas about the reason for this behaviour?

@thebies

This comment has been minimized.

Copy link

@thebies thebies commented Nov 27, 2019

Hi, im trying to add playlist with a music.play command but gives an error(An error occurred: Command raised an exception: KeyError: 'webpage_url'). Do you mind explaining why and how to solve?? literally no idea why because i never went into that deep with discord.py and youtube_dl(i just wanted to implement a music feature to my existing bot which i figured after a few try). Trying to learn from even with premade code is looking impossible XD
Edit: ur code is 'solid af' btw imo even with copy-paste+ a few changes it worked almost perfectly ^_^

@LegendBegins

This comment has been minimized.

Copy link

@LegendBegins LegendBegins commented Dec 19, 2019

I've found that if the bot times out when the queue is empty, it cannot play another song. I was able to fix this by adding the following attribute to the VoiceState class:
self.exists = True
And then this above the return statement in the exception of the audio_player_task function:
self.exists = False
And finally modify this condition in the Music function get_voice_state:
if not state or not state.exists

The looping mechanism also fails (the player seems to get stuck at the song being in a completed state and rapidly loops audio_player_task function). I haven't had a chance to dive into this as much yet, but I'll update if I resolve it.

@MotionlessMatt

This comment has been minimized.

Copy link

@MotionlessMatt MotionlessMatt commented Dec 23, 2019

The looping mechanism also fails (the player seems to get stuck at the song being in a completed state and rapidly loops audio_player_task function). I haven't had a chance to dive into this as much yet, but I'll update if I resolve it.

Was just about to ask if there was a fix to this. Hopefully you find something! Great work OP! Code is solid. Is there any way I can loop the whole entire current queue, meaning songs don't get cleared from the queue if loop is true?

@epoxe

This comment has been minimized.

Copy link

@epoxe epoxe commented Dec 27, 2019

Any way to add support for youtube playlists?

@rollnthndr

This comment has been minimized.

Copy link

@rollnthndr rollnthndr commented Jan 4, 2020

Is it possible to play local files, if not, what would I need to modify?

Love this so far, it's great and thank you for sharing!

@MotionlessMatt

This comment has been minimized.

Copy link

@MotionlessMatt MotionlessMatt commented Jan 6, 2020

How can I make this queue songs from a YouTube playlist?

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Jan 18, 2020

i got the following error : [tls @ 000001e58cbbe3c0]

@Chugh2

This comment has been minimized.

Copy link

@Chugh2 Chugh2 commented Jan 29, 2020

Can't even find the bot prefix :/

@MotionlessMatt

This comment has been minimized.

Copy link

@MotionlessMatt MotionlessMatt commented Jan 29, 2020

Chugh2 There is no prefix, it is a cog.

@vbe0201

This comment has been minimized.

Copy link
Owner Author

@vbe0201 vbe0201 commented Jan 30, 2020

@Chugh2 @MotionlessMatt Though the main focus lies on the cog, this is a self-contained music bot. From line 513 ongoing, a bot instance with the prefix music. is created.

@vbe0201

This comment has been minimized.

Copy link
Owner Author

@vbe0201 vbe0201 commented Jan 30, 2020

@MotionlessMatt @epoxe @thebies I'm afraid, the functionality for enqueuing YouTube playlists is not implemented for the time being. I'll consider adding this in the future, when I get back to working on this.

@vbe0201

This comment has been minimized.

Copy link
Owner Author

@vbe0201 vbe0201 commented Jan 30, 2020

@AnotherFailure69 I suppose this is an error caused by FFmpeg and not directly related to the bot code.

@vbe0201

This comment has been minimized.

Copy link
Owner Author

@vbe0201 vbe0201 commented Jan 30, 2020

@rollnthndr You'd have to modify the YTDLSource class. You'd have to provide the functionality to read the bytes from a local file and supply them to discord.FFmpegPCMAudio.

Next step is to modify the play function. search might now also take a local path so we need to check this:

if Path(source).exists():  # from pathlib import Path
    source = await YTDLSource.from_local_file(ctx, search)
else:
    source = await YTDLSource.create_source(ctx, search, loop=self.bot.loop)

You could refine this by adding an additional strategy for searching specific directories of songs so you wouldn't have to supply the full path to a file whenever you want to use this.

@AnonymousX86

This comment has been minimized.

Copy link

@AnonymousX86 AnonymousX86 commented Feb 23, 2020

I've added ffmpeg to PATH and added ffmpeg.exe to bot's directory - still getting this error:

An error occurred: Command raised an exception: ClientException: ffmpeg was not found.

@ljszero

This comment has been minimized.

Copy link

@ljszero ljszero commented Feb 26, 2020

how can I use this bot?

@WillDyer

This comment has been minimized.

Copy link

@WillDyer WillDyer commented Feb 28, 2020

heroku host is not working.
bot online, but he cant reproduce music.(he can join to voice, he react on cmds)

Maybe ffmpeg isn't installed on your heroku

@Tsuyuno

This comment has been minimized.

Copy link

@Tsuyuno Tsuyuno commented Mar 7, 2020

I have tried this on my bot but when I tried looping a music, it stops and returns this error:

Traceback (most recent call last):
File "/home/tsuyuno/.local/lib/python3.6/site-packages/discord/player.py", line 598, in run
self._do_run()
File "/home/tsuyuno/.local/lib/python3.6/site-packages/discord/player.py", line 585, in _do_run
data = self.source.read()
File "/home/tsuyuno/.local/lib/python3.6/site-packages/discord/player.py", line 538, in read
ret = self.original.read()
File "/home/tsuyuno/.local/lib/python3.6/site-packages/discord/player.py", line 223, in read
ret = self._stdout.read(OpusEncoder.FRAME_SIZE)
AttributeError: 'NoneType' object has no attribute 'read'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/tsuyuno/.local/lib/python3.6/site-packages/discord/player.py", line 611, in _call_after
self.after(error)
File "/home/tsuyuno/PycharmProjects/RinBot/cogs/music.py", line 243, in play_next_song
raise VoiceError(str(error))
cogs.music.VoiceError: 'NoneType' object has no attribute 'read'

@NexInfinite

This comment has been minimized.

Copy link

@NexInfinite NexInfinite commented Mar 9, 2020

Can't even find the bot prefix :/

Line 491 "music."

@AffinityGH

This comment has been minimized.

Copy link

@AffinityGH AffinityGH commented Apr 3, 2020

pause, resume, and stop features are not working.

@AffinityGH

This comment has been minimized.

Copy link

@AffinityGH AffinityGH commented Apr 3, 2020

pause, resume, and stop features are not working.

simple fix found: in each of the command's if statements, remove the not, and the commands should function as intended.

@pixel3rr0r

This comment has been minimized.

Copy link

@pixel3rr0r pixel3rr0r commented Apr 8, 2020

@LegendBegins @vbe0201 Any updates on the loop function? I've tried modifying a bit myself, but the only thing I've achieved was an infinite 'Now playing' output and an exception in the play_next_song function...

@dc-rothgar

This comment has been minimized.

Copy link

@dc-rothgar dc-rothgar commented Apr 9, 2020

@vbe0201 Any chance you could look into the loop errors, I get the same error as others:

Traceback (most recent call last):
File "C:\Users\X\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\player.py", line 598, in run
self._do_run()
File "C:\Users\X\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\player.py", line 585, in _do_run
data = self.source.read()
File "D:\PY Twitch_Bot\cogs\discord_bot_music.py", line 126, in read
return audioop.mul(self.source.read(), 2, volume or self.volume)
File "C:\Users\X\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\player.py", line 223, in read
ret = self._stdout.read(OpusEncoder.FRAME_SIZE)
AttributeError: 'NoneType' object has no attribute 'read'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\X\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\player.py", line 611, in _call_after
self.after(error)
File "D:\PY Twitch_Bot\cogs\discord_bot_music.py", line 401, in play_next_song
raise VoiceError(str(error))
cogs.discord_bot_music.VoiceError: 'NoneType' object has no attribute 'read'

I've made a few small revisions to try and get the YoutubeDL to download the files and then play music from the local file which seems to be working except for when you try and loop.

Do you have a support discord or something?

I tried to make sense of the error but I guess I don't understand programming enough to fix and I'm stuck. I feel like my source is all the same so I don't understand why the second play/loop isn't working properly unless there is some rewind or similar that needs to be done/

@StPetar

This comment has been minimized.

Copy link

@StPetar StPetar commented Apr 11, 2020

How can I make this bot work with YouTube playlists?

@pixel3rr0r

This comment has been minimized.

Copy link

@pixel3rr0r pixel3rr0r commented Apr 12, 2020

@StPetar This is something you would have to change in the YTDL settings. I've tried this several times, but could never make it work outside the command line. What I do know, is that you would have to download (and not stream) each song of the playlist, which in turn would make it quite ineffcient.

@zolhh

This comment has been minimized.

Copy link

@zolhh zolhh commented Apr 15, 2020

I get the following error when I want to run it on Google Cloud platform

ERROR: mpohX_R0f2I: YouTube said: Invalid parameters.

https://i.stack.imgur.com/j67qo.png

Can anyone help me?

@pixel3rr0r

This comment has been minimized.

Copy link

@pixel3rr0r pixel3rr0r commented Apr 16, 2020

@zolhh Are you using the latest version of youtube-dl?

@maxpereira

This comment has been minimized.

Copy link

@maxpereira maxpereira commented Apr 29, 2020

I've found that if the bot times out when the queue is empty, it cannot play another song. I was able to fix this by adding the following attribute to the VoiceState class:
self.exists = True
And then this above the return statement in the exception of the audio_player_task function:
self.exists = False
And finally modify this condition in the Music function get_voice_state:
if not state or not state.exists

Thank you so much for this comment!!! I was pulling my hair out trying all sorts of different things and all I had to do was scroll down to find this answer....

@Djagur

This comment has been minimized.

Copy link

@Djagur Djagur commented Apr 30, 2020

@DJAPPLE-byte Try adding ytdl.cache.remove() below ytdl = youtube_dl.YoutubeDL(YTDL_OPTIONS).

@TheNuzo

This comment has been minimized.

Copy link

@TheNuzo TheNuzo commented May 3, 2020

When I run the code it says that bot is logged in as correct bot id and I get no errors when trying with IDLE but when I try to use commands in discord chat nothing happens

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented May 4, 2020

@DJAPPLE-byte Try adding ytdl.cache.remove() below ytdl = youtube_dl.YoutubeDL(YTDL_OPTIONS).

It worked, thx

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented May 4, 2020

volume command not working
@commands.command(name='볼륨')
async def _volume(self, ctx: commands.Context, *, volume: int):
"""볼륨조절을 해줍니다."""

    if not ctx.voice_state.is_playing:
        return await ctx.send('나는 음악을 틀고 있지 않아!')

    if 0 > volume > 100:
        return await ctx.send('볼륨은 0과 100 사이여야해!')

    ctx.voice_state.volume = volume / 100
    await ctx.send('현재 볼륨: {}%'.format(volume))
@Djagur

This comment has been minimized.

Copy link

@Djagur Djagur commented May 4, 2020

@DJAPPLE-byte Change ctx.voice_state.volume = volume / 100 to ctx.voice_state.current.source.volume = volume / 100

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented May 6, 2020

now volume worked but
if 0 > volume > 100:
return await ctx.send('볼륨은 0과 100 사이여야해!')
not working this line

@dc-rothgar

This comment has been minimized.

Copy link

@dc-rothgar dc-rothgar commented May 6, 2020

@boba324

This comment has been minimized.

Copy link

@boba324 boba324 commented May 10, 2020

I get like this error showing up every some seconds while the musics playing and only when the first track is playing.
[tls @ 0000023e5afcc840] Error in the pull function.
[https @ 0000023e5afccd00] Will reconnect at 2539504 in 0 second(s), error=I/O error.
[tls @ 0000023e5b08e5c0] Error in the pull function.
[https @ 0000023e5afccd00] Will reconnect at 2949104 in 0 second(s), error=I/O error.
[tls @ 0000023e5cd267c0] Error in the pull function.
[https @ 0000023e5afccd00] Will reconnect at 3358704 in 0 second(s), error=I/O error.
[tls @ 0000023e5afd1d80] Error in the pull function.
[https @ 0000023e5afccd00] Will reconnect at 3801072 in 0 second(s), error=I/O error.
[tls @ 0000023e5cd267c0] Error in the pull function.
[https @ 0000023e5afccd00] Will reconnect at 4227040 in 0 second(s), error=I/O error.

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented May 11, 2020

When bot online too long, play command just add song to list not playing.

@boba324

This comment has been minimized.

Copy link

@boba324 boba324 commented May 11, 2020

now volume worked but
if 0 > volume > 100:
return await ctx.send('볼륨은 0과 100 사이여야해!')
not working this line

it is working but not as intendet xD.
if not -1 > volume > 101:
or
if not 0 >= volume >= 100:
Should do the trick.

@WizzyGeek

This comment has been minimized.

Copy link

@WizzyGeek WizzyGeek commented May 20, 2020

hello, I have deployed this bot on heroku. it queues the songs but never starts playing them.
edit : i got the bot to work by installing opus build pack for heroku by xrisk. then loading opus.
also pause and resume were not working, the fix is to change the and to or . i guess both of them dont return Non-falsy values.

@pixel3rr0r

This comment has been minimized.

Copy link

@pixel3rr0r pixel3rr0r commented May 20, 2020

Hey @TEEN-BOOM, Heroku is not recommended for music bot hosting, as it doesn't support voice package sending. See this image from the official discord.py server:
image

@dc-rothgar

This comment has been minimized.

Copy link

@dc-rothgar dc-rothgar commented May 23, 2020

@wedobevibingtho

This comment has been minimized.

Copy link

@wedobevibingtho wedobevibingtho commented May 28, 2020

Traceback (most recent call last):
  File "test.py", line 23, in <module>
    import youtube_dl
ModuleNotFoundError: No module named 'youtube_dl'

I've installed youtube_dl, I've also found it in C:\Users\username\AppData\Local\Programs\Python\Python36\Lib\site-packages\youtube_dl. Any Help? I've also rebooted my PC

@Munji-Kim

This comment has been minimized.

Copy link

@Munji-Kim Munji-Kim commented May 29, 2020

ERROR: No video formats found

@WizzyGeek

This comment has been minimized.

Copy link

@WizzyGeek WizzyGeek commented May 29, 2020

Traceback (most recent call last):
  File "test.py", line 23, in <module>
    import youtube_dl
ModuleNotFoundError: No module named 'youtube_dl'

I've installed youtube_dl, I've also found it in C:\Users\username\AppData\Local\Programs\Python\Python36\Lib\site-packages\youtube_dl. Any Help? I've also rebooted my PC

Are you using a virtual environment?

@omg-someone-actually

This comment has been minimized.

Copy link

@omg-someone-actually omg-someone-actually commented Jun 6, 2020

when I do $play(I changed the prefix because I have already coded a bot so I just implemented this in) I get this error "An error occurred: Command raised an exception: ClientException: ffmpeg was not found." I have no idea what this means and im very confused. if you are willing to help me can you please add me on discord: omg someone actually#420 I appreciate any help anyone gives
image

@Bocreator

This comment has been minimized.

Copy link

@Bocreator Bocreator commented Jun 6, 2020

How do I even turn on this thing?

@guac420

This comment has been minimized.

Copy link

@guac420 guac420 commented Jun 10, 2020

when I do $play(I changed the prefix because I have already coded a bot so I just implemented this in) I get this error "An error occurred: Command raised an exception: ClientException: ffmpeg was not found." I have no idea what this means and im very confused. if you are willing to help me can you please add me on discord: omg someone actually#420 I appreciate any help anyone gives
image
@bigdaddy015 I sent you a friend request and would like to help if you still need it

@JustinShao1978

This comment has been minimized.

Copy link

@JustinShao1978 JustinShao1978 commented Jun 11, 2020

ERROR: No video formats found

I have that problem too

@guac420

This comment has been minimized.

Copy link

@guac420 guac420 commented Jun 15, 2020

In the forks section, I have added my own code which has a search command added to it

@JustinShao1978

This comment has been minimized.

Copy link

@JustinShao1978 JustinShao1978 commented Jun 16, 2020

In the forks section, I have added my own code which has a search command added to it

Could you show me the code? If that is possible?

@guac420

This comment has been minimized.

Copy link

@guac420 guac420 commented Jun 16, 2020

In the forks section, I have added my own code which has a search command added to it

Could you show me the code? If that is possible?

Here is the link to the fork:
https://gist.github.com/guac420/bc612fd3a35cd00ddc1c221c560daa01

The specific lines of code I have added are:
128-186 the code that searches youtube and displays the first 10 results. This is in the YTDLSource Class
367-372 repeats everything the bot hears into the console (for convenience)
567-593 this is the actual search command that starts the code in the YTDLSource Class
614-620 a command to stop the bot from inside discord

Starting at line 189 I have edited the parse_duration function to my preferences

@yigitgokgz

This comment has been minimized.

Copy link

@yigitgokgz yigitgokgz commented Jun 16, 2020

I want to add spotify support to how can I do that?

@ktsue

This comment has been minimized.

Copy link

@ktsue ktsue commented Jun 18, 2020

Hi! I keep getting this error:
An error occurred: Command raised an exception: ClientException: ffmpeg was not found.

After a lot of googling and research, I have tried the following: Uninstalled and reinstalled, installation via homebrew, install static build, install snapshot, tried importing ffmpeg in both bot.py and db_music (cog) files, i also tried installing ffmpeg-python which shows it in my pips but still isn't recognized (unless i need to change the import ffmpeg lines to import ffmpeg-python?). I also tried moving it to usr/local/bin/ but it says i cant because ffmpeg is a directory.

None of the above seemed to work. Any advice?

@elitejakey

This comment has been minimized.

Copy link

@elitejakey elitejakey commented Jun 19, 2020

Sorry if I sound dumb but how do I play the music. Like what is the command etc

@ImJustaHere

This comment has been minimized.

Copy link

@ImJustaHere ImJustaHere commented Jun 20, 2020

What is the current prefix and how do i change it ;-;

@ImJustaHere

This comment has been minimized.

Copy link

@ImJustaHere ImJustaHere commented Jun 20, 2020

when I do $play(I changed the prefix because I have already coded a bot so I just implemented this in) I get this error "An error occurred: Command raised an exception: ClientException: ffmpeg was not found." I have no idea what this means and im very confused. if you are willing to help me can you please add me on discord: omg someone actually#420 I appreciate any help anyone gives
image

Ik this doesnt answer ur question but how did u change the prefix???

@Myrvek

This comment has been minimized.

Copy link

@Myrvek Myrvek commented Jun 21, 2020

An error occurred: Command raised an exception: DownloadError: ERROR: Unable to download webpage: HTTP Error 429: Too Many Requests (caused by <HTTPError 429: 'Too Many Requests'>)
Ok I was play music and thix

@guac420

This comment has been minimized.

Copy link

@guac420 guac420 commented Jun 23, 2020

when I do $play(I changed the prefix because I have already coded a bot so I just implemented this in) I get this error "An error occurred: Command raised an exception: ClientException: ffmpeg was not found." I have no idea what this means and im very confused. if you are willing to help me can you please add me on discord: omg someone actually#420 I appreciate any help anyone gives
image

Ik this doesnt answer ur question but how did u change the prefix???

In line 513 add the argument:

command_prefix='(YOUR PREFIX)'

So line 513 would look like:

bot = commands.Bot(description='Yet another music bot.', command_prefix='!')

With "!" as an example prefix.

@guac420

This comment has been minimized.

Copy link

@guac420 guac420 commented Jun 28, 2020

Loop Command Fixed!
After like a week of trying to figure it out I came up with a solution.
The edits start at line 294 in my fork of the code:
My_Fork

The only edits made to fix the loop command are in the "audio_player_task" function in the VoiceState Class

My fork also contains code for a search command that shouldn't affect the loop fix.

@Myrvek

This comment has been minimized.

Copy link

@Myrvek Myrvek commented Jun 28, 2020

Hey
I made this in cog and when i write play me het the Error
An error occurred: Command raised an exception: DownloadError: ERROR: Unable to download webpage: HTTP Error 429: Too Many Requests (caused by <HTTPError 429: 'Too Many Requests'>)
Pls help me

@guac420

This comment has been minimized.

Copy link

@guac420 guac420 commented Jun 28, 2020

Hey
I made this in cog and when i write play me het the Error
An error occurred: Command raised an exception: DownloadError: ERROR: Unable to download webpage: HTTP Error 429: Too Many Requests (caused by <HTTPError 429: 'Too Many Requests'>)
Pls help me

Is there a chance that you accidentally looped the ytdl extract_info function? If you could, can you share the code?

@aleeeee1

This comment has been minimized.

Copy link

@aleeeee1 aleeeee1 commented Jun 30, 2020

Uhm hi, how can i send a message when the bot leave the channel for inactivity? i want to send the message in the last channel the bot writted in.

@guac420

This comment has been minimized.

Copy link

@guac420 guac420 commented Jun 30, 2020

Uhm hi, how can i send a message when the bot leave the channel for inactivity? i want to send the message in the last channel the bot writted in.

In between lines 245 and 246 add await self._ctx.send("Your Message")
the except would look like:
except asyncio.TimeoutError:
await self._ctx.send("Your Message")
self.bot.loop.create_task(self.stop())
return
Be sure to ident the lines properly

@tango1337

This comment has been minimized.

Copy link

@tango1337 tango1337 commented Jul 1, 2020

how do you use it lmao, like what commands

@Munji-Kim

This comment has been minimized.

Copy link

@Munji-Kim Munji-Kim commented Jul 8, 2020

If discord bot play music all and leave voice channel after My discord bot doesn't play music if I use play command one more discord bot just add music to list

@guac420

This comment has been minimized.

Copy link

@guac420 guac420 commented Jul 11, 2020

how do you use it lmao, like what commands

Try the help command:
[prefix]help

If you would like to change your prefix or don't know what it is, I have a post explaining how to change it above.

@guac420

This comment has been minimized.

Copy link

@guac420 guac420 commented Jul 11, 2020

If discord bot play music all and leave voice channel after My discord bot doesn't play music if I use play command one more discord bot just add music to list

There is a comment above by LegendBegins that fixes this problem.

Here is the link to the exact comment:
https://gist.github.com/vbe0201/ade9b80f2d3b64643d854938d40a0a2d#gistcomment-3115864

@Munji-Kim

This comment has been minimized.

Copy link

@Munji-Kim Munji-Kim commented Jul 12, 2020

I can't use Loop command. It's not working.

@guac420

This comment has been minimized.

Copy link

@guac420 guac420 commented Jul 12, 2020

I can't use Loop command. It's not working.

Did you happen to try the fix I posted above?

The exact link is:
https://gist.github.com/vbe0201/ade9b80f2d3b64643d854938d40a0a2d#gistcomment-3357079

@aleeeee1

This comment has been minimized.

Copy link

@aleeeee1 aleeeee1 commented Jul 12, 2020

How to do an np command that show you the progress-slider with the actual min/seconds of the song that's is begin played

@aleeeee1

This comment has been minimized.

Copy link

@aleeeee1 aleeeee1 commented Jul 12, 2020

@guac420 can i have your discord

@aleeeee1

This comment has been minimized.

Copy link

@aleeeee1 aleeeee1 commented Jul 12, 2020

here's my actual bot's code and i can't figure out why the hell the search command doesn't work. It looks like the client.wait_for doesn't work. Pls i need some help i spent all the day tring do this but i came out with nothing.

@dc-rothgar

This comment has been minimized.

Copy link

@dc-rothgar dc-rothgar commented Jul 12, 2020

@guac420

This comment has been minimized.

Copy link

@guac420 guac420 commented Jul 14, 2020

@00Ale00
My discord is
Guac#7689

Sorry it took so long for me to respond I will be faster on discord

@aleeeee1

This comment has been minimized.

Copy link

@aleeeee1 aleeeee1 commented Jul 14, 2020

I sent you friend request, I'm BAKA

@Lenart12

This comment has been minimized.

Copy link

@Lenart12 Lenart12 commented Jul 19, 2020

Maybe we can add an autoplay when the queue is finished

I did some already

import requests
from bs4 import BeautifulSoup

# Spoof user agent as a webcrawler so it displays the whole page
headers = {'User-Agent' : 'Mozilla/5.0 (compatible; Bingbot/2.0; +http://www.bing.com/bingbot.htm)'}
# The song that we want recommended videos for
page = 'https://www.youtube.com/watch?v=2r9vLnmacLE'

res = requests.get(page, headers=headers)
soup = BeautifulSoup(res.text, features='lxml')

# Parse all the recommended videos out of the response and store them in a list
rec = []
for li in soup.find_all('li', class_='related-list-item'):
    a = li.find('a')

    # Only videos (no mixes or playlists)
    if 'content-link' in a.attrs['class']:
        rec.append(a.get('href'))


print(rec)

I can do it on my own later when I have the time

EDIT:
I forked @guac420's version and added in an autoplay feature - here https://gist.github.com/Lenart12/024222b63db38c65f68b57ae7e623d56

EDIT2: I made it into a repository here https://github.com/Lenart12/GodecBot

@ChonkyWonky

This comment has been minimized.

Copy link

@ChonkyWonky ChonkyWonky commented Jul 24, 2020

[tls @ 0x170be40] Error in the pull function.
[https @ 0x14bfa70] Will reconnect at 2670576 in 0 second(s), error=Input/output error.

Plays it the voice channel but it seems to distort/buffer the audio. Maybe my pi cannot compensate for the bitrate?

@zOIDAdaJulian

This comment has been minimized.

Copy link

@zOIDAdaJulian zOIDAdaJulian commented Aug 11, 2020

I get like this error showing up every some seconds while the musics playing and only when the first track is playing.
[tls @ 0000023e5afcc840] Error in the pull function.
[https @ 0000023e5afccd00] Will reconnect at 2539504 in 0 second(s), error=I/O error.
[tls @ 0000023e5b08e5c0] Error in the pull function.
[https @ 0000023e5afccd00] Will reconnect at 2949104 in 0 second(s), error=I/O error.
[tls @ 0000023e5cd267c0] Error in the pull function.
[https @ 0000023e5afccd00] Will reconnect at 3358704 in 0 second(s), error=I/O error.
[tls @ 0000023e5afd1d80] Error in the pull function.
[https @ 0000023e5afccd00] Will reconnect at 3801072 in 0 second(s), error=I/O error.
[tls @ 0000023e5cd267c0] Error in the pull function.
[https @ 0000023e5afccd00] Will reconnect at 4227040 in 0 second(s), error=I/O error.

@boba324 same Error here /:

@RAINGM1

This comment has been minimized.

Copy link

@RAINGM1 RAINGM1 commented Aug 12, 2020

guys, u can use lavalink

@jaedan1010

This comment has been minimized.

Copy link

@jaedan1010 jaedan1010 commented Aug 14, 2020

def play_next_song(self, error=None):
        if error:
            raise VoiceError(str(error))

        self.next.set()

Here


Traceback (most recent call last):
File "C:\Program Files\Python37\lib\site-packages\discord\player.py", line 611, in _call_after
self.after(error)
File "c:\Users\GUEST1209\Desktop\bot\test.py", line 252, in play_next_song
raise VoiceError(str(error))
VoiceError: 'NoneType' object has no attribute 'read'

The error appears. How can I fix this error?

  • For reference, it appears when using the loop command.
@Jay-Surana

This comment has been minimized.

Copy link

@Jay-Surana Jay-Surana commented Aug 24, 2020

what is the prefix?

@EdibleDank-bruh

This comment has been minimized.

Copy link

@EdibleDank-bruh EdibleDank-bruh commented Aug 24, 2020

im dieing to find prefix

@EdibleDank-bruh

This comment has been minimized.

Copy link

@EdibleDank-bruh EdibleDank-bruh commented Aug 24, 2020

@Jay-Surana pls can u tell if u found it

@EdibleDank-bruh

This comment has been minimized.

Copy link

@EdibleDank-bruh EdibleDank-bruh commented Aug 24, 2020

when I do $play(I changed the prefix because I have already coded a bot so I just implemented this in) I get this error "An error occurred: Command raised an exception: ClientException: ffmpeg was not found." I have no idea what this means and im very confused. if you are willing to help me can you please add me on discord: omg someone actually#420 I appreciate any help anyone gives
image

Ik this doesnt answer ur question but how did u change the prefix???

In line 513 add the argument:

command_prefix='(YOUR PREFIX)'

So line 513 would look like:

bot = commands.Bot(description='Yet another music bot.', command_prefix='!')

With "!" as an example prefix.

I tried that before but it says that init has multiple arguments for value "command_prefix"

I think it has a prefix already
Can you tell me please if you find the prefix

@MrDragonBoi

This comment has been minimized.

Copy link

@MrDragonBoi MrDragonBoi commented Aug 26, 2020

I keep getting this error:
__iter__ returns non-iterator
In this code:
def __iter__(self): return self._queue.__iter__()

What the heck is going on?

@justanothernoob4648

This comment has been minimized.

Copy link

@justanothernoob4648 justanothernoob4648 commented Aug 31, 2020

I keep getting this error:
__iter__ returns non-iterator
In this code:
def __iter__(self): return self._queue.__iter__()

What the heck is going on?

dont worry, it doesnt effect the code, its just saying the iter command isnt doing what it normally does, but it's fine

@mattehie

This comment has been minimized.

Copy link

@mattehie mattehie commented Sep 2, 2020

when I do $play(I changed the prefix because I have already coded a bot so I just implemented this in) I get this error "An error occurred: Command raised an exception: ClientException: ffmpeg was not found." I have no idea what this means and im very confused. if you are willing to help me can you please add me on discord: omg someone actually#420 I appreciate any help anyone gives
image

Ik this doesnt answer ur question but how did u change the prefix???

In line 513 add the argument:

command_prefix='(YOUR PREFIX)'

So line 513 would look like:

bot = commands.Bot(description='Yet another music bot.', command_prefix='!')

With "!" as an example prefix.

when i do this i get the error: " Traceback (most recent call last):
File "S:\music bot", line 490, in
bot = commands.Bot('music.', description='Yet another music bot.', command_prefix='Music')
TypeError: init() got multiple values for argument 'command_prefix' "

@justanothernoob4648

This comment has been minimized.

Copy link

@justanothernoob4648 justanothernoob4648 commented Sep 2, 2020

when I do $play(I changed the prefix because I have already coded a bot so I just implemented this in) I get this error "An error occurred: Command raised an exception: ClientException: ffmpeg was not found." I have no idea what this means and im very confused. if you are willing to help me can you please add me on discord: omg someone actually#420 I appreciate any help anyone gives
image

Ik this doesnt answer ur question but how did u change the prefix???

In line 513 add the argument:
command_prefix='(YOUR PREFIX)'
So line 513 would look like:
bot = commands.Bot(description='Yet another music bot.', command_prefix='!')
With "!" as an example prefix.

when i do this i get the error: " Traceback (most recent call last):
File "S:\music bot", line 490, in
bot = commands.Bot('music.', description='Yet another music bot.', command_prefix='Music')
TypeError: init() got multiple values for argument 'command_prefix' "

I think I can answer both of your questions. For ffmpeg not found, you have to add ffmpeg to your path. There are several yt vids on how. If you have done that already, then you need to restart your pc. As for the prefix, since this is a cog, you can’t change the prefix in it. Go to your main file, and change your prefix there. Btw, you don’t need bot = commands.Bot() this is already in the main and doesn’t need to be repeated

@aleeeee1

This comment has been minimized.

Copy link

@aleeeee1 aleeeee1 commented Sep 8, 2020

The goddam prefix is "music." why are you here only for steal code, you didn't even know what is a prefix

@i1470s

This comment has been minimized.

Copy link

@i1470s i1470s commented Oct 4, 2020

would this work on a ubuntu machine?

@Minecon724

This comment has been minimized.

Copy link

@Minecon724 Minecon724 commented Oct 4, 2020

would this work on a ubuntu machine?

yes

@i1470s

This comment has been minimized.

Copy link

@i1470s i1470s commented Oct 4, 2020

hmm im finding that when the bot is online for too long it just adds the song to queue anyone have a solution?

@LegendBegins

This comment has been minimized.

Copy link

@LegendBegins LegendBegins commented Oct 5, 2020

hmm im finding that when the bot is online for too long it just adds the song to queue anyone have a solution?

See this: https://gist.github.com/vbe0201/ade9b80f2d3b64643d854938d40a0a2d#gistcomment-3115864

@i1470s

This comment has been minimized.

Copy link

@i1470s i1470s commented Oct 5, 2020

hmm im finding that when the bot is online for too long it just adds the song to queue anyone have a solution?

See this: https://gist.github.com/vbe0201/ade9b80f2d3b64643d854938d40a0a2d#gistcomment-3115864

ahh thank you very much!

@MagnaMadness

This comment has been minimized.

Copy link

@MagnaMadness MagnaMadness commented Oct 7, 2020

uhhmm can anyone send the entire modified corrected proper code plss

@justanothernoob4648

This comment has been minimized.

Copy link

@justanothernoob4648 justanothernoob4648 commented Oct 19, 2020

anyone get this error?
youtube_dl.utils.DownloadError: ERROR: query "song": Failed to parse JSON (caused by JSONDecodeError('Expecting value: line 1 column 1 (char 0)'))

@LeRubix

This comment has been minimized.

Copy link

@LeRubix LeRubix commented Oct 19, 2020

When i try to play a song, using a search or url, it starts typing, sends nothing and does absolutely nothing but it has the ring around the bot as if it's making sound. connecting fine and sending the connected message fine but currently the only commands i see actually working are connect and stop.

@zOIDAdaJulian

This comment has been minimized.

Copy link

@zOIDAdaJulian zOIDAdaJulian commented Oct 21, 2020

anyone get this error?
youtube_dl.utils.DownloadError: ERROR: query "song": Failed to parse JSON (caused by JSONDecodeError('Expecting value: line 1 column 1 (char 0)'))

Yea. Same Error here

@StarTwi

This comment has been minimized.

Copy link

@StarTwi StarTwi commented Oct 22, 2020

in line 160 i am getting an error saying "iter returns non-iterator"
please help me and tell what shall i do?

@AravinthSS07

This comment has been minimized.

Copy link

@AravinthSS07 AravinthSS07 commented Oct 22, 2020

can anyone say what is the prefix of this bot or i have to assign one

@resuther

This comment has been minimized.

Copy link

@resuther resuther commented Oct 23, 2020

When i run the bot i get
ERROR: query "song": Failed to parse JSON (caused by JSONDecodeError('Expecting value: line 1 column 1 (char 0)'))

Any help? It seems others are getting it too

@aleeeee1

This comment has been minimized.

Copy link

@aleeeee1 aleeeee1 commented Oct 23, 2020

i'm getting that error too

@aleeeee1

This comment has been minimized.

Copy link

@aleeeee1 aleeeee1 commented Oct 23, 2020

@i1470s

This comment has been minimized.

Copy link

@i1470s i1470s commented Oct 23, 2020

When i run the bot i get
ERROR: query "song": Failed to parse JSON (caused by JSONDecodeError('Expecting value: line 1 column 1 (char 0)'))

Any help? It seems others are getting it too

hello guys this is an error with the YTDL library youtube added something to there site and its causing this error head over to the YTDL repo and check there!

@gtxyqjc

This comment has been minimized.

Copy link

@gtxyqjc gtxyqjc commented Oct 25, 2020

how can I add reaction under the embed message, I saw the reaction emoji in the code but it doesn't show on discord.

@WizzyGeek

This comment has been minimized.

Copy link

@WizzyGeek WizzyGeek commented Oct 27, 2020

To anyone wondering why this does not work anymore the YTDL repo was taken down due to a DMCA take-down request from RIAA to GitHub. YouTube also might have updated their internals which has made the lib (on PyPi) outdated

@MrDragonBoi

This comment has been minimized.

Copy link

@MrDragonBoi MrDragonBoi commented Oct 27, 2020

To anyone wondering why this does not work anymore the YTDL repo was taken down due to a DMCA take-down request from RIAA to GitHub. YouTube also might have updated their internals which has made the lib (on PyPi) outdated

Yup, that's why lavalink.py OR wavelink is better. Use either one

@LegendBegins

This comment has been minimized.

Copy link

@LegendBegins LegendBegins commented Oct 27, 2020

Having a takedown notice doesn't make one library better than the other. Regardless, it's an invalid takedown of legitimate open-source software and will likely be fought and revoked.

@devsapariya94

This comment has been minimized.

Copy link

@devsapariya94 devsapariya94 commented Nov 5, 2020

An error occurred: Command raised an exception: ClientException: ffmpeg was not found.

the error come

@i1470s

This comment has been minimized.

Copy link

@i1470s i1470s commented Nov 9, 2020

An error occurred: Command raised an exception: ClientException: ffmpeg was not found.

the error come

hey man you need to have this installed https://ffmpeg.org/ if your on windows put the exe in the root of the bot and on linux just use the terminal to install the packages :)

@biGGepiKK

This comment has been minimized.

Copy link

@biGGepiKK biGGepiKK commented Nov 10, 2020

why does it say command not found every time i enter a music command, but when i use the other commands fo my bot, it works perfectly.

@resuther

This comment has been minimized.

Copy link

@resuther resuther commented Nov 14, 2020

How do i remove the help command?

@aleeeee1

This comment has been minimized.

Copy link

@aleeeee1 aleeeee1 commented Nov 14, 2020

i still have ERROR: query "song": Failed to parse JSON (caused by JSONDecodeError('Expecting value: line 1 column 1 (char 0)'))
someone has fixed??? help pls

@Dr-locke

This comment has been minimized.

Copy link

@Dr-locke Dr-locke commented Nov 16, 2020

Is the play command broken?

Edit: I tried using the youtube url when using the code I got
ERROR: Unable to extract JS player URL
in the console along with
An error occurred: Command raised an exception: DownloadError: ERROR: Unable to extract JS player URL
In the discord chat
Is there a fix for it?

@LegendBegins

This comment has been minimized.

Copy link

@LegendBegins LegendBegins commented Nov 16, 2020

why does it say command not found every time i enter a music command, but when i use the other commands fo my bot, it works perfectly.

Make sure you're loading the cog correctly.

i still have ERROR: query "song": Failed to parse JSON (caused by JSONDecodeError('Expecting value: line 1 column 1 (char 0)'))
someone has fixed??? help pls

Caused by a problem with youtube-dl parsing. It was just reinstated today, so update to the latest version to fix the problem.

Is the play command broken?

Edit: I tried using the youtube url when using the code I got
ERROR: Unable to extract JS player URL
in the console along with
An error occurred: Command raised an exception: DownloadError: ERROR: Unable to extract JS player URL
In the discord chat
Is there a fix for it?

What URL did you use?

@LegendBegins

This comment has been minimized.

Copy link

@LegendBegins LegendBegins commented Nov 16, 2020