问题
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