Simp-O-Matic

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

commit c66f274641df4a4335271f9d5069b9ac6e50470b
parent 0606252e24f254c6f2d48eff9dc33ae7c02c2fee
Author: Demonstrandum <moi@knutsen.co>
Date:   Thu, 19 Mar 2020 01:45:56 +0000

Merge branch 'master' of github.com:Demonstrandum/Simp-O-Matic

Diffstat:
MHELP.md | 1+
Alib/commands/emojify.ts | 30++++++++++++++++++++++++++++++
Mlib/extensions.ts | 5++++-
3 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/HELP.md b/HELP.md @@ -88,6 +88,7 @@ - `!boomer [phrase]` **〈not impl.〉** — Say something, but in the way your demented boomer uncle would write it on Facebook. - `!ship [@user-name] [@user-name]` — Shows the love grade between two people. - `!kiss [@user-name]` — Blow a kiss to someone you like! +- `!emojify [phrase]` — Turn your text into discord-style emoji. ▬▬▬ diff --git a/lib/commands/emojify.ts b/lib/commands/emojify.ts @@ -0,0 +1,30 @@ +export default home_scope => { + const { message, args } + : { message: Message, args: string[] } = home_scope; + + let input: string; + + if (args.length === 0) + input = "nibba"; + else + input = args.join(' ').toLowerCase(); + + const alphabet = 'abcdefghijklmnopqrstuvwxyz'; + const numerics = [ + 'one', 'two', 'three', 'four', 'five', + 'six', 'seven', 'eight', 'nine', 'keycap_ten' + ]; + + let letters = [...input].map((chr: any) => { + if (isNaN(chr) && alphabet.includes(chr)) + return chr === 'b' ? chr.emojify() : `regional_indicator_${chr}`.emojify(); + else if (chr === ' ') + return chr; + else if (!isNaN(Number(chr))) + return numerics[Number(chr)].emojify(); + else + return chr; + }) + + message.channel.send(letters.join(' ')); +}; diff --git a/lib/extensions.ts b/lib/extensions.ts @@ -37,7 +37,8 @@ declare global { tail(): string first(): string last(off? : number): string - format(fmt: string): string + format(fmt: string): string + emojify(): string } interface Number { @@ -100,6 +101,8 @@ String.prototype.capitalize = function () { return this.charAt(0).toUpperCase() + this.slice(1); }; +String.prototype.emojify = function () { return `:${this}:` }; + String.prototype.head = Array.prototype.head as any; String.prototype.tail = Array.prototype.tail as any; String.prototype.first = Array.prototype.first as any;