【发布时间】:2020-10-14 20:13:28
【问题描述】:
我目前正在为我的不和谐服务器开发一个 discord.py-rewrite (1.3.3) 机器人。目前,我正在尝试让机器人在语音频道中播放音乐。根据 discord.py 文档,您将使用函数 channel.connect() 连接到语音通道,这将返回一个 VoiceClient 对象。
但是,我从来没有从 channel.connect() 得到 VoiceClient 对象。该机器人确实加入了我的频道,但它似乎陷入了无限循环。执行“await channel.connect()”行后没有任何内容,因此不打印“test”行。当我更新 bot 在服务器中的角色时,它可以工作一次,但在我重新启动 bot 后它将不再工作。
# This is just a function, not the command the user calls. The context is passed through
async def join(ctx):
voice_status = ctx.author.voice
# Checking if author voice_status is not none
if voice_status:
# Getting the channel of the author
channel = voice_status.channel
if ctx.voice_client is None:
# Connect the bot
vc = await channel.connect()
print("test")
我在 github 上发现了一些线程并溢出,人们遇到了同样的问题,但他们从未修复它。我很确定代码是正确的。
我已经尝试过重新安装和更新 discord.py。我还在 discord API 服务器中寻求帮助,但他们无法复制我的问题。
这是我的第一个溢出帖子,所以如果我的帖子有任何问题,我提前道歉。
干杯
【问题讨论】:
标签: python bots discord discord.py discord.py-rewrite