150_Kirill_150
@150_Kirill_150
FX, Python, C# (Unity), Coding, адепт Linux

Почему бот не может зайти в VoiceChannel?

Всем привет, имеется одна проблема. Разрабатываю музыкального бота для 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)

Что не так?
  • Вопрос задан
  • 155 просмотров
Решения вопроса 1
150_Kirill_150
@150_Kirill_150 Автор вопроса
FX, Python, C# (Unity), Coding, адепт Linux
И так, я болбес
Надо зайти в VoiceChannel самому, а потом уже давать команду для того чтобы зашёл бот
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы