【问题标题】:Python discord bot disconnect() function not workingPython discord bot disconnect()函数不起作用
【发布时间】:2019-11-21 04:24:51
【问题描述】:

所以我在 Python3.7 中使用新的 discord.py 重写编写了一个不和谐机器人,我遇到了一个关于在 VoiceClient 上调用的 disconnect() 函数的问题

我的代码如下:

@bot.command()
async def leave(ctx):
    if ctx.author.voice is None:
        await ctx.send("Im not in a channel ")
        return
    await ctx.voice_client.disconnect()

这是一个非常简单的命令,使用 discord.py 的命令扩展名,await ctx.voice_client.disconnect() 行似乎不想工作。

  • 运行时没有报错
  • 我在disconnect() 行之后直接放置了一个调试print("test") 并打印出来
  • 我检查了所有的 API,但目前找不到任何有效的方法
  • 机器人可以完美加入频道
  • 是的,这个leave 命令函数正在被调用
  • 即使之前的检查 (if ctx.author.voice is None:) 在满足条件时也会运行

任何帮助都会很棒,谢谢!

【问题讨论】:

    标签: python discord disconnect


    【解决方案1】:

    解决了! 未在 IDE 中安装和使用正确的库。 在此处找到的库:discord.py Introduction - Libraries

    【讨论】:

      猜你喜欢
      • 2021-10-22
      • 1970-01-01
      • 2022-10-15
      • 2019-01-06
      • 1970-01-01
      • 2020-08-16
      • 2021-02-22
      • 2021-02-28
      • 2020-07-17
      相关资源
      最近更新 更多