gpt4 book ai didi

python - Discord.py 机器人不离开语音 channel

转载 作者:行者123 更新时间:2023-11-30 22:04:55 26 4
gpt4 key购买 nike

我正在尝试编写一个discord.py 机器人,但在尝试让机器人离开语音 channel 时遇到了问题。我一直在网上查找,但未能找到解决我的问题的有效解决方案。

我正在使用的库:

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."

我收到的错误消息:

Ignoring exception in command summon
Traceback (most recent call last):

File "C:\Program Files (x86)\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
ret = yield from coro(*args, **kwargs)

File "A:/Python/MossyBot/Bot Version 1.0.py", line 53, in summon
vc = await client.join_voice_channel(channel)

File "C:\Program Files (x86)\Python36-32\lib\site-packages\discord\client.py", line 3209, in join_voice_channel
voice = VoiceClient(**kwargs)

File "C:\Program Files (x86)\Python36-32\lib\site-packages\discord\voice_client.py", line 217, in __init__
raise RuntimeError("PyNaCl library needed in order to use voice")

RuntimeError: PyNaCl library needed in order to use voice

最佳答案

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

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

pip install pynacl

关于python - Discord.py 机器人不离开语音 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53145128/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com