summaryrefslogtreecommitdiff
path: root/src/tools/add-emoji.ts
blob: 2aa99e37aec1fd7ff04f0bf9e6edefcbaa14e83f (plain)
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
import Emoji from '../models/emoji';

async function main(name: string, url: string, alias?: string): Promise<any> {
	const aliases = alias != null ? [ alias ] : [];

	await Emoji.insert({
		host: null,
		name,
		url,
		aliases,
		updatedAt: new Date()
	});
}

const args = process.argv.slice(2);
const name = args[0];
const url = args[1];

if (!name) throw 'require name';
if (!url) throw 'require url';

main(name, url).then(() => {
	console.log('success');
	process.exit(0);
}).catch(e => {
	console.warn(e);
	process.exit(1);
});