Getting None in message.guild.get_member_named(“member_name”)

女生的网名这么多〃 提交于 2021-02-15 07:45:47

问题


I'm getting NoneType in
message.guild.get_member_named("Testing Account")
and there is a person/account named Testing Account in the discord server.


回答1:


First, make sure your bot has members intent enabled in the developer portal

Enable intents in the code, and pass them in your bot/client with the intents kwarg.

intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix='!', intents=intents)

I will update the question if the way you setup your bot is different than mine.

"If your bot tracks presence data, you may need the presence intent to receive presence event data." - Discord Developer Portal




回答2:


If .get_member_named() is returning None there could be many reasons causing that. You can check if...

  • you typed the name of the account correctly
  • the account is in the guild in which the message was sent
  • the bot has permissions to view the user's profile
  • your bot has logged in correctly

If none of those are the case you can have a look at the get_member_named() documentation or use IDs instead of a name (IDs usually work much more reliably).



来源:https://stackoverflow.com/questions/65355942/getting-none-in-message-guild-get-member-namedmember-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!