Ping custom role and custom username fix

Added custom content too that comes after the ping + channel name :D
This commit is contained in:
2024-12-12 18:54:52 +02:00
parent 555ce91670
commit eda1c26c74

View File

@@ -12,9 +12,11 @@ class DiscordClient:
notification_msg_id: str = "" notification_msg_id: str = ""
def __init__(self): def __init__(self):
self.user = os.environ["USER"]
self._webhook_url = os.environ["DISCORD_WEBHOOK_URL"] self._webhook_url = os.environ["DISCORD_WEBHOOK_URL"]
self.avatar_url = os.environ["AVATAR_URL"] self.avatar_url = os.environ["AVATAR_URL"]
self.content = os.environ["CONTENT"] self.content = os.environ["CONTENT"]
self.role_id = os.environ["ROLE_ID"]
def send_information_to_discord( def send_information_to_discord(
self, self,
@@ -28,10 +30,9 @@ class DiscordClient:
response = requests.post( response = requests.post(
url=f"{self._webhook_url}?wait=true", url=f"{self._webhook_url}?wait=true",
json={ json={
"username": "Randy", "username": f"{self.user}",
# "avatar_url": "https://i.imgur.com/DBOuwjx.png",
"avatar_url": f"{self.avatar_url}", "avatar_url": f"{self.avatar_url}",
"content": f"{self.content}", "content": f"<@&{self.role_id} {stream.user_name} {self.content}",
"embeds": [ "embeds": [
{ {
"title": stream.title, "title": stream.title,