Simp-O-Matic

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

commit 2a527f98562d1d82ba6a0e1fff8e3a17193d7398
parent cc9c54a3df28741b4593e10f4d5016a3cb166dd7
Author: Demonstrandum <moi@knutsen.co>
Date:   Sat, 16 May 2020 22:30:47 +0100

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

Diffstat:
Mlib/action.ts | 59+++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 37 insertions(+), 22 deletions(-)

diff --git a/lib/action.ts b/lib/action.ts @@ -5,15 +5,17 @@ type ActionType = 'kiss' | 'rape' | 'slap' | 'hug' | 'lick'; interface Actions { title: string; - message: string, - images: string[], - transitiveness: boolean + message: string; + images: string[]; + emoji?: string; + transitiveness?: boolean; } const ACTIONS: Record<ActionType, Actions> = { kiss: { title: "Uh-oh... You're getting a kissu!", - message: "", + message: "you got a kissu", + emoji: "flushed", images: [ "https://i.imgur.com/a5rkTna.gif", "https://i.imgur.com/AnYC2Xi.gif", @@ -24,14 +26,13 @@ const ACTIONS: Record<ActionType, Actions> = { "https://i.imgur.com/79hpwpn.gif", "https://i.imgur.com/RpxJYVD.gif", "https://i.imgur.com/8fcnQFS.gif", - ], - transitiveness: true + ] }, rape: { title: "Don't struggle :)", message: "raped", + emoji: "clown", images: [ - "https://tenor.com/biv7G.gif", "https://i.imgur.com/rdZHqDX.gif", "https://i.imgur.com/DdUkVBo.gif", "https://i.imgur.com/EcBew8x.gif", @@ -42,6 +43,7 @@ const ACTIONS: Record<ActionType, Actions> = { slap: { title: "Ouchie! You've been slapped!", message: "you got a slap", + emoji: 'back_of_hand', images: [ "https://cdn.weeb.sh/images/HkskD56OG.gif", "https://cdn.weeb.sh/images/BJSpWec1M.gif", @@ -53,12 +55,12 @@ const ACTIONS: Record<ActionType, Actions> = { "https://cdn.weeb.sh/images/H16aQJFvb.gif", "https://cdn.weeb.sh/images/HkK2mkYPZ.gif", "https://cdn.weeb.sh/images/BJ8o71tD-.gif", - ], - transitiveness: false + ] }, hug: { title: "Uguu~~ You got a warm hug!", message: "you got a hug", + emoji: 'hugging', images: [ "https://cdn.weeb.sh/images/rkIK_u7Pb.gif", "https://cdn.weeb.sh/images/SJByY_QwW.gif", @@ -66,12 +68,12 @@ const ACTIONS: Record<ActionType, Actions> = { "https://cdn.weeb.sh/images/S1a0DJhqG.gif", "https://cdn.weeb.sh/images/SJfEks3Rb.gif", "https://cdn.weeb.sh/images/HyNJIaVCb.gif", - ], - transitiveness: false + ] }, lick: { title: "You got a wet lick!", message: "you got a lick", + emoji: 'tongue', images: [ "https://cdn.weeb.sh/images/H1zlgRuvZ.gif", "https://cdn.weeb.sh/images/Bkagl0uvb.gif", @@ -82,29 +84,42 @@ const ACTIONS: Record<ActionType, Actions> = { "https://cdn.weeb.sh/images/H1EJxR_vZ.gif", "https://cdn.weeb.sh/images/H1EJxR_vZ.gif", "https://cdn.weeb.sh/images/HkEqiExdf.gif", - ], - transitiveness: false + ] } }; -const description_string = (subject, object, verb, transitiveness) => - transitiveness - ? subject.format(FORMATS.bold) + ` ${verb} ` + object.format(FORMATS.bold) + '! :flushed:' - : object.format(FORMATS.bold) + `, ${verb} from ` + subject.format(FORMATS.bold) + '! :flushed:'; - export default class Action { + private static description( + subject: string, + object: string, + { message: verb, emoji, transitiveness = false }: Actions): string + { + const description = transitiveness + ? `${subject} ${verb} ${object}!` + : `${object}, ${verb} from ${subject}!` + + return emoji + ? `${description} ${emoji.emojify()}` + : description; + } + static get(action: ActionType, message: Message): MessageEmbed { const { username: author } = message.author; const { username: to } = message.mentions.users.first(); - const reaction = ACTIONS[action]; - const images = reaction.images; - const image = images[Math.floor(Math.random() * images.length)]; + const reaction: Actions = ACTIONS[action]; + const images = reaction.images; + const image = images[Math.floor(Math.random() * images.length)]; const embed = new MessageEmbed() .setColor('#ba3d8a') .setTitle(reaction.title) - .setDescription(description_string(author, to, reaction.message, reaction.transitiveness)) + .setDescription( + this.description( + author.format(FORMATS.bold), + to.format(FORMATS.bold), + reaction) + ) .setImage(image); return embed;