Add Discord embed to package webhooks
This commit is contained in:
@@ -22,7 +22,7 @@ from app.models import User
|
||||
from app.tasks import celery
|
||||
|
||||
@celery.task()
|
||||
def post_discord_webhook(username: Optional[str], content: str, is_queue: bool):
|
||||
def post_discord_webhook(username: Optional[str], content: str, is_queue: bool, title: Optional[str], description: Optional[str], thumbnail: Optional[str]):
|
||||
discord_url = app.config.get("DISCORD_WEBHOOK_QUEUE" if is_queue else "DISCORD_WEBHOOK_FEED")
|
||||
if discord_url is None:
|
||||
return
|
||||
@@ -37,4 +37,15 @@ def post_discord_webhook(username: Optional[str], content: str, is_queue: bool):
|
||||
if user:
|
||||
json["avatar_url"] = user.getProfilePicURL().replace("/./", "/")
|
||||
|
||||
if title:
|
||||
embed = {
|
||||
"title": title,
|
||||
"description": description,
|
||||
}
|
||||
|
||||
if thumbnail:
|
||||
embed["thumbnail"] = {"url": thumbnail}
|
||||
|
||||
json["embeds"] = [embed]
|
||||
|
||||
requests.post(discord_url, json=json)
|
||||
|
||||
Reference in New Issue
Block a user