Skip to content

[BUG] TypeError 'NoneType' in get_member() if user absent from guild #596

@Donbur4156

Description

@Donbur4156

Describe the bug.

If I try to get an Member Object with get_member() for an absent User it caused a TypeError.
I think it can´t resolve the roles correctly.

Foxtrots hint:
self.roles had to check if _json.get("roles")

List the steps.

Try to create a Member Object:
member = interactions.Member(**await bot._http.get_member(member_id=dc_id, guild_id=serverid), _client=bot._http)
I generalize this, so the Traceback have other variables

What you expected.

I expected a Member Object if User is in Guild.
If not I appreciate a None Object to check if self.member

What you saw.

File "\bot\objects.py", line 79, in get_member_obj
self.member = di.Member(**await self.bot._http.get_member(member_id=self.dc_id, guild_id=c.serverid), _client=self.bot._http)
File "\lib\site-packages\interactions\api\models\member.py", line 75, in init
self.roles = [
TypeError: 'NoneType' object is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'NoneType' object is not iterable

What version of the library did you use?

release

Code of Conduct

  • I agree to follow the contribution requirements.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions