Итак, я пытаюсь закодировать диск-бота, но всякий раз, когда я пытаюсь отключить его, появляется следующая ошибка:
Ignoring exception in command leave
Traceback (most recent call last):
File "D:\Python36\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
ret = yield from coro(*args, **kwargs)
File "D:\new\main.py", line 31, in leave
await voice_client.disconnect()
File "D:\Python36\lib\site-packages\discord\voice_client.py", line 297, in disconnect
yield from self.ws.close()
File "D:\Python36\lib\site-packages\websockets\protocol.py", line 419, in close
yield from asyncio.shield(self.close_connection_task)
File "D:\Python36\lib\site-packages\discord\gateway.py", line 686, in close_connection
yield from super().close_connection(force=force)
TypeError: close_connection() got an unexpected keyword argument 'force'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Python36\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "D:\Python36\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "D:\Python36\lib\site-packages\discord\ext\commands\core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: close_connection() got an unexpected keyword argument 'force'
Я пытался изменить способ получения бота.отключить, но, похоже, он не хочет проходить через эту строку:
await voice_client.disconnect ()
Вот код, который не работает.
import discord
from discord.ext import commands
BOT_PREFIX = ('!')
client = commands.Bot(command_prefix=BOT_PREFIX)
@client.command(pass_context = True)
async def leave(ctx):
server = ctx.message.server
voice_client = client.voice_client_in(server)
if voice_client:
await voice_client.disconnect()
await client.say('Disconnected')
else:
await client.say('I am not in a voice channel')