'Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "play" is not found. this happens in python
I am trying to make an bot just like rythm and it gives me this error Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "play" is not found Here's the code:
music.py:
import discord
from discord.ext import commands
import youtube_dl
class music(commands.Cog):
def _init_(self, client):
self.client = client
@commands.command()
async def join(self,ctx):
if ctx.author.voice is None:
await ctx.send("You're not in a voice channel!")
voice_channel = ctx.author.voice.channel
if ctx.voice_client is None:
await voice_channel.connect()
else:
await ctx.voice.client.move_to(voice_channel)
@commands.command()
async def disconnect(self,ctx):
await ctx.voice.client.disconnect()
@commands.command()
async def play(self,ctx,url):
ctx.voice_client.stop()
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': 'vn'}
YDL_OPTIONS = {'format':"bestaudio"}
vc = ctx.voice_client
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
url2 = info['formats'][0]['url']
source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEGOP_OPTIONS)
vc.play(source)
def setup(client):
client.add_cog(music(client))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
