Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected AtrributeError #9387

Closed
3 of 5 tasks
irregularunit opened this issue May 5, 2023 · 2 comments
Closed
3 of 5 tasks

Unexpected AtrributeError #9387

irregularunit opened this issue May 5, 2023 · 2 comments
Labels
bug This is a bug with the library.

Comments

@irregularunit
Copy link

irregularunit commented May 5, 2023

Summary

Unexpected AtrributeError on when iterating over guild.chunked() or guild.members

Reproduction Steps

  • Load the cog below
  • Join a new guild or invoke the event via eval

Minimal Reproducible Code

from discord.ext import commands

class Cog(commands.Cog):
  def __init__(self, bot):
      self.bot = bot

  @commands.Cog.listener()
  async def on_guild_join(self, guild):
      members = await guild.chunk() if guild.chunked else guild.members

      for member in members:
            try:
                # Raises AtrributeError for ClientUser
                if len(member.mutual_guilds) > 1:
            except AttributeError:
                ...

Expected Results

Either a type-warning that the list or sequence can/contains a ClientUser | discord.Member obj or it being removed completely.

Actual Results

Unexpected error we have to catch while development.

Intents

guilds, members, messages, message_content, presences

System Information

OS: FreeBSD 13.0-RELEASE-p10 amd64
Discord Version: 2.3.0a

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

@irregularunit irregularunit added the unconfirmed bug A bug report that needs triaging label May 5, 2023
@Rapptz Rapptz added no repro Cannot be reproduced. and removed unconfirmed bug A bug report that needs triaging labels May 5, 2023
@Rapptz
Copy link
Owner

Rapptz commented May 5, 2023

Looking at the code I see no way for this to happen so I'm going to need more information.

@Rapptz Rapptz added bug This is a bug with the library. and removed no repro Cannot be reproduced. labels May 5, 2023
@Rapptz
Copy link
Owner

Rapptz commented May 5, 2023

Sorry, I see now what you meant. The issue as presented was insufficient due to not showing the error.

The issue stems from the internal User object that the Member is encapsulating being a ClientUser and causing an attribute error since it has no mutual_guilds property for some reason. The way this issue was presented made it seem like Guild.members returned a ClientUser instance instead of a Member, which is impossible.

@Rapptz Rapptz closed this as completed in 252ac38 May 5, 2023
AbstractUmbra pushed a commit to AbstractUmbra/discord.py that referenced this issue Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a bug with the library.
Projects
None yet
Development

No branches or pull requests

2 participants