Simp-O-Matic

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

commit 31ae1c805aedbf9a4ef50f8ffd8981c595d06ca6
parent 102e1fd05352be8b13527bab1a50ba4fc08299fd
Author: Demonstrandum <moi@knutsen.co>
Date:   Wed, 18 Mar 2020 23:23:52 +0000

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

Diffstat:
MHELP.md | 1+
Alib/commands/kiss.ts | 22++++++++++++++++++++++
Mlib/commands/ship.ts | 30+++++++++++++++++++++++++++---
3 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/HELP.md b/HELP.md @@ -87,6 +87,7 @@ - `!mock [phrase]` **〈not impl.〉** — Say something, _bUt iN a MocKiNg WaY_... - `!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! ▬▬▬ diff --git a/lib/commands/kiss.ts b/lib/commands/kiss.ts @@ -0,0 +1,22 @@ +import { MessageEmbed } from 'discord.js'; +import { FORMATS } from '.././extensions'; + +export default home_scope => { + const { message, args } = home_scope; + + if (args.length === 0 || message.mentions.users.size === 0) { + message.channel.send("You kissed your own hand. :face_with_hand_over_mouth:"); + return; + } + + let author = message.author.username; + let to = message.mentions.first().username; + + const embed = new MessageEmbed() + .setColor('#ba3d8a') + .setTitle('Some title') + .setDescription(`{to.format(FORMATS.bold)}, you got a kissu from ${author.format(FORMATS.bold)}! :flushed:`) + .setImage('https://i.imgur.com/lz1BY2x.gif') + + message.channel.send(embed); +}; diff --git a/lib/commands/ship.ts b/lib/commands/ship.ts @@ -1,6 +1,31 @@ import { FORMATS } from '../extensions'; import { Message } from 'discord.js'; +const fs = require('fs'); +const cp = require('child_process'); +const fetch = require('node-fetch'); + +function ps(stream) { + return new Promise((resolve, reject) => { + stream.once('error', reject); + stream.once('finish', resolve); + }); +} + +function makeimg(u1, u2){ + var ps1, ps2 + fetch(u1).then(res => { + ps1 = ps(res.body.pipe(fs.createWriteStream('./u1.png'))) + }) + fetch(u2).then(res => { + ps2 = ps(res.body.pipe(fs.createWriteStream('./u2.png'))) + }) + Promise.all([ps1, ps2]).then(() => { + cp.execSync('montage u1.png ../../❤️.png u2.png out.png', {cwd: __dirname}) + }) + return './out.png' +} + export default home_scope => { const { message, args, HELP_SECTIONS, @@ -66,8 +91,7 @@ export default home_scope => { let die: number = Math.floor(Math.random() * 100); let response: string = - `${getPercentage(die)} ${getResponse(die)} \n` + - `${userAvatars.first} :white_heart: ${userAvatars.second}`; + `${getPercentage(die)} ${getResponse(die)}`; - message.answer(response); + message.channel.send(response, {files: [makeimg(userAvatars.first, userAvatars.second)]}); }