def get_name(self, user_id: int, account=None):
"""Get a string representation of a user or guild.
Parameters
----------
user_id: int
User ID to get a string representation of.
account: dict, optional
Account object to determine if this is
A user or a guild to search.
Returns
-------
str
"""
if isinstance(user_id, discord.Guild):
return f'taxbank:{user_id.name}'
elif isinstance(user_id, discord.User):
return str(user_id)
obj = self.bot.get_user(int(user_id))
if not obj:
# try to find guild
obj = self.bot.get_guild(user_id)
if obj:
obj = f'taxbank:{obj}'
if not obj:
# we tried stuff, show a special text
if account:
res = ''
if account['type'] == AccountType.USER:
res = f'Unfindable User {user_id}'
elif account['type'] == AccountType.TAXBANK:
res = f'Unfindable Guild {user_id}'
else:
res = f'Unfindable Unknown {user_id}'
return res
else:
return f'Unfindable ID {user_id}'
return str(obj)
评论列表
文章目录