diff --git a/commands/analyze/butt.js b/commands/analyze/butt.js index ba42293d..9b31f209 100644 --- a/commands/analyze/butt.js +++ b/commands/analyze/butt.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const Random = require('random-js'); +const { MersenneTwister19937, integer } = require('random-js'); const texts = require('../../assets/json/butt'); module.exports = class ButtCommand extends Command { @@ -29,8 +29,8 @@ module.exports = class ButtCommand extends Command { run(msg, { user }) { if (user.id === this.client.user.id) return msg.reply('Me? I think I have the best butt around!'); - const random = new Random(Random.engines.mt19937().seed(user.id)); - const quality = random.integer(0, texts.length - 1); + const random = MersenneTwister19937.seed(user.id); + const quality = integer(0, texts.length - 1)(random); return msg.reply(`${user.id === msg.author.id ? 'ur' : `${user.username}'s`} butt is ${texts[quality]}`); } }; diff --git a/commands/analyze/coolness.js b/commands/analyze/coolness.js index a6d8de8d..68d6813a 100644 --- a/commands/analyze/coolness.js +++ b/commands/analyze/coolness.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const Random = require('random-js'); +const { MersenneTwister19937, integer } = require('random-js'); const texts = require('../../assets/json/coolness'); module.exports = class CoolnessCommand extends Command { @@ -27,8 +27,8 @@ 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.`); } - const random = new Random(Random.engines.mt19937().seed(user.id)); - const coolness = random.integer(0, texts.length - 1); + 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/analyze/dick.js b/commands/analyze/dick.js index bd13e4e3..5fb820f0 100644 --- a/commands/analyze/dick.js +++ b/commands/analyze/dick.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const Random = require('random-js'); +const { MersenneTwister19937, integer } = require('random-js'); module.exports = class DickCommand extends Command { constructor(client) { @@ -23,8 +23,8 @@ module.exports = class DickCommand extends Command { run(msg, { user }) { const clientAuthor = user.id === this.client.user.id; - const random = new Random(Random.engines.mt19937().seed(clientAuthor ? msg.author.id : user.id)); - const length = random.integer(0, 200); + const random = MersenneTwister19937.seed(clientAuthor ? msg.author.id : user.id); + const length = integer(0, 200)(random); return msg.reply(`8${'='.repeat(clientAuthor ? length + 1 : length)}D`); } }; diff --git a/commands/analyze/guess-looks.js b/commands/analyze/guess-looks.js index 7643f33e..8102d7a2 100644 --- a/commands/analyze/guess-looks.js +++ b/commands/analyze/guess-looks.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const { oneLine } = require('common-tags'); -const Random = require('random-js'); +const { MersenneTwister19937, integer } = require('random-js'); const genders = ['male', 'female']; const { eyeColors, hairColors, hairStyles, extras } = require('../../assets/json/guess-looks'); @@ -26,16 +26,16 @@ module.exports = class GuessLooksCommand extends Command { run(msg, { user }) { if (user.id === this.client.user.id) return msg.reply('Me? Just look at my avatar, dummy.'); const authorUser = user.id === msg.author.id; - const random = new Random(Random.engines.mt19937().seed(user.id)); - const gender = genders[random.integer(0, genders.length - 1)]; - const eyeColor = eyeColors[random.integer(0, eyeColors.length - 1)]; - const hairColor = hairColors[random.integer(0, hairColors.length - 1)]; - const hairStyle = hairStyles[random.integer(0, hairStyles.length - 1)]; - const age = random.integer(10, 100); - const feet = random.integer(3, 7); - const inches = random.integer(0, 11); - const weight = random.integer(50, 300); - const extra = extras[random.integer(0, extras.length - 1)]; + const random = MersenneTwister19937.seed(user.id); + const gender = genders[integer(0, genders.length - 1)(random)]; + const eyeColor = eyeColors[integer(0, eyeColors.length - 1)(random)]; + const hairColor = hairColors[integer(0, hairColors.length - 1)(random)]; + const hairStyle = hairStyles[integer(0, hairStyles.length - 1)(random)]; + const age = integer(10, 100)(random); + const feet = integer(3, 7)(random); + const inches = integer(0, 11)(random); + const weight = integer(50, 300)(random); + const extra = extras[integer(0, extras.length - 1)(random)]; return msg.reply(oneLine` I think ${authorUser ? 'you are' : `${user.username} is`} a ${age} year old ${gender} with ${eyeColor} eyes and ${hairStyle} ${hairColor} hair. ${authorUser ? 'You are' : `${gender === 'male' ? 'He' : 'She'} is`} diff --git a/commands/analyze/iq.js b/commands/analyze/iq.js index fc62ee0f..ab298610 100644 --- a/commands/analyze/iq.js +++ b/commands/analyze/iq.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const Random = require('random-js'); +const { MersenneTwister19937, integer } = require('random-js'); module.exports = class IQCommand extends Command { constructor(client) { @@ -22,8 +22,8 @@ module.exports = class IQCommand extends Command { run(msg, { user }) { if (user.id === this.client.user.id) return msg.reply('Me? My IQ score is off the charts!'); - const random = new Random(Random.engines.mt19937().seed(user.id)); - const score = random.integer(20, 170); + const random = MersenneTwister19937.seed(user.id); + const score = integer(20, 170)(random); return msg.reply(`${user.id === msg.author.id ? 'Your' : `${user.username}'s`} IQ score is ${score}.`); } }; diff --git a/commands/analyze/psycho-pass.js b/commands/analyze/psycho-pass.js index 477f9e2d..59f15a5b 100644 --- a/commands/analyze/psycho-pass.js +++ b/commands/analyze/psycho-pass.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const Random = require('random-js'); +const { MersenneTwister19937, integer } = require('random-js'); const { under100, between, over300 } = require('../../assets/json/psycho-pass'); module.exports = class PsychoPassCommand extends Command { @@ -29,8 +29,8 @@ module.exports = class PsychoPassCommand extends Command { run(msg, { user }) { if (user.id === this.client.user.id) return msg.reply('Me? I-I\'m not dangerous, I promise!'); - const random = new Random(Random.engines.mt19937().seed(user.id)); - const coefficient = random.integer(0, 500); + const random = MersenneTwister19937.seed(user.id); + const coefficient = integer(0, 500)(random); let res; if (coefficient < 100) res = under100; else if (coefficient > 300) res = over300; diff --git a/commands/analyze/ship.js b/commands/analyze/ship.js index d4a63183..d31c2504 100644 --- a/commands/analyze/ship.js +++ b/commands/analyze/ship.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const Random = require('random-js'); +const { MersenneTwister19937, integer } = require('random-js'); const { oneLine } = require('common-tags'); module.exports = class ShipCommand extends Command { @@ -30,8 +30,8 @@ module.exports = class ShipCommand extends Command { run(msg, { first, second }) { if (first.id === second.id) return msg.reply('Shipping someone with themselves would be pretty weird.'); const authorInvolved = first.id === msg.author.id || second.id === msg.author.id; - const random = new Random(Random.engines.mt19937().seed(Math.abs(first.id - second.id))); - const level = random.integer(0, 100); + const random = MersenneTwister19937.seed(Math.abs(first.id - second.id)); + const level = integer(0, 100)(random); const botText = first.id === this.client.user.id || second.id === this.client.user.id ? level >= 70 ? `But ${authorInvolved ? 'you\'re' : 'they\'re'} still rejected.` diff --git a/package.json b/package.json index 2d9f4dc9..e05d3386 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ }, "homepage": "https://github.com/dragonfire535/xiao#readme", "engines": { - "node": ">=10" + "node": ">=11" }, "dependencies": { "@discordjs/uws": "^11.149.1", @@ -46,14 +46,14 @@ "moment-timezone": "^0.5.25", "neopet-image-finder": "^5.0.2", "node-superfetch": "^0.1.9", - "random-js": "^1.0.8", + "random-js": "^2.0.0", "winston": "^3.2.1", "zlib-sync": "^0.1.4" }, "devDependencies": { - "eslint": "^5.8.0", + "eslint": "^5.16.0", "eslint-config-amber": "^2.0.0", - "eslint-plugin-json": "^1.2.1" + "eslint-plugin-json": "^1.4.0" }, "eslintConfig": { "extends": "amber",