3 python discord discord.py discord.py-rewrite
我想让我的不和谐机器人连接到我输入的语音频道!join。我曾尝试使用以下代码执行此操作,但出现此错误:
bot: BotInstance of 'Bot' has no 'voice_client_int' memberpylint(no-member)
我发现我的代码与 rewrite discord 版本不兼容。
@bot.command(pass_context = True)
async def join(ctx):
channel = ctx.message.author.voice.voice_channel
await bot.join_voice_channel(channel)
@bot.command(pass_context = True)
async def leave(ctx):
server = ctx.message.server
voice_client = bot.voice_client_int(server)
await voice_client.disconnect()
Run Code Online (Sandbox Code Playgroud)
有人能帮我吗?
如迁移页面所述,在重写版本中,语音连接现在是VoiceChannel模型的一种方法。该pass_context也不赞成上下文现在总是通过。
现在看起来像这样:
@bot.command()
async def join(ctx):
channel = ctx.author.voice.channel
await channel.connect()
@bot.command()
async def leave(ctx):
await ctx.voice_client.disconnect()
Run Code Online (Sandbox Code Playgroud)
当然,这个过于简化的版本缺乏错误处理。
| 归档时间: |
|
| 查看次数: |
38546 次 |
| 最近记录: |