Python discord.py-rewrite';语音客户端&x27;对象没有属性';ws';
以下是代码:Python discord.py-rewrite';语音客户端&x27;对象没有属性';ws';,python,discord.py,discord.py-rewrite,Python,Discord.py,Discord.py Rewrite,以下是代码: @client.command(pass_context=True) async def join(ctx): global voice1 global channel1 channel1 = ctx.author.voice.channel voice1 = get(client.voice_clients, guild=ctx.guild) if voice1 and voice1.
@client.command(pass_context=True)
async def join(ctx):
global voice1
global channel1
channel1 = ctx.author.voice.channel
voice1 = get(client.voice_clients, guild=ctx.guild)
if voice1 and voice1.is_connected():
await voice1.move_to(channel1)
else:
await channel1.connect()
await ctx.send(f"joined {channel1}")
我得到了这个错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError:
'VoiceClient' object has no attribute 'ws'
我试着做一个音乐机器人
@bot.command(name='join', invoke_without_subcommand=True)
async def join(ctx):
destination = ctx.author.voice.channel
if ctx.voice_state.voice:
await ctx.voice_state.voice.move_to(destination)
return
ctx.voice_state.voice = await destination.connect()
await ctx.send(f"Joined {ctx.author.voice.channel} Voice Channel")
试试这个
我认为应该是因为最近discord更改了文档并引入了一些新功能。您确定发布了正确的代码吗?让
voice\u client
是VoiceClient
类的一个实例。您的错误意味着您编写了voice\u client.ws()
。。。您提供的代码中没有类似的内容。你能发布完整的回溯吗,可能有线索吗?