discord.py - channel.connect() 不工作
discord.py - channel.connect() not working
我正在尝试将我的机器人连接到语音通道并尝试了我可以在网上找到的所有解决方案,但没有任何效果。
当我调用 await channel.connect()
时,程序挂起并且什么都不做
代码片段:
@commands.command()
async def join(self, ctx):
if not ctx.message.author.voice:
ctx.send("You are not in a voice channel")
else:
channel = ctx.message.author.voice.voice_channel
await channel.connect()
我认为你需要改变
ctx.message.author.voice.voice_channel
变成 ctx.message.author.voice.channel
首先,你没有等待ctx.send
,其次discord.VoiceState
没有属性voice_channel
,它是channel
。
固定代码如下:
@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()
我正在尝试将我的机器人连接到语音通道并尝试了我可以在网上找到的所有解决方案,但没有任何效果。
当我调用 await channel.connect()
时,程序挂起并且什么都不做
代码片段:
@commands.command()
async def join(self, ctx):
if not ctx.message.author.voice:
ctx.send("You are not in a voice channel")
else:
channel = ctx.message.author.voice.voice_channel
await channel.connect()
我认为你需要改变
ctx.message.author.voice.voice_channel
变成 ctx.message.author.voice.channel
首先,你没有等待ctx.send
,其次discord.VoiceState
没有属性voice_channel
,它是channel
。
固定代码如下:
@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()