-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbroadcaster.js
35 lines (31 loc) · 937 Bytes
/
broadcaster.js
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
27
28
29
30
31
32
33
34
35
sendchat.addEventListener('submit', (e) => {
e.preventDefault();
sendChat();
});
async function sendChat() {
master_log('Sending Chat Message');
let req = await fetch(
'https://api.twitch.tv/helix/extensions/chat',
{
method: 'POST',
headers: {
...gojwt,
'Content-Type': 'application/json'
},
body: JSON.stringify({
broadcaster_id: channelId,
text: 'Test message',
extension_id: gojwt['Client-ID'],
extension_version: extensionVersion
})
}
);
//master_log(`Sent Chat Message: ${req.status}`);
if (req.status == 204) {
master_log('Send Chat Message OK');
return;
}
master_log(`Failed to send chat message: ${req.status}`);
let data = await req.json();
master_log(`Response: ${data.message}`);
}