Discord.py-如何获取语音通道的ID?

时间:2019-06-18 19:23:55

标签: python python-3.x discord.py-rewrite

我正在尝试获取作者语音通道的ID。我正在尝试使其链接,您可以单击该链接进入完整的语音通道(如果有必要的话):

@client.command()
async def fullv(ctx):

 guild=ctx.message.guild
 author=ctx.message.author
 channel = 
 vc=f"https://discordapp.com/{guild.id}/{channel.id}"

 embed=discord.Embed(title="Join Full Voice", url=vc, description="Full voice is a DM voice chat in a Discord Server!", color=0x00ff40)

 await ctx.send(embed=embed)

{channel.id}中没有vc=f"https://discordapp.com/{guild.id}/{channel.id}"的情况下,它可以正常工作,但是您无法查看语音通道

1 个答案:

答案 0 :(得分:1)

ctx.author.voice是作者的VoiceState,具有一个channel属性,表示该成员所在的VoiceChannel

if ctx.author.voice and ctx.author.voice.channel:
    channel = ctx.author.voice.channel
else:
    await ctx.send("You are not connected to a voice channel")
    return
相关问题