discord.py: 你能从他们的 id 中得到一个不在你的 bot 的服务器中的用户的名字吗?

discord.py: Can you get the name of a user that's not in a server with your bot from their id?

我见过 discord 机器人能够从他们的 id 中获取用户的信息(如姓名),而这些信息甚至不在任何服务器上,我想知道这是否可能在 discord.py。我知道

client.get_user(id)

但如果用户不在任何服务器上,机器人将无法工作。你能在 discord.py 中做到这一点吗?

您可以使用 API 调用 fetch_user

user = await client.fetch_user(user_id)

坚持link(官方文档),您就不会在这样的小挫折上浪费时间。