Discord.py Bot没有离开语音通道

时间:2018-11-04 20:26:30

标签: python discord discord.py

我目前正在尝试编写一个discord.py机器人,但在尝试使该机器人离开频道时遇到了一个问题。我一直在网上寻找,但无法找到解决我问题的方法。

我正在使用的库:

import discord
import asyncio
import random
import time
import youtube_dl
from discord.ext import commands
from discord.ext.commands import Bot
from discord import Game
from discord import opus

我正在使用的代码:

@client.command(pass_context=True)
async def summon(ctx):
    channel = ctx.message.author.voice.voice_channel
    vc = await client.join_voice_channel(channel)

@client.command(name = "check",
                pass_context=True)
async def check(ctx):
    server = ctx.message.server
    if client.is_voice_connected(server):
        await client.say("Yes")
    else:
        await client.say("No")

@client.command(pass_context=True)
async def leave(ctx):
    for x in client.voice_clients:
        if(x.server == ctx.message.server):
            return await x.discconect()
    return await client.say("Mission Failed."

我收到的错误消息:

忽略命令召唤中的异常 追溯(最近一次通话):

文件“ C:\ Program Files(x86)\ Python36-32 \ lib \ site-packages \ discord \ ext \ commands \ core.py”,第50行,已包装     ret =来自coro(* args,** kwargs)的收益

文件“ A:/ Python / MossyBot / Bot版本1.0.py”,第53行,摘要     vc =等待client.join_voice_channel(channel)

文件“ C:\ Program Files(x86)\ Python36-32 \ lib \ site-packages \ discord \ client.py”,行3209,在join_voice_channel中     voice = VoiceClient(** kwargs)

“ strong:init 中的文件“ C:\ Program Files(x86)\ Python36-32 \ lib \ site-packages \ discord \ voice_client.py”,第217行     引发RuntimeError(“使用语音需要PyNaCl库”)

RuntimeError:需要PyNaCl库才能使用语音

1 个答案:

答案 0 :(得分:2)

最后一行告诉您您需要了解的内容。

pip运行PyNaCL安装,这是大多数语音功能所必需的,例如:

pip install pynacl
相关问题