【问题标题】:How to get the ID of a given voice channel? - Discord.py如何获取给定语音通道的 ID? - 不和谐.py
【发布时间】:2021-03-11 12:17:53
【问题描述】:

我有下面这行代码,它是用来接收一个频道并给出它的id。

channel = discord.utils.get(message.guild.channels, name='general', type="ChannelType.voice")
print(channel)

它最终返回None,我做错了吗?

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    get_xutils.get 都返回 None 如果找不到任何匹配项。 常见原因包括:

    • 未订阅相关意图
    • 密钥错误
    • 机器人未登录,并试图从缓存中抓取对象
    • 机器人无法“看到”对象

    你可以试试:

    channel = discord.utils.get(message.guild.voice_channels, name='general')
    

    【讨论】:

      猜你喜欢
      • 2021-09-27
      • 2021-01-18
      • 2021-11-15
      • 2021-04-06
      • 2021-02-10
      • 2021-08-04
      • 2021-11-17
      • 1970-01-01
      • 2021-01-02
      相关资源
      最近更新 更多