async chat(message) {
console.log(message);
let payload = {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + TWITCH_APP_TOKEN,
"Client-Id": TWITCH_APP_ID
},
body: {
"broadcaster_user_id": "12341234",
"sender_id": "12341234",
"message": message,
"for_source_only": "true"
}
};
let url = "http://api.twitch.tv/helix/chat/messages";
let response = await fetch(url, payload);
if (!response.ok) {
return Response.json({
status: response.status,
error: 'oauth error?'
}, {
status: 500
});
}
if (!response.headers?.get('content-type')?.includes('application/json')) {
return Response.json({
status: response.status,
error: 'malformed json'
}, {
status: 500
});
}
const json = await response.json();
console.log(json);
return
}
async chat(message) {
console.log(message);
let payload = {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + TWITCH_APP_TOKEN,
"Client-Id": TWITCH_APP_ID
},
body: {
"broadcaster_user_id": "12341234",
"sender_id": "12341234",
"message": message,
"for_source_only": "true"
}
};
let url = "http://api.twitch.tv/helix/chat/messages";
let response = await fetch(url, payload);
if (!response.ok) {
return Response.json({
status: response.status,
error: 'oauth error?'
}, {
status: 500
});
}
if (!response.headers?.get('content-type')?.includes('application/json')) {
return Response.json({
status: response.status,
error: 'malformed json'
}, {
status: 500
});
}
const json = await response.json();
console.log(json);
return
}