Beispiel #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
Beispiel #2
0
 async def king(self, ctx: Context, player1: Member, player2: Member,
                player3: Member, *players: Member):
     players = list(players)
     players.extend((player1, player2, player3))
     tasks = list()
     king = None
     i = 0
     count_description = literals('king')['count'] % (len(players) - 1)
     footer = literals('king')['footer']
     while len(players):
         player1 = players.pop(randrange(0, len(players)))
         if i == 0:
             king = player1
         else:
             embed = ChainedEmbed(title=literals('king')['number'] % i,
                                  description=count_description)
             embed.set_footer(text=footer)
             tasks.append(player1.send(embed=embed))
         i = i + 1
     embed = ChainedEmbed(title=literals('king')['king'] %
                          king.display_name,
                          description=count_description)
     embed.set_image(url=king.avatar_url)
     embed.set_footer(text=footer)
     tasks.append(
         ctx.send(' '.join(
             [member.mention for member in ctx.message.mentions]),
                  embed=embed))
     tasks.append(ctx.message.delete())
     await asyncio.wait(tasks)
Beispiel #3
0
 async def send_command_help(self, ctx: Context, command: Command):
     literal = literals('send_command_help')
     command_name = command.qualified_name
     default_signature = get_command_default_signature(command)
     footer = get_command_signature(command)
     description = ''
     if command.help is not None:
         description = command.help + '\n'
     elif command.brief is not None:
         description = command.brief + '\n'
     description += f'`{default_signature}`'
     embeds = ChainedEmbed(title=get_constant('default_prefix') + command_name, description=description)
     embeds.set_thumbnail(url=self.client.user.avatar_url)
     if not command.enabled:
         embeds.add_field(name=literal['disabled_name'], value=literal['disabled_value'])
     if isinstance(command, CustomGroup):
         embeds.add_field(name=literal['subcommand'],
                          value=f'\n{brief_group(command)}\n')
     for check in command.checks:
         data = get_check(check.name)
         if data is None:
             continue
         embeds.add_field(name=f'{data["emoji"]} {data["name"]}', value=data["description"])
     if command.cog is not None:
         category = command.cog.qualified_name
         if isinstance(command.cog, CustomCog):
             category = command.cog.emoji + ' ' + category
         footer += ' · ' + category
     embeds.set_footer(text=footer)
     for embed in embeds.to_list():
         await ctx.send(embed=embed)
Beispiel #4
0
 async def get_deck_embed(self,
                          deck: Deck,
                          brief: bool = True) -> ChainedEmbed:
     literal = literals('get_deck_embed')
     deck_embed = ChainedEmbed(title=literal['title'] % deck.name,
                               description=deck.topic)
     deck_role = discord.utils.get(await
                                   self.deck_handler.guild.fetch_roles(),
                                   name=deck.name)
     deck_members = list()
     async for member in self.deck_handler.guild.fetch_members():
         if deck_role in member.roles:
             deck_members.append(str(member))
     deck_embed.set_thumbnail(url=deck.manager.avatar_url)
     deck_embed.add_field(name=literal['manager'], value=str(deck.manager))
     if deck.public:
         deck_embed.add_field(name=literal['public_name'],
                              value=literal['public_value'])
     if deck.nsfw:
         deck_embed.add_field(name=literal['nsfw_name'],
                              value=literal['nsfw_value'])
     if deck.auto:
         deck_embed.add_field(name=literal['auto_name'],
                              value=literal['auto_value'])
     if deck.lock:
         deck_embed.add_field(name=literal['lock_name'],
                              value=literal['lock_value'])
     if deck.pending:
         deck_embed.add_field(name=literal['pending'] % len(deck.pending),
                              value=' '.join(
                                  [str(member) for member in deck.pending]))
     if not brief:
         if deck_members:
             deck_embed.add_field(name=literal['members'] %
                                  len(deck_members),
                                  value='\n'.join(deck_members),
                                  inline=True)
         channels = list()
         for channel in deck.category_channel.channels:
             channels.append(
                 (literal['voice'] if isinstance(channel, VoiceChannel
                                                 ) else '') +
                 (channel.name if channel != deck.default_channel else
                  f'**__{channel.name}__**'))
         deck_embed.add_field(name=literal['channels'] %
                              len(deck.category_channel.channels),
                              value='\n'.join(channels),
                              inline=True)
     deck_embed.set_footer(text=literal['id'] % deck.id)
     return deck_embed
Beispiel #5
0
 async def send_cog_list(self, ctx: Context):
     literal = literals('send_cog_list')
     states = list()
     count = len(self.client.cogs)
     message = None
     for i, cog in enumerate(sorted(self.client.cogs.items(),
                                    key=lambda item: get_cog(type(item[1]).__name__)['priority'])):
         name, cog = cog
         if isinstance(cog, CustomCog):
             name = cog.emoji + ' ' + name
         page_embed = ChainedEmbed(title=literal['title'], description=literal['description'])
         page_embed.set_thumbnail(url=self.client.user.avatar_url)
         page_embed.add_field(name=name, value=brief_cog(cog))
         page_embed.set_footer(text=literal['footer'] % (i + 1, count))
         if message is None:
             message = await ctx.send(embed=page_embed)
         states.append(InterfaceState(callback=message.edit, embed=page_embed))
     await attach_page_interface(self.client, message, states, user=ctx.author)
Beispiel #6
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]))