Python discord bot - 加入语音频道

Python discord bot - join voice channel

我有兴趣使用 python 制作一个不和谐的机器人。 我正在尝试制作一个可以加入语音频道的机器人。 这是我的代码,我已经 运行 它了,但它不起作用。 我已经在互联网上做了一些研究,但我认为这段代码完全没问题?

   #Join Command
     @client.command()
     async def join(ctx):
         if(ctx.author.voice): #If in voice channel
            channel = ctx.author.voice.channel
            await channel.connect()
    
        else: #If not in voice channel
            await ctx.send("You must be in voice channel first !")

那么知道为什么我的代码不起作用吗? 这是我第一次使用 python 顺便说一句。

@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 机器人加入语音频道。

目的地是已经连接并希望将机器人添加到该频道的人。