diff --git a/packages/automated-dispute/src/services/discordNotifier.ts b/packages/automated-dispute/src/services/discordNotifier.ts index 2c78f79..b2f257f 100644 --- a/packages/automated-dispute/src/services/discordNotifier.ts +++ b/packages/automated-dispute/src/services/discordNotifier.ts @@ -1,6 +1,6 @@ import { isNativeError } from "util/types"; import type { APIEmbed, JSONEncodable } from "discord.js"; -import { Logger } from "@ebo-agent/shared"; +import { Logger, stringify } from "@ebo-agent/shared"; import { WebhookClient, WebhookMessageCreateOptions } from "discord.js"; import { NotificationFailureException } from "../exceptions/index.js"; @@ -115,26 +115,18 @@ export class DiscordNotifier implements NotificationService { if (isNativeError(err)) { return { title: `**Error:** ${err.name} - ${err.message}`, - description: `**Context:**\n\`\`\`json\n${JSON.stringify( - { - ...contextObject, - stack: err.stack, - }, - null, - 2, - )}\n\`\`\``, + description: `**Context:**\n\`\`\`json\n${stringify({ + ...contextObject, + stack: err.stack, + })}\n\`\`\``, }; } else { return { title: `**Error:** ${defaultMessage}`, - description: `**Context:**\n\`\`\`json\n${JSON.stringify( - { - ...contextObject, - error: err ? JSON.stringify(err, null, 2) : undefined, - }, - null, - 2, - )}\n\`\`\``, + description: `**Context:**\n\`\`\`json\n${stringify({ + ...contextObject, + error: err ? stringify(err) : undefined, + })}\n\`\`\``, }; } }