27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
|
|
from discord import Embed
|
||
|
|
|
||
|
|
|
||
|
|
class TwitchGameNotificationEmbed(Embed):
|
||
|
|
|
||
|
|
def __init__(self, stream_data):
|
||
|
|
super().__init__()
|
||
|
|
game = stream_data["game_name"]
|
||
|
|
self.title = stream_data["title"]
|
||
|
|
self.url = f"https://twitch.tv/{stream_data["user_login"]}"
|
||
|
|
self.description = f"[Watch](https://twitch.tv/{stream_data["user_login"]})"
|
||
|
|
self.color = 0x001eff
|
||
|
|
self.set_author(name=f"{stream_data["user_name"]} Stream is Live",
|
||
|
|
url=f"https://twitch.tv/{stream_data["user_login"]}")
|
||
|
|
self.set_image(
|
||
|
|
url=f"https://static-cdn.jtvnw.net/previews-ttv/live_user_{stream_data["user_login"]}-1920x1080.jpg")
|
||
|
|
|
||
|
|
if game == "":
|
||
|
|
self.add_field(name="Game", value="404: Game not found", inline=True)
|
||
|
|
else:
|
||
|
|
self.add_field(name="Game", value=f"{stream_data["game_name"]}", inline=True)
|
||
|
|
self.add_field(name="Viewers", value=f"{stream_data["viewer_count"]}", inline=True)
|
||
|
|
tags = stream_data["tags"]
|
||
|
|
if len(tags) > 3:
|
||
|
|
tags = tags[:3]
|
||
|
|
tags.append('...')
|
||
|
|
self.add_field(name="Tags", value=f"{", ".join(tags)}")
|