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
|
# Method 2: Try to fetch user profile specifically
|
||||||
if hasattr(user, 'id'):
|
if hasattr(user, 'id'):
|
||||||
try:
|
try:
|
||||||
# Use fetch_user_profile instead of fetch_user
|
# Try multiple profile fetch methods
|
||||||
# This is the key change - you need the profile endpoint
|
profile = None
|
||||||
profile = await self.fetch_user_profile(user.id)
|
|
||||||
|
|
||||||
if hasattr(profile, 'bio') and profile.bio:
|
# Try different possible method names
|
||||||
bio = profile.bio
|
if hasattr(self, 'fetch_user_profile'):
|
||||||
self.logger.debug(f"Found bio via profile fetch for {user.name}")
|
profile = await self.fetch_user_profile(user.id)
|
||||||
elif hasattr(profile, 'display_bio') and profile.display_bio:
|
elif hasattr(self, 'fetch_profile'):
|
||||||
bio = profile.display_bio
|
profile = await self.fetch_profile(user.id)
|
||||||
self.logger.debug(f"Found display_bio via profile fetch for {user.name}")
|
elif hasattr(user, 'fetch_profile'):
|
||||||
|
profile = await user.fetch_profile()
|
||||||
else:
|
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:
|
except discord.Forbidden:
|
||||||
self.logger.debug(f"Access denied to profile for {user.name} - user may have privacy settings enabled")
|
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
|
# Method 3: Try member profile if in a guild context
|
||||||
if not bio and hasattr(user, 'guild') and user.guild:
|
if not bio and hasattr(user, 'guild') and user.guild:
|
||||||
try:
|
try:
|
||||||
member_profile = await user.guild.fetch_member_profile(user.id)
|
member_profile = None
|
||||||
if hasattr(member_profile, 'bio') and member_profile.bio:
|
if hasattr(user.guild, 'fetch_member_profile'):
|
||||||
bio = member_profile.bio
|
member_profile = await user.guild.fetch_member_profile(user.id)
|
||||||
self.logger.debug(f"Found bio via member profile for {user.name}")
|
elif hasattr(user, 'fetch_member_profile'):
|
||||||
elif hasattr(member_profile, 'display_bio') and member_profile.display_bio:
|
member_profile = await user.fetch_member_profile()
|
||||||
bio = member_profile.display_bio
|
|
||||||
self.logger.debug(f"Found display_bio via member profile for {user.name}")
|
if member_profile:
|
||||||
elif hasattr(member_profile, 'guild_bio') and member_profile.guild_bio:
|
bio_attrs = ['bio', 'display_bio', 'guild_bio', 'about', 'about_me']
|
||||||
bio = member_profile.guild_bio
|
for attr in bio_attrs:
|
||||||
self.logger.debug(f"Found guild_bio via member profile for {user.name}")
|
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:
|
except discord.Forbidden:
|
||||||
self.logger.debug(f"Access denied to member profile for {user.name}")
|
self.logger.debug(f"Access denied to member profile for {user.name}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -245,7 +275,7 @@ async def get_user_bio(self, user) -> Optional[str]:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.debug(f"Could not fetch bio for user {user.name}: {e}")
|
self.logger.debug(f"Could not fetch bio for user {user.name}: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _get_user_status(self, user) -> Optional[str]:
|
def _get_user_status(self, user) -> Optional[str]:
|
||||||
"""Get user status with better handling."""
|
"""Get user status with better handling."""
|
||||||
if not self.config.collect_status:
|
if not self.config.collect_status:
|
||||||
|
|
Loading…
Reference in a new issue