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 }) => {
try {
await sendDiscordNotification(input, {
title: "Test Notification",
description: "Hi, From Dokploy 👋",
title: "> `🤚` - Test Notification",
description: "> Hi, From Dokploy 👋",
color: 0xf3f7f4
});
return true;
} catch (error) {

View File

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

View File

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

View File

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

View File

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

View File

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