@sapphire-sh/utils 1.31.0 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/notify.d.ts +1 -1
- package/lib/notify.js +5 -4
- package/package.json +1 -1
package/lib/notify.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function notifySlack(url: string, text: string): Promise<void>;
|
|
2
|
-
export declare function notifyMattermost(
|
|
2
|
+
export declare function notifyMattermost(baseUrl: string, token: string, channelId: string, message: string): Promise<void>;
|
package/lib/notify.js
CHANGED
|
@@ -14,15 +14,16 @@ async function notifySlack(url, text) {
|
|
|
14
14
|
throw new Error(`Slack webhook failed: HTTP ${resp.status}`);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
async function notifyMattermost(
|
|
18
|
-
const resp = await fetch(
|
|
17
|
+
async function notifyMattermost(baseUrl, token, channelId, message) {
|
|
18
|
+
const resp = await fetch(`${baseUrl}/api/v4/posts`, {
|
|
19
19
|
method: 'POST',
|
|
20
20
|
headers: {
|
|
21
|
+
'Authorization': `Bearer ${token}`,
|
|
21
22
|
'Content-Type': 'application/json',
|
|
22
23
|
},
|
|
23
|
-
body: JSON.stringify({
|
|
24
|
+
body: JSON.stringify({ channel_id: channelId, message }),
|
|
24
25
|
});
|
|
25
26
|
if (!resp.ok) {
|
|
26
|
-
throw new Error(`Mattermost
|
|
27
|
+
throw new Error(`Mattermost post failed: HTTP ${resp.status}`);
|
|
27
28
|
}
|
|
28
29
|
}
|