'Beginner to Python Discord Music Bot

I'm just trying to get a discord bot to join a VC and play a song Pause & Stop but I am getting these errors.

*Edit: With me being new to Python I am not exactly sure how to fix this. I have read up about examples of these kinds of issues while trying to fix this and transferring them over to this problem has been uneventful with me just gaining more errors in the process.

Old Error

Traceback (most recent call last):
  File "main.py", line 3, in <module>
    import music
  File "/home/runner/Adonnis/music.py", line 13, in <module>
    async def join(self,ctx):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1432, in decorator
    raise TypeError('Callback is already a command.')
TypeError: Callback is already a command.

New Error

Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "join" is not found

Main.py

import discord
from discord.ext import commands
import music
print("Discord version ",discord.__version__)
print("Bot Running")

cogs = [music]

client = commands.Bot(command_prefix='?', intents = discord.Intents.all())

for i in range(len(cogs)):
  cogs[i].setup(client)

client.run(Token) 

Music.py

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))

I've coded this off of https://www.youtube.com/watch?v=jHZlvRr9KxM

Is anyone able to assist me with the debugging of this?

*Edit: I have updated the "Error" sorry that was from an older version where I was trying what worked for someone else.

*Edit:

Packages used:

  • Discord
  • Discord.py
  • Youtube_DL
  • Pineapple

Just in case anyone wants to know what this was coded on also this was made on Replit.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source