discord.py bot not responding

55 Views Asked by At

I'm trying to build my first bot, so I'm following the discord.py official examples. I literally copy paste the "basic_voice.py" and didn't touch anything except for token where I replaced it with the my bot's token, this is the code (removed all comands except for join to let the code being more readable here).

import asyncio
import discord
from discord.ext import commands

TOKEN = "..."

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

    @commands.command()
    async def join(self, ctx, *, channel: discord.VoiceChannel):
        """Joins a voice channel"""
        if ctx.voice_client is not None:
            return await ctx.voice_client.move_to(channel)

        await channel.connect()

intents = discord.Intents.default()
intents.members = True
intents.message_content = True

bot = commands.Bot(
    command_prefix="+",
    description='Relatively simple music bot example',
    intents=intents,
)


@bot.event
async def on_ready():
    print(f'Logged in as {bot.user} (ID: {bot.user.id})')
    print('------')


async def main():
    async with bot:
        await bot.add_cog(Music(bot))
        await bot.start(TOKEN)


asyncio.run(main())

I run the main and the ready function works well but then in the server even if I try only to use join (+join) it doesn't respond, it doesn't even enter in the command code block (checked with a print). Tried also basic.py with the super basic add command and even there nothing. What I'm missing? bot has administrator permissions and I literally copy paste the code from the official repo

1

There are 1 best solutions below

0
On BEST ANSWER

have you installed discord.py[voice]?

try run this command:

pip install discord.py[voice]