s
This commit is contained in:
parent
9923a4f8eb
commit
59f988bb90
|
@ -189,18 +189,43 @@ async def get_user_bio(self, user) -> Optional[str]:
|
|||
# Method 2: Try to fetch user profile specifically
|
||||
if hasattr(user, 'id'):
|
||||
try:
|
||||
# Use fetch_user_profile instead of fetch_user
|
||||
# This is the key change - you need the profile endpoint
|
||||
profile = await self.fetch_user_profile(user.id)
|
||||
# Try multiple profile fetch methods
|
||||
profile = None
|
||||
|
||||
if hasattr(profile, 'bio') and profile.bio:
|
||||
bio = profile.bio
|
||||
self.logger.debug(f"Found bio via profile fetch for {user.name}")
|
||||
elif hasattr(profile, 'display_bio') and profile.display_bio:
|
||||
bio = profile.display_bio
|
||||
self.logger.debug(f"Found display_bio via profile fetch for {user.name}")
|
||||
# Try different possible method names
|
||||
if hasattr(self, 'fetch_user_profile'):
|
||||
profile = await self.fetch_user_profile(user.id)
|
||||
elif hasattr(self, 'fetch_profile'):
|
||||
profile = await self.fetch_profile(user.id)
|
||||
elif hasattr(user, 'fetch_profile'):
|
||||
profile = await user.fetch_profile()
|
||||
else:
|
||||
self.logger.debug(f"No bio found in profile for {user.name}")
|
||||
# Fallback to regular fetch_user and check for profile attr
|
||||
fetched_user = await self.fetch_user(user.id)
|
||||
if hasattr(fetched_user, 'profile'):
|
||||
profile = fetched_user.profile
|
||||
else:
|
||||
profile = fetched_user
|
||||
|
||||
|
||||
if profile:
|
||||
# Check all possible bio attributes
|
||||
bio_attrs = ['bio', 'display_bio', 'about', 'about_me', 'description']
|
||||
for attr in bio_attrs:
|
||||
if hasattr(profile, attr):
|
||||
bio_value = getattr(profile, attr)
|
||||
if bio_value:
|
||||
bio = bio_value
|
||||
self.logger.debug(f"Found {attr} via profile fetch for {user.name}")
|
||||
break
|
||||
|
||||
if not bio:
|
||||
self.logger.debug(f"Profile found but no bio attributes for {user.name}")
|
||||
# Debug: log available attributes
|
||||
attrs = [attr for attr in dir(profile) if not attr.startswith('_')]
|
||||
self.logger.debug(f"Available profile attributes: {attrs}")
|
||||
else:
|
||||
self.logger.debug(f"No profile method available for {user.name}")
|
||||
|
||||
except discord.Forbidden:
|
||||
self.logger.debug(f"Access denied to profile for {user.name} - user may have privacy settings enabled")
|
||||
|
@ -214,16 +239,21 @@ async def get_user_bio(self, user) -> Optional[str]:
|
|||
# Method 3: Try member profile if in a guild context
|
||||
if not bio and hasattr(user, 'guild') and user.guild:
|
||||
try:
|
||||
member_profile = await user.guild.fetch_member_profile(user.id)
|
||||
if hasattr(member_profile, 'bio') and member_profile.bio:
|
||||
bio = member_profile.bio
|
||||
self.logger.debug(f"Found bio via member profile for {user.name}")
|
||||
elif hasattr(member_profile, 'display_bio') and member_profile.display_bio:
|
||||
bio = member_profile.display_bio
|
||||
self.logger.debug(f"Found display_bio via member profile for {user.name}")
|
||||
elif hasattr(member_profile, 'guild_bio') and member_profile.guild_bio:
|
||||
bio = member_profile.guild_bio
|
||||
self.logger.debug(f"Found guild_bio via member profile for {user.name}")
|
||||
member_profile = None
|
||||
if hasattr(user.guild, 'fetch_member_profile'):
|
||||
member_profile = await user.guild.fetch_member_profile(user.id)
|
||||
elif hasattr(user, 'fetch_member_profile'):
|
||||
member_profile = await user.fetch_member_profile()
|
||||
|
||||
if member_profile:
|
||||
bio_attrs = ['bio', 'display_bio', 'guild_bio', 'about', 'about_me']
|
||||
for attr in bio_attrs:
|
||||
if hasattr(member_profile, attr):
|
||||
bio_value = getattr(member_profile, attr)
|
||||
if bio_value:
|
||||
bio = bio_value
|
||||
self.logger.debug(f"Found {attr} via member profile for {user.name}")
|
||||
break
|
||||
except discord.Forbidden:
|
||||
self.logger.debug(f"Access denied to member profile for {user.name}")
|
||||
except Exception as e:
|
||||
|
@ -245,7 +275,7 @@ async def get_user_bio(self, user) -> Optional[str]:
|
|||
except Exception as e:
|
||||
self.logger.debug(f"Could not fetch bio for user {user.name}: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def _get_user_status(self, user) -> Optional[str]:
|
||||
"""Get user status with better handling."""
|
||||
if not self.config.collect_status:
|
||||
|
|
Loading…
Reference in a new issue