From 45d99929ee77547e4f972b475df605decfe8acc7 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 15 Mar 2020 19:24:15 -0400 Subject: [PATCH] Apple Engraving Command --- README.md | 4 +- assets/json/apple-engraving.json | 10 +++++ commands/image-edit/apple-engraving.js | 52 ++++++++++++++++++++++++++ package.json | 2 +- 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 assets/json/apple-engraving.json create mode 100644 commands/image-edit/apple-engraving.js diff --git a/README.md b/README.md index 97cbbdb0..a2424058 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ don't grant that permission. ## Commands -Total: 367 +Total: 368 ### Utility: @@ -373,6 +373,7 @@ Total: 367 ### Image Manipulation: * **achievement:** Sends a Minecraft achievement with the text of your choice. +* **apple-engraving:** Engraves the text of your choice onto an Apple product. * **approved:** Draws an "approved" stamp over an image or a user's avatar. * **brazzers:** Draws an image with the Brazzers logo in the corner. (NSFW) * **circle:** Draws an image or a user's avatar as a circle. @@ -580,6 +581,7 @@ here. - [Antonio Guillem](http://antonioguillem.com/) * distracted-boyfriend ([Image](https://www.istockphoto.com/photo/gm493656728-77018851)) - [Apple](https://www.apple.com/) + * apple-engraving (API) * 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/)) diff --git a/assets/json/apple-engraving.json b/assets/json/apple-engraving.json new file mode 100644 index 00000000..35d4e63c --- /dev/null +++ b/assets/json/apple-engraving.json @@ -0,0 +1,10 @@ +{ + "airpods": "PRXJ2AM", + "airpods-pro": "PWP22AM", + "pencil": "PU8F2AM", + "ipod": "PVHV2LL", + "ipad-pro": "PTEM2LL", + "ipad": "PW752LL", + "ipad-mini": "PUQX2LL", + "ipad-air": "PUUK2LL" +} diff --git a/commands/image-edit/apple-engraving.js b/commands/image-edit/apple-engraving.js new file mode 100644 index 00000000..ab65dee1 --- /dev/null +++ b/commands/image-edit/apple-engraving.js @@ -0,0 +1,52 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); +const { list } = require('../../util/Util'); +const products = require('../../assets/json/apple-engraving'); + +module.exports = class AppleEngravingCommand extends Command { + constructor(client) { + super(client, { + name: 'apple-engraving', + aliases: ['apple-engrave', 'apple-e', 'a-engrave', 'a-engraving'], + group: 'image-edit', + memberName: 'apple-engraving', + description: 'Engraves the text of your choice onto an Apple product.', + credit: [ + { + name: 'Apple', + url: 'https://www.apple.com/', + reason: 'API' + } + ], + args: [ + { + key: 'product', + prompt: `What product do you want to engrave? Either ${list(Object.keys(products), 'or')}.`, + type: 'string', + oneOf: Object.keys(products), + parse: product => product.toLowerCase() + }, + { + key: 'text', + prompt: 'What text do you want to engrave?', + type: 'string' + } + ] + }); + } + + async run(msg, { product, text }) { + try { + const { body } = await request + .get(`https://www.apple.com/shop/preview/engrave/${products[product]}/A`) + .query({ + th: text, + s: 2, + f: 'font1' + }); + return msg.channel.send({ files: [{ attachment: body, name: 'apple-engraving.jpg' }] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 5634551c..9c7a6cdb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "112.7.2", + "version": "112.8.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {