Всем привет, имеется одна проблема. Разрабатываю музыкального бота для Discord, нужно чтобы бот зашёл в VoiceChannel, но ошибка:
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)
Что не так?