Search code examples
pythondiscorddiscord.py

Problem with discord bot joining voice channel


import discord
from discord.ext import commands


class Music(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_ready(self):
        print("music.py is ready!")

    @commands.command(aliases=["j"])
    async def join(self, ctx):
        if not ctx.author.voice:
            await ctx.send("...")
        else:
            channel = ctx.author.voice.channel
            await channel.connect()


async def setup(bot):
    await bot.add_cog(Music(bot))
  • The bot "knows" when I'm in the voice channel and which one I use.
  • I've tried to install and uninstall, and install again discord.py[voice]
  • I've checked many times for permissions and they are there
  • I've tried with roles permissions
  • I didn't try with slash commands but will it work?

I'm not sure where the problem is.


Solution

  • Okay, I had problem with python modules and enviorment variables. Now It's working. Thanks anyway.