【发布时间】:2020-10-30 22:28:27
【问题描述】:
问题
你好,我正在学习discord.py。在我的编码过程中,我尝试创建一个可以在我的不和谐服务器中加入和离开语音频道的机器人。当我尝试运行代码时出现问题。机器人完美加入频道,但当我在不和谐聊天中输入 ()leave 时,我在控制台中收到此错误。
错误
“VoiceState”对象没有“断开连接”属性
这是我的机器人的代码。
代码
@client.command(pass_context = True) # Join Voice Channel.
async def join(ctx):
channel = ctx.message.author.voice.channel
print(f"Joining into: {channel}.")
await channel.connect()
@client.command(pass_context = True) # Leave Voice Channel.
async def leave(ctx):
channel = ctx.message.author.voice
print(f"Leaving: {channel}.")
await channel.disconnect()
【问题讨论】:
标签: python python-3.x discord.py