示例#1
0
async def get_guild_profile_embed(guild: Guild, brief: bool = True):
    literal = literals('get_guild_profile_embed')
    online_members = (await guild.widget()).members
    description = literal['description'] % (guild.region, guild.member_count)
    if guild.premium_tier:
        description += '\n' + literal['tier'] % guild.premium_tier
    if online_members:
        description += '\n' + (literal['online'] % len(online_members))
    guild_embed = ChainedEmbed(title=guild.name, description=description)
    guild_embed.set_author(name=literal['author'] % guild.owner.name,
                           icon_url=guild.owner.avatar_url)
    guild_embed.set_thumbnail(url=guild.icon_url)
    if not brief:
        if guild.premium_subscription_count:
            guild_embed.add_field(
                name=literal['boost'] % guild.premium_subscription_count,
                value='\n'.join(
                    str(subscriber)
                    for subscriber in guild.premium_subscribers))
        guild_embed.set_footer(text=f'{to_kst(guild.created_at)} · {guild.id}')
        guild_embed.set_image(url=guild.banner_url)
        if guild.channels:
            value = literal['category'] % len(guild.categories)
            value += '\n' + literal['text_channel'] % len(guild.text_channels)
            value += '\n' + literal['voice_channel'] % len(
                guild.voice_channels)
            guild_embed.add_field(name=literal['channel'] %
                                  len(guild.channels),
                                  value=value)
    return guild_embed
示例#2
0
def get_profile_embed(user: User, brief: bool = True):
    literal = literals('get_profile_embed')
    profile_embed = ChainedEmbed(title=user.display_name,
                                 color=user.colour,
                                 description=str(user))
    profile_embed.set_thumbnail(url=user.avatar_url)
    if isinstance(user, Member):
        profile_embed.set_author(name=user.guild.name + ' ' +
                                 user.top_role.name,
                                 icon_url=user.guild.icon_url)
    if not brief:
        profile_embed.set_image(url=user.avatar_url)
        profile_embed.set_footer(text=f'{to_kst(user.created_at)} · {user.id}')
        if isinstance(user, Member):
            profile_embed.add_field(name=literal['join'],
                                    value=to_kst(user.joined_at))
            if user.premium_since:
                profile_embed.add_field(name=literal['boost'],
                                        value=to_kst(user.premium_since))
            if roles := user.roles[1:]:
                roles.reverse()
                profile_embed.add_field(name=literal['roles'],
                                        value='\n'.join(
                                            [role.name for role in roles]))
示例#3
0
 def get_custom_emoji_embed(self, emoji_id: int):
     emoji: PartialEmoji = self.client.get_emoji(emoji_id)
     embed = ChainedEmbed()
     embed.set_image(url=emoji.url)
     embed.set_author(name=f':{emoji.name}:')
     return embed