mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 03:38:53 -05:00
[Streams] Avoid Discord's thumbnail caching
This commit is contained in:
parent
7ef878864e
commit
f32b3acd4c
@ -5,6 +5,8 @@ from .utils.chat_formatting import escape_mass_mentions
|
||||
from .utils import checks
|
||||
from __main__ import send_cmd_help
|
||||
from collections import defaultdict
|
||||
from string import ascii_letters
|
||||
from random import choice
|
||||
import os
|
||||
import re
|
||||
import aiohttp
|
||||
@ -380,7 +382,7 @@ class Streams:
|
||||
embed.add_field(name="Followers", value=channel["followers"])
|
||||
embed.add_field(name="Total views", value=channel["views"])
|
||||
embed.set_thumbnail(url=logo)
|
||||
embed.set_image(url=data["stream"]["preview"]["medium"])
|
||||
embed.set_image(url=data["stream"]["preview"]["medium"] + self.rnd_attr())
|
||||
if channel["game"]:
|
||||
embed.set_footer(text="Playing: " + channel["game"])
|
||||
embed.color = 0x6441A4
|
||||
@ -396,7 +398,7 @@ class Streams:
|
||||
embed.add_field(name="Followers", value=channel["followers"])
|
||||
#embed.add_field(name="Views", value=channel["views"])
|
||||
embed.set_thumbnail(url=base_url + channel["user_logo"])
|
||||
embed.set_image(url=base_url + livestream["media_thumbnail"])
|
||||
embed.set_image(url=base_url + livestream["media_thumbnail"] + self.rnd_attr())
|
||||
embed.set_footer(text="Playing: " + livestream["category_name"])
|
||||
embed.color = 0x98CB00
|
||||
return embed
|
||||
@ -414,7 +416,7 @@ class Streams:
|
||||
embed.set_thumbnail(url=user["avatarUrl"])
|
||||
else:
|
||||
embed.set_thumbnail(url=default_avatar)
|
||||
embed.set_image(url=data["thumbnail"]["url"])
|
||||
embed.set_image(url=data["thumbnail"]["url"] + self.rnd_attr())
|
||||
embed.color = 0x4C90F3
|
||||
if data["type"] is not None:
|
||||
embed.set_footer(text="Playing: " + data["type"]["name"])
|
||||
@ -459,6 +461,10 @@ class Streams:
|
||||
|
||||
await asyncio.sleep(CHECK_DELAY)
|
||||
|
||||
def rnd_attr(self):
|
||||
"""Avoids Discord's caching"""
|
||||
return "?rnd=" + "".join([choice(ascii_letters) for i in range(6)])
|
||||
|
||||
|
||||
def check_folders():
|
||||
if not os.path.exists("data/streams"):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user