Skip to content

Instantly share code, notes, and snippets.

@conblem
Created August 8, 2019 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conblem/65e06485b953de8a410f7016c8de4163 to your computer and use it in GitHub Desktop.
Save conblem/65e06485b953de8a410f7016c8de4163 to your computer and use it in GitHub Desktop.
Adding Twitchemotes to Mattermost; Replace CREATOR_ID, mattermost url and X-CSRF-Token
function send(emote) {
return fetch(`https://static-cdn.jtvnw.net/emoticons/v1/${emote.id}/2.0`)
.then(res => res.blob())
.then(res => {
const formdata = new FormData();
formdata.append("image", res, `${emote.code}.png`);
formdata.append("emoji", JSON.stringify({creator_id:"CREATOR_ID",name: emote.code}));
return fetch("https://mattermost.com/api/v4/emoji", {
method: "post",
credentials: "same-origin",
body: formdata,
headers: {
"X-CSRF-Token": "X-CSRF-TOKEN"
}
});
})
.then(res => res.json())
.then(console.log);
};
data.map(send)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment