Пример #1
0
async def embed(self,
                ctx,
                title=None,
                description=None,
                url=None,
                fields=None,
                color=None,
                thumbnail=None,
                image=None,
                footer=defaultFooter,
                showTimeStamp=True,
                send=True):
    if type(title) is dict:
        e = Embed.from_dict(title)
        if send:
            return await ctx.send(embed=e)
        return e

    if not color:
        color = colors[random.choice(list(colors.keys()))]

    e = Embed(title=title, description=description, url=url, color=color)

    if type(fields) is list:
        for field in fields:
            inline = True
            if "inline" in list(field.keys()):
                inline = field['inline']
                del field['inline']

            for name, value in field.items():
                e.add_field(name=name, value=value, inline=inline)

    if showTimeStamp:
        e.timestamp = datetime.datetime.now()

    if thumbnail:
        e.set_thumbnail(url=thumbnail)
    else:
        e.set_thumbnail(url=self.bot.user.avatar_url)

    if image:
        e.set_image(url=image)

    if footer:
        icon = self.bot.user.avatar_url
        text = footer["text"].replace(
            "//author//", f"{ctx.author.name}#{ctx.author.discriminator}")

        if footer['icon']:
            if "//author.avatar//" in footer['icon']:
                if ctx.author.avatar_url:
                    icon = ctx.author.avatar_url

        e.set_footer(text=text, icon_url=icon)

    if send:
        return await ctx.send(embed=e)
    return e
Пример #2
0
    def ping_embed(package, message, paginate):
        'Formats and generates the embed for the ping'
        embed = Embed()
        currentmsg = paginate.pages_yielded
        totalmsgs = currentmsg + paginate.pages_left

        if currentmsg == 1:
            embed.title = package['sender']
            embed.set_author(name=package['description'])

        embed.description = message
        embed.set_thumbnail(url=package['logo_url'])
        if totalmsgs > 1:
            embed.set_footer(
                text='Message {}/{}'.format(currentmsg, totalmsgs))
        embed.timestamp = datetime.utcnow()
        embed.colour = package['embed_colour']

        return embed
Пример #3
0
 def _make_embed_skeleton(self, header: bool, desc: bool, footer: bool, image: bool):
     embed = self.template
     e_new = Embed(colour=embed.colour, type=embed.type)
     if header:
         e_new.title = embed.title
         e_new.url = embed.url
         author = embed.author
         if author.name is not EmptyEmbed:
             e_new.set_author(name=author.name, url=author.url, icon_url=author.icon_url)
     if desc:
         e_new.description = embed.description
     if image:
         if embed.image.url is not EmptyEmbed:
             e_new.set_image(url=embed.image.url)
         if embed.thumbnail.url is not EmptyEmbed:
             e_new.set_thumbnail(url=embed.thumbnail.url)
     if footer:
         e_new.timestamp = embed.timestamp
         footer = embed.footer
         e_new.set_footer(text=footer.text, icon_url=footer.icon_url)
     return e_new