Simp-O-Matic

Dumb Discord bot in TS.
git clone git://git.knutsen.co/Simp-O-Matic
Log | Files | Refs | README | LICENSE

emojify.ts (704B)


import { Message } from 'discord.js';

const NUMBER_NAMES = [
	'one', 'two', 'three', 'four', 'five',
	'six', 'seven', 'eight', 'nine', 'keycap_ten'
];

export default (homescope: HomeScope) => {
	const { message, args }
		: { message: Message,
			args: string[] } = homescope;

	const input = args.length === 0
		? "nibba"
		: args.join(' ').toLowerCase();

	const letters = [...input].map((chr: any) => {
		if (chr === ' ') return chr;
		if (isNaN(chr) && /[a-z]/i.test(chr))
			return chr === 'b'
				? chr.emojify()
				: `regional_indicator_${chr}`.emojify();
		if (!isNaN(Number(chr)))
			return NUMBER_NAMES[Number(chr)].emojify();
		return chr;
	});

	message.channel.send(letters.join(' '));
};