1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Fix some more discord embed bugs

This commit is contained in:
Steffo 2019-09-26 00:18:36 +02:00
parent 112733d439
commit 0b8f466120

View file

@ -103,14 +103,24 @@ class YtdlInfo:
def to_discord_embed(self) -> discord.Embed: def to_discord_embed(self) -> discord.Embed:
"""Return this info as a :py:class:`discord.Embed`.""" """Return this info as a :py:class:`discord.Embed`."""
colors = {
"youtube": 0xCC0000,
"soundcloud": 0xFF5400,
"Clyp": 0x3DBEB3,
"Bandcamp": 0x1DA0C3
}
embed = discord.Embed(title=self.title, embed = discord.Embed(title=self.title,
colour=discord.Colour(0xcc0000), colour=discord.Colour(colors.get(self.extractor, 0x4F545C)),
url=self.webpage_url) url=self.webpage_url if self.webpage_url is not None else discord.embeds.EmptyEmbed)
embed.set_thumbnail(url=self.thumbnail) if self.thumbnail:
embed.set_author(name=self.uploader, url=self.uploader_url if self.uploader_url is not None else discord.embeds.EmptyEmbed) embed.set_thumbnail(url=self.thumbnail)
if self.uploader:
embed.set_author(name=self.uploader, url=self.uploader_url if self.uploader_url is not None else discord.embeds.EmptyEmbed)
# embed.set_footer(text="Source: youtube-dl", icon_url="https://i.imgur.com/TSvSRYn.png") # embed.set_footer(text="Source: youtube-dl", icon_url="https://i.imgur.com/TSvSRYn.png")
embed.add_field(name="Duration", value=str(self.duration), inline=True) if self.duration:
embed.add_field(name="Published on", value=self.upload_date.strftime("%d %b %Y"), inline=True) embed.add_field(name="Duration", value=str(self.duration), inline=True)
if self.upload_date:
embed.add_field(name="Published on", value=self.upload_date.strftime("%d %b %Y"), inline=True)
return embed return embed
def __repr__(self): def __repr__(self):