From 5082576901324b140b17bf73f61274e01f23df94 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Mon, 29 Jun 2020 14:42:59 -0400 Subject: [PATCH] Rig seeded randoms --- .env.example | 1 + README.md | 1 + commands/random-seed/coolness.js | 2 ++ commands/random-seed/cuteness.js | 2 ++ commands/random-seed/friendship.js | 4 ++++ commands/random-seed/guess-looks.js | 4 ++++ commands/random-seed/ship.js | 4 ++++ commands/random-seed/smash-or-pass.js | 3 ++- commands/random-seed/worth.js | 6 +++++- 9 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index e02db669..522b52d2 100644 --- a/.env.example +++ b/.env.example @@ -2,6 +2,7 @@ XIAO_TOKEN= # Seperate OWNERS with a , OWNERS= +GIRLFRIEND_USER_ID= XIAO_PREFIX= INVITE= XIAO_WEBHOOK_ID= diff --git a/README.md b/README.md index a474e436..c05e69c6 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ The difficulty in getting all of these keys is why I recommend * `XIAO_TOKEN` can be obtained at the [Discord Developer Portal](https://discord.com/developers/applications/). * `OWNERS` is a comma-seperated list of Discord User IDs. +* `GIRLFRIEND_USER_ID` is a Discord User ID for your lover. It rigs commands like `coolness` and `cuteness`. Totally optional, loners can leave it out. * `XIAO_PREFIX` is the prefix you want the bot to have. Like `x;`. * `INVITE` is an invite link to a Discord server. The whole thing, not just the code. * `XIAO_WEBHOOK_ID` is the ID of the webhook you want the `webhook` command to use. diff --git a/commands/random-seed/coolness.js b/commands/random-seed/coolness.js index 393a20ae..b8d871d8 100644 --- a/commands/random-seed/coolness.js +++ b/commands/random-seed/coolness.js @@ -1,6 +1,7 @@ const Command = require('../../structures/Command'); const { MersenneTwister19937, integer } = require('random-js'); const texts = require('../../assets/json/coolness'); +const { GIRLFRIEND_USER_ID } = process.env; module.exports = class CoolnessCommand extends Command { constructor(client) { @@ -28,6 +29,7 @@ module.exports = class CoolnessCommand extends Command { if (authorUser) return msg.reply('You\'re the best owner a bot could ask for! ❤'); return msg.reply(`Don't tell them I said this but I think ${user.username} smells like a sack of diapers.`); } + if (user.id === GIRLFRIEND_USER_ID) return msg.reply(`${user.username} is by far the coolest person ever! ❤`); const random = MersenneTwister19937.seed(user.id); const coolness = integer(0, texts.length - 1)(random); return msg.reply(`${authorUser ? 'You are' : `${user.username} is`} ${texts[coolness]}`); diff --git a/commands/random-seed/cuteness.js b/commands/random-seed/cuteness.js index f538a611..66f91d0e 100644 --- a/commands/random-seed/cuteness.js +++ b/commands/random-seed/cuteness.js @@ -1,6 +1,7 @@ const Command = require('../../structures/Command'); const { MersenneTwister19937, integer } = require('random-js'); const texts = require('../../assets/json/cuteness'); +const { GIRLFRIEND_USER_ID } = process.env; module.exports = class CutenessCommand extends Command { constructor(client) { @@ -35,6 +36,7 @@ module.exports = class CutenessCommand extends Command { if (authorUser) return msg.reply('You\'re the most adorable little cutie I know! ❤'); return msg.reply(`${user.username} is ugly. Like, not cute at all.`); } + if (user.id === GIRLFRIEND_USER_ID) return msg.reply(`${user.username} is by far the cutest person ever! ❤`); const random = MersenneTwister19937.seed(user.id); const cuteness = integer(0, texts.length - 1)(random); return msg.reply(`${authorUser ? 'You are' : `${user.username} is`} ${texts[cuteness]}`); diff --git a/commands/random-seed/friendship.js b/commands/random-seed/friendship.js index 69512af4..1110ee58 100644 --- a/commands/random-seed/friendship.js +++ b/commands/random-seed/friendship.js @@ -4,6 +4,7 @@ const { createCanvas, loadImage, registerFont } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { percentColor } = require('../../util/Util'); +const { GIRLFRIEND_USER_ID } = process.env; registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Pinky Cupid.otf'), { family: 'Pinky Cupid' }); const percentColors = [ { pct: 0.0, color: { r: 0, g: 0, b: 255 } }, @@ -56,11 +57,14 @@ module.exports = class FriendshipCommand extends Command { const owner = this.client.isOwner(first) || this.client.isOwner(second); const authorUser = first.id === msg.author.id || second.id === msg.author.id; const botUser = first.id === this.client.user.id || second.id === this.client.user.id; + const girlfriendUser = first.id === GIRLFRIEND_USER_ID || second.id === GIRLFRIEND_USER_ID; if (owner && botUser) { if (authorUser) level = 100; else level = 0; } else if (self) { level = 100; + } else if (girlfriendUser && owner) { + level = 100; } else { const calculated = -Math.abs(Number.parseInt(BigInt(first.id) - BigInt(second.id), 10)); const random = MersenneTwister19937.seed(calculated); diff --git a/commands/random-seed/guess-looks.js b/commands/random-seed/guess-looks.js index 801a049d..ed60182d 100644 --- a/commands/random-seed/guess-looks.js +++ b/commands/random-seed/guess-looks.js @@ -3,6 +3,7 @@ const { oneLine } = require('common-tags'); const { MersenneTwister19937, integer } = require('random-js'); const genders = ['male', 'female']; const { eyeColors, hairColors, hairStyles, extras } = require('../../assets/json/guess-looks'); +const { GIRLFRIEND_USER_ID } = process.env; module.exports = class GuessLooksCommand extends Command { constructor(client) { @@ -30,6 +31,9 @@ module.exports = class GuessLooksCommand extends Command { if (authorUser) return msg.reply('You look amazing as always! ❤'); return msg.reply(`${user.username} looks like a monkey, and smells like one too.`); } + if (user.id === GIRLFRIEND_USER_ID) { + return msg.reply(`Know what perfection looks like? That's what ${user.username} looks like. ❤`); + } const random = MersenneTwister19937.seed(user.id); const gender = genders[integer(0, genders.length - 1)(random)]; const eyeColor = eyeColors[integer(0, eyeColors.length - 1)(random)]; diff --git a/commands/random-seed/ship.js b/commands/random-seed/ship.js index a39cc252..41466625 100644 --- a/commands/random-seed/ship.js +++ b/commands/random-seed/ship.js @@ -4,6 +4,7 @@ const { createCanvas, loadImage, registerFont } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); const { percentColor } = require('../../util/Util'); +const { GIRLFRIEND_USER_ID } = process.env; registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Pinky Cupid.otf'), { family: 'Pinky Cupid' }); const percentColors = [ { pct: 0.0, color: { r: 0, g: 0, b: 255 } }, @@ -56,10 +57,13 @@ module.exports = class ShipCommand extends Command { const owner = this.client.isOwner(first) || this.client.isOwner(second); const authorUser = first.id === msg.author.id || second.id === msg.author.id; const botUser = first.id === this.client.user.id || second.id === this.client.user.id; + const girlfriendUser = first.id === GIRLFRIEND_USER_ID || second.id === GIRLFRIEND_USER_ID; if (owner && botUser) { level = 0; } else if (self) { level = 100; + } else if (girlfriendUser && owner) { + level = 100; } else { const calculated = Math.abs(Number.parseInt(BigInt(first.id) - BigInt(second.id), 10)); const random = MersenneTwister19937.seed(calculated); diff --git a/commands/random-seed/smash-or-pass.js b/commands/random-seed/smash-or-pass.js index 1b8be8ee..1cf91525 100644 --- a/commands/random-seed/smash-or-pass.js +++ b/commands/random-seed/smash-or-pass.js @@ -1,5 +1,6 @@ const Command = require('../../structures/Command'); const { MersenneTwister19937, bool } = require('random-js'); +const { GIRLFRIEND_USER_ID } = process.env; module.exports = class SmashOrPassCommand extends Command { constructor(client) { @@ -27,7 +28,7 @@ module.exports = class SmashOrPassCommand extends Command { return msg.reply('I sure hope no one is dumb enough to smash that... Thing.'); } const random = MersenneTwister19937.seed(user.id); - const smashOrPass = bool()(random); + const smashOrPass = user.id === GIRLFRIEND_USER_ID || bool()(random); return msg.reply(smashOrPass ? 'Smash, I\'d definitely smash.' : 'Hard pass. Yuck.'); } }; diff --git a/commands/random-seed/worth.js b/commands/random-seed/worth.js index 9d95afd3..19d81106 100644 --- a/commands/random-seed/worth.js +++ b/commands/random-seed/worth.js @@ -1,6 +1,7 @@ const Command = require('../../structures/Command'); const { MersenneTwister19937, integer } = require('random-js'); const { formatNumber } = require('../../util/Util'); +const { GIRLFRIEND_USER_ID } = process.env; module.exports = class WorthCommand extends Command { constructor(client) { @@ -32,9 +33,12 @@ module.exports = class WorthCommand extends Command { const authorUser = user.id === msg.author.id; if (user.id === this.client.user.id) return msg.reply('Me? I\'m worth $5/month. At least that\'s how much I cost.'); if (this.client.isOwner(user)) { - if (authorUser) return msg.reply('Infinity, you amazing owner ❤'); + if (authorUser) return msg.reply('Infinity, you amazing owner! ❤'); return msg.reply(`${user.username}, as in my owner? Worthless. Absolutely worthless.`); } + if (user.id === GIRLFRIEND_USER_ID) { + return msg.reply(`${user.username} is worth more than anyone else on this Earth! ❤`); + } const random = MersenneTwister19937.seed(user.id); const worth = integer(0, 1000000)(random); return msg.reply(`${authorUser ? 'You are' : `${user.username} is`} worth $${formatNumber(worth)}.`);