aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src/utils/discord.ts
blob: 3a04587699aac198b5dae797caf931267283d763 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { fetchAsync } from '@0x/utils';

import { constants } from '../constants';

import { utils } from './utils';

export const alertDiscordAsync = async (releaseNotes: string): Promise<void> => {
    const webhookUrl = constants.discordAlertWebhookUrl;
    if (webhookUrl === undefined) {
        throw new Error("No discord webhook url, can't alert");
    }

    utils.log('Alerting discord...');
    const payload = {
        content: `New monorepo package released!  View at ${constants.releasesUrl} \n\n ${releaseNotes}`,
    };
    await fetchAsync(webhookUrl, {
        method: 'POST',
        headers: {
            Accept: 'application/json',
            'Content-Type': 'application/json',
        },
        body: JSON.stringify(payload),
    });
    return;
};