【问题标题】:How to get user info given discord id using the discord Bot class?如何使用 discord Bot 类获取给定 discord id 的用户信息?
【发布时间】:2021-05-22 23:30:06
【问题描述】:

我正在使用 discord.ext.commands Bot 类。我需要从字典中的 id 获取用户信息,以便我可以直接向他们发送消息。我知道有一种方法可以使用客户端类( .get_user_info() )函数从 id 获取用户信息,但是我没有使用客户端类,只使用 Bot 类。有没有办法使用 bot 类获取用户信息?

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    使用user = bot.fetch_user(id)。之后就可以通过user访问用户的所有属性,比如user.display_name

    【讨论】:

      猜你喜欢
      • 2021-01-03
      • 1970-01-01
      • 2021-03-15
      • 2022-12-09
      • 2021-12-12
      • 2020-07-05
      • 2021-07-19
      • 2018-06-29
      • 2019-12-11
      相关资源
      最近更新 更多