style: improved discord webhooks notifications

This commit is contained in:
190km
2024-12-01 04:09:19 +01:00
parent 63998f71ec
commit a235815a13
6 changed files with 51 additions and 49 deletions

View File

@@ -188,8 +188,9 @@ export const notificationRouter = createTRPCRouter({
.mutation(async ({ input }) => { .mutation(async ({ input }) => {
try { try {
await sendDiscordNotification(input, { await sendDiscordNotification(input, {
title: "Test Notification", title: "> `🤚` - Test Notification",
description: "Hi, From Dokploy 👋", description: "> Hi, From Dokploy 👋",
color: 0xf3f7f4
}); });
return true; return true;
} catch (error) { } catch (error) {

View File

@@ -59,30 +59,30 @@ export const sendBuildErrorNotifications = async ({
if (discord) { if (discord) {
await sendDiscordNotification(discord, { await sendDiscordNotification(discord, {
title: "⚠️ Build Failed", title: "> `⚠️` - Build Failed",
color: 0xff0000, color: 0xed4245,
fields: [ fields: [
{ {
name: "Project", name: "`🛠️`・Project",
value: projectName, value: `\`\`\`${projectName}\`\`\``,
inline: true, inline: true,
}, },
{ {
name: "Application", name: "`⚙️`・Application",
value: applicationName, value: `\`\`\`${applicationName}\`\`\``,
inline: true, inline: true,
}, },
{ {
name: "Type", name: "`❔`・Type",
value: applicationType, value: `\`\`\`${applicationType}\`\`\``,
inline: true, inline: true,
}, },
{ {
name: "Error", name: "`⚠️`・Error Message",
value: errorMessage, value: `\`\`\`${errorMessage}\`\`\``,
}, },
{ {
name: "Build Link", name: "`🧷`・Build Link",
value: buildLink, value: buildLink,
}, },
], ],

View File

@@ -57,26 +57,26 @@ export const sendBuildSuccessNotifications = async ({
if (discord) { if (discord) {
await sendDiscordNotification(discord, { await sendDiscordNotification(discord, {
title: " Build Success", title: "> `✅` - Build Success",
color: 0x00ff00, color: 0x57f287,
fields: [ fields: [
{ {
name: "Project", name: "`🛠️`・Project",
value: projectName, value: `\`\`\`${projectName}\`\`\``,
inline: true, inline: true,
}, },
{ {
name: "Application", name: "`⚙️`・Application",
value: applicationName, value: `\`\`\`${applicationName}\`\`\``,
inline: true, inline: true,
}, },
{ {
name: "Type", name: "`❔`・Type",
value: applicationType, value: `\`\`\`${applicationType}\`\`\``,
inline: true, inline: true,
}, },
{ {
name: "Build Link", name: "`🧷`・Build Link",
value: buildLink, value: buildLink,
}, },
], ],

View File

@@ -64,39 +64,40 @@ export const sendDatabaseBackupNotifications = async ({
await sendDiscordNotification(discord, { await sendDiscordNotification(discord, {
title: title:
type === "success" type === "success"
? " Database Backup Successful" ? "> `✅` - Database Backup Successful"
: " Database Backup Failed", : "> `❌` - Database Backup Failed",
color: type === "success" ? 0x00ff00 : 0xff0000, color: type === "success" ? 0x57f287 : 0xed4245,
fields: [ fields: [
{ {
name: "Project", name: "`🛠️`・Project",
value: projectName, value: `\`\`\`${projectName}\`\`\``,
inline: false,
},
{
name: "`⚙️`・Application",
value: `\`\`\`${applicationName}\`\`\``,
inline: true, inline: true,
}, },
{ {
name: "Application", name: "`❔`・Type",
value: applicationName, value: `\`\`\`${databaseType}\`\`\``,
inline: true, inline: true,
}, },
{ {
name: "Type", name: "`📅`・Time",
value: databaseType, value: `\`\`\`${date.toLocaleString()}\`\`\``,
inline: true, inline: false,
}, },
{ {
name: "Time", name: "`❔`・Type",
value: date.toLocaleString(), value: `\`\`\`${type}\`\`\``,
inline: true, inline: false,
},
{
name: "Type",
value: type,
}, },
...(type === "error" && errorMessage ...(type === "error" && errorMessage
? [ ? [
{ {
name: "Error Message", name: "`⚠️`・Error Message",
value: errorMessage, value: `\`\`\`${errorMessage}\`\`\``,
}, },
] ]
: []), : []),

View File

@@ -45,12 +45,12 @@ export const sendDockerCleanupNotifications = async (
if (discord) { if (discord) {
await sendDiscordNotification(discord, { await sendDiscordNotification(discord, {
title: " Docker Cleanup", title: "> `✅` - Docker Cleanup",
color: 0x00ff00, color: 0x57f287,
fields: [ fields: [
{ {
name: "Message", name: "`📜`・Message",
value: message, value: `\`\`\`${message}\`\`\``,
}, },
], ],
timestamp: date.toISOString(), timestamp: date.toISOString(),

View File

@@ -34,12 +34,12 @@ export const sendDokployRestartNotifications = async () => {
if (discord) { if (discord) {
await sendDiscordNotification(discord, { await sendDiscordNotification(discord, {
title: " Dokploy Server Restarted", title: "> `✅` - Dokploy Server Restarted",
color: 0x00ff00, color: 0x57f287,
fields: [ fields: [
{ {
name: "Time", name: "`📅`・Time",
value: date.toLocaleString(), value: `\`\`\`${date.toLocaleString()}\`\`\``,
inline: true, inline: true,
}, },
], ],