2025-06-23 12:56:09 +00:00
|
|
|
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"]
|
2025-06-23 14:03:54 +00:00
|
|
|
if len(tags) > 5:
|
|
|
|
|
tags = tags[:5]
|
2025-06-23 12:56:09 +00:00
|
|
|
tags.append('...')
|
2025-06-23 14:03:54 +00:00
|
|
|
self.add_field(name="Tags", value=f"{", ".join(tags)}", inline=False)
|