Answer the question
In order to leave comments, you need to log in
What to do if the bot does not find the user on the server?
I have a code that checks the database every minute for time out. And if the time is up, it removes the role and deletes the line from the database.
And after I got the user id, I want to convert it to an object. But I get an error:
member = main_guild.get_member(member_id)
AttributeError: 'NoneType' object has no attribute 'get_member'
@tasks.loop(minutes=1.0)
async def mutes(self):
ended = self.nakaz.find({'mute_time': {'$lte': time.time()}})
for mute in ended:
main_guild = self.bot.get_guild(820618566163628034)
member_id = mute["_id"]
print(member_id)
member = main_guild.get_member(member_id)
muted = main_guild.get_role(913833814021787709)
await member.remove_roles(muted)
self.nakaz.delete_one(mute)
Answer the question
In order to leave comments, you need to log in
member = main_guild.get_member(member_id)
AttributeError: 'NoneType' object has no attribute 'get_member'
Well, guess what, there is no such guild. ID accurately not mixed up?
Also, are you sure the function doesn't run before the bot has connected?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question