add default URL param to discordAlert

This commit is contained in:
Ben Allfree 2024-09-25 04:40:14 +00:00
parent e48e422ecd
commit a11e819d5e

View File

@ -3,8 +3,11 @@ import { stringify } from '../common'
const cache: { [_: string]: NodeJS.Timeout } = {}
export const discordAlert = (message: { toString: () => string }) => {
const url = DISCORD_ALERT_CHANNEL_URL()
export const discordAlert = (
message: { toString: () => string },
_url?: string,
) => {
const url = _url || DISCORD_ALERT_CHANNEL_URL()
if (!url) return
const m = `${message}${message instanceof Error ? `\n${message.stack}` : ''}`
const isCached = !!cache[m]