diff --git a/README.md b/README.md index 394a5285..ccd3baed 100644 --- a/README.md +++ b/README.md @@ -637,6 +637,8 @@ here. * itunes ([iTunes Search API](https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/)) - [astrology.TV](https://astrology.tv/) * horoscope ([Horoscope Data](https://astrology.tv/horoscope/daily/)) +- [Attype Studio](https://www.dafont.com/fadli-ramadhan-iskandar.d7339) + * ship ([Pinky Cupid Font](https://www.dafont.com/pinky-cupid.font)) - [Axis Order Bot](https://www.reddit.com/r/axisorderbot/wiki/index) * axis-cult (Prayer Data) - [AZLyrics](https://www.azlyrics.com/) diff --git a/assets/fonts/Pinky Cupid.otf b/assets/fonts/Pinky Cupid.otf new file mode 100644 index 00000000..e34b344f Binary files /dev/null and b/assets/fonts/Pinky Cupid.otf differ diff --git a/assets/images/ship.png b/assets/images/ship.png new file mode 100644 index 00000000..9f043efa Binary files /dev/null and b/assets/images/ship.png differ diff --git a/commands/random-seed/ship.js b/commands/random-seed/ship.js index d37c12ec..7baaac38 100644 --- a/commands/random-seed/ship.js +++ b/commands/random-seed/ship.js @@ -1,6 +1,9 @@ const Command = require('../../structures/Command'); const { MersenneTwister19937, integer } = require('random-js'); -const { oneLine } = require('common-tags'); +const { createCanvas, loadImage, registerFont } = require('canvas'); +const request = require('node-superfetch'); +const path = require('path'); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Pinky Cupid.ttf'), { family: 'Pinky Cupid' }); module.exports = class ShipCommand extends Command { constructor(client) { @@ -9,6 +12,19 @@ module.exports = class ShipCommand extends Command { group: 'random-seed', memberName: 'ship', description: 'Ships two users together.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Attype Studio', + url: 'https://www.dafont.com/fadli-ramadhan-iskandar.d7339', + reason: 'Pinky Cupid Font', + reasonURL: 'https://www.dafont.com/pinky-cupid.font' + } + ], args: [ { key: 'first', @@ -27,20 +43,56 @@ module.exports = class ShipCommand extends Command { }); } - run(msg, { first, second }) { + async 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 = 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.` - : `Haha even a bot thinks ${authorInvolved ? 'you\'re' : 'they\'re'} lame.` - : ''; - return msg.say(oneLine` - ${first.id === this.client.user.id ? 'Me' : first.id === msg.author.id ? 'You' : first.username} and - ${second.id === this.client.user.id ? 'I' : second.id === msg.author.id ? 'you' : second.username} have a - compatability of... **${level}%**! ${botText} - `); + const firstAvatarURL = first.displayAvatarURL({ format: 'png', size: 512 }); + const secondAvatarURL = second.displayAvatarURL({ format: 'png', size: 512 }); + try { + const firstAvatarData = await request.get(firstAvatarURL); + const firstAvatar = await loadImage(firstAvatarData.body); + const secondAvatarData = await request.get(secondAvatarURL); + const secondAvatar = await loadImage(secondAvatarData.body); + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'ship.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(firstAvatar, 70, 56, 400, 400); + ctx.drawImage(secondAvatar, 730, 56, 400, 400); + ctx.drawImage(base, 0, 0); + ctx.textAlign = 'center'; + ctx.textBaseline = 'top'; + ctx.fillStyle = '#ff6c6c'; + ctx.font = '40px Pinky Cupid' + ctx.fillText('~Xiao\'s Compatability Meter~', 600, 15); + ctx.fillStyle = 'white'; + ctx.fillText(first.username, 270, 448); + ctx.fillText(second.username, 930, 448); + ctx.font = '60px Pinky Cupid'; + ctx.fillStyle = 'red'; + ctx.fillText(`~${level}%~`, 600, 230); + ctx.fillText(this.calculateLevelText(level), 600, 296); + ctx.font = '90px Pinky Cupid'; + ctx.fillText(level > 49 ? '❤️' : '💔'); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ship.png' }] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } + + calculateLevelText(level) { + if (level === 0) return 'Abyssmal'; + if (level > 0 && level < 10) return 'Horrid'; + if (level > 9 && level < 20) return 'Awful'; + if (level > 19 && level < 30) return 'Very Bad'; + if (level > 29 && level < 40) return 'Bad'; + if (level > 39 && level < 50) return 'Poor'; + if (level > 49 && level < 60) return 'Average'; + if (level > 59 && level < 70) return 'Fine'; + if (level > 69 && level < 80) return 'Good'; + if (level > 79 && level < 90) return 'Great'; + if (level > 89 && level < 100) return 'Amazing'; + if (level === 100) return 'Soulmates'; + return '???'; } }; diff --git a/package.json b/package.json index b3e2d37e..8e803a38 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "113.0.2", + "version": "113.0.3", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {