Simp-O-Matic

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

commit a317af87350786dd847d5cf4f758ee85f75ba349
parent 3a7084d725e476c1d0455f8d3be7203c6d05719f
Author: Demonstrandum <moi@knutsen.co>
Date:   Thu, 19 Mar 2020 23:31:33 +0000

Added fortune and motivation, fix alias expansion, fix aliases listing.

Diffstat:
MHELP.md | 4+++-
Alib/commands/fortune.ts | 6++++++
Alib/commands/motivation.ts | 10++++++++++
Mlib/main.ts | 9++++++---
Mpackage.json | 1+
Myarn.lock | 5+++++
6 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/HELP.md b/HELP.md @@ -91,7 +91,9 @@ - `!kiss [@user-name]` — Blow a kiss to someone you like! - `!emojify [phrase]` — Turn your text into discord-style emoji. - `!B [phrase]` — Replace some elements of your text with a certain U+1F171. -- `!uwu [phrase]` — "uwuify" your text. +- `!uwu [phrase]` — “uwuify” your text. +- `!fortune` — Brings you fortune. +- `!motivation` — Get a motivational quote (for when you're feeling a lil down). ▬▬▬ diff --git a/lib/commands/fortune.ts b/lib/commands/fortune.ts @@ -0,0 +1,6 @@ +import { fortune } from 'fortune-teller'; + +export default home_scope => { + const { message } = home_scope; + message.channel.send(fortune()); +}; diff --git a/lib/commands/motivation.ts b/lib/commands/motivation.ts @@ -0,0 +1,10 @@ +import fetch from 'node-fetch'; +const URL = 'http://api.forismatic.com/api/1.0/?method=getQuote&format=text&lang=en&key=457653'; + +export default home_scope => { + const { message } = home_scope; + fetch(URL) + .catch(_ => message.channel.send("Couldn't get your quote qwq...")) + .then(res => res.text()) + .then(body => message.channel.send(body)); +}; diff --git a/lib/main.ts b/lib/main.ts @@ -98,7 +98,7 @@ export class SimpOMatic { if (expanded_command_words.length > 1) { // This means the alias has expanded to more than just one word. expansion = expanded_command_words.shift(); - expanded_command_words.each(e => args.push(e)); + expanded_command_words.reverse().each(e => args.shift(e)); } return expansion; }; @@ -224,8 +224,11 @@ export class SimpOMatic { const lines = Object.keys(CONFIG.commands.aliases) .map((e, i) => `${i + 1}. \`${p}${e}\` ↦ \`${p}${CONFIG.commands.aliases[e]}\``); message.answer('List of **Aliases**:\n'); - message.channel.send('**KEY: `Alias` ↦ `Command it maps to`**\n\n' - + lines.join('\n')); + lines.unshift('**KEY: `Alias` ↦ `Command it maps to`**\n\n'); + + for (const msg of glue_strings(lines)) + message.channel.send(msg); + break; } diff --git a/package.json b/package.json @@ -43,6 +43,7 @@ "discord.js": "11.6.1", "figlet": "^1.3.0", "figlet-cli": "^0.1.1", + "fortune-teller": "^0.1.2", "google-auth-library": "^5.10.1", "googleapis": "^48.0.0", "node-fetch": "^2.6.0", diff --git a/yarn.lock b/yarn.lock @@ -590,6 +590,11 @@ form-data@~2.3.2: combined-stream "^1.0.6" mime-types "^2.1.12" +fortune-teller@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/fortune-teller/-/fortune-teller-0.1.2.tgz#e9ae756de8de4c3f31f3411573743cd60bfaa136" + integrity sha1-6a51bejeTD8x80EVc3Q81gv6oTY= + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"