Skip to content

Instantly share code, notes, and snippets.

@ItsFelix5
Created March 25, 2025 18:58
Show Gist options
  • Select an option

  • Save ItsFelix5/fd5fd19b9a7701d8331bd41b7cae3497 to your computer and use it in GitHub Desktop.

Select an option

Save ItsFelix5/fd5fd19b9a7701d8331bd41b7cae3497 to your computer and use it in GitHub Desktop.
Deno script for bulk uploading slack emojis
const queue = Deno.readDirSync('emojis')
.toArray()
.map(({ name }) => name);
const upload = () => {
let file = queue.pop();
if (!file) return;
const name = file
.split('.')[0]
.toLowerCase()
.replaceAll(/[.,?! ()&]/g, '_');
const form = new FormData();
form.append('token', '<TOKEN>');
form.append('mode', 'data');
form.append('name', name);
form.append('image', new Blob([Deno.readFileSync(`emojis/${file}`)]));
fetch('https://hackclub.slack.com/api/emoji.add', {
credentials: 'include',
method: 'POST',
body: form,
headers: {
Cookie: 'Cookie <COOKIE>'
}
})
.then(r => r.json())
.then(r => {
if (r.ok) {
Deno.removeSync(`emojis/${file}`);
console.log(name, 'uploaded!');
setTimeout(upload, 1600);
} else if (r.ok === false) {
if (r.error === 'error_name_taken') {
Deno.removeSync(`emojis/${file}`);
console.log(name, 'already exists!');
} else if (r.error === 'ratelimited') {
console.warn('ratelimited!');
queue.push(file);
setTimeout(upload, 3000);
return;
} else console.error(name, r.error);
setTimeout(upload, 1600);
}
})
.catch(e => console.error(name, e));
};
upload();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment