Answer the question
In order to leave comments, you need to log in
Why can't the bot enter the VoiceChannel?
Hello everyone, there is one problem. I am developing a music bot for Discord, I need the bot to enter the VoiceChannel, but the error is:
Traceback (most recent call last):
File "/home/kirill/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/kirill/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/kirill/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'channel'
import config
import discord
from discord.ext import commands
import yandex_music
#client = discord.Client(command_prefix = '!')
bot = commands.Bot(command_prefix=config.PREFIX)
@bot.command()
async def hi(ctx):
author = ctx.message.author
await ctx.send(f'sup, {author.mention}')
@bot.command()
async def join(ctx):
channel = ctx.author.voice.channel
await channel.connect()
@bot.command()
async def leave(ctx):
await ctx.voice_client.disconnect()
@bot.command()
async def whoa(ctx):
if ctx.message.content.startswith('!whoa'):
channel = ctx.message.channel
await ctx.channel.send(ctx.message.content[5:].format(ctx.message))
#client = commands.Bot(command_prefix='?', intents = discord.Intents.all())
bot.run(config.TOKEN)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question