hello i just make a new bot and i got this error
discord.ext.commands.errors.CommandNotFound: Command “play” is not found
wht should i do
-thank for the help
Hello. I’m sorry, but we cannot help you without the code/repl link.
This means the command you programmed was programmed incorrectly. Try giving us the code/repl link like @OmegaOrbitals2 said.
here is the code
(i am a starter)
import discord
from discord.ext import commands
import youtube_dl
class music(commands.Cog):
def __innit__(self, client):
self.client = client
# @commands.command()
@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_channel.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, **FFMPEG_OPTIONS)
vc.play(source)
@commands.command()
async def pause(self, ctx):
await ctx.voice.client.pause()
await ctx.send("Audio Paused ⏸")
@commands.command()
async def resume(self, ctx):
await ctx.voice.client.resume()
await ctx.send("Audio Resumed ⏯")
def setup(client):
client.add_cog(music(client))
it’s def __init__
, not innit
Could you edit your reply like this, so the code is syntax highlighted:
```py
# code here
```
its innit
i dont know why it says like that
it has underscore
but it didnt show
but how many n
s does it have?
If you edit your reply like I mentioned, code will format properly and the underscores won’t be parsed into bold text.
it have 2 undersocere
It showed innit b/c of MD, his error is probably b/c of the he misspelled it __init__
.
This is your code correct:
import discord
from discord.ext import commands
import youtube_dl
class music(commands.Cog):
def __innit__(self, client):
self.client = client
# @commands.command()
@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_channel.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, **FFMPEG_OPTIONS)
vc.play(source)
@commands.command()
async def pause(self, ctx):
await ctx.voice.client.pause()
await ctx.send("Audio Paused ⏸")
@commands.command()
async def resume(self, ctx):
await ctx.voice.client.resume()
await ctx.send("Audio Resumed ⏯")
def setup(client):
client.add_cog(music(client))
If so it should be __init__
, not __innit__
.
i replaced it and it says discord.ext.commands.errors.CommandNotFound: Command “play” is not found
We don’t know things like whether the commands were indented to be in the class, which is why I asked them to edit the reply instead of doing it myself
I just went to their Replit profile xD.
so, the problem is likely that the commands aren’t inside the cog.
Select all the command functions and hit Tab so they’re indented inside the class music
i did it now it says
Traceback (most recent call last):
File "main.py", line 13, in <module>
cogs[i].setup(client)
AttributeError: module 'music' has no attribute 'setup'
did you indent the setup
function as well? That shouldn’t be indented, so it can be accessed by the main file
sorry about that i am a starter
so i did i and it says
File "main.py", line 12
for i in range(len(cogs)):
IndentationError: unexpected indent
IndentationError means you have an error on the indentation. Try checking everything to see that all indentation is correct.
should i indent everything?