Skip to content

Instantly share code, notes, and snippets.

@mrtnzlml

mrtnzlml/slack.js

Created Sep 30, 2019
Embed
What would you like to do?
Downloading Slack emojis
import fs from 'fs';
import path from 'path';
import fetch from '@kiwicom/fetch';
// See: https://gist.github.com/lmarkus/8722f56baf8c47045621
import { emoji } from './emoji.json';
(async function() {
for (const [name, link] of Object.entries(emoji)) {
const downloadLink = link;
if (link.startsWith('alias:')) {
continue;
}
const result = await fetch(downloadLink);
const match = downloadLink.match(/.+\.(?<extension>[a-z]+)$/i);
const iconPath = path.join(__dirname, 'output', `${name}.${match.groups.extension}`);
const fileStream = fs.createWriteStream(iconPath);
result.body.pipe(fileStream);
result.body.on('finish', () => {
console.warn('Saved %s', iconPath);
});
result.body.on('error', err => {
throw err;
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.