小弟我最近想試做一個discord音樂機器人,卻發現無法連線至語音頻道
@commands.command()
async def join(self, ctx):
if not ctx.author.voice:
await ctx.send("You are not in a voice channel")
else:
channel = ctx.author.voice.channel
await channel.connect()
輸完指令發現是有運作的,但就是無法連線到語音頻道,機器人也給了伺服器管理員權限,沒有任何報錯。
麻煩各位大佬幫忙解答,謝謝。
可以參考這篇
#這裡的指令會讓機器人進入call他的人所在的語音頻道
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
if ctx.author.voice == None:
await ctx.send("You are not connected to any voice channel")
elif voice == None:
voiceChannel = ctx.author.voice.channel
await voiceChannel.connect()
else:
await ctx.send("Already connected to a voice channel")