diff --git a/README.md b/README.md index 9b9c8be8..7501a2ee 100644 --- a/README.md +++ b/README.md @@ -224,7 +224,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 425 +Total: 427 ### Utility: @@ -480,6 +480,7 @@ Total: 425 * **mad-libs:** Choose words that fill in the blanks to create a crazy story! * **math-quiz:** See how fast you can answer a math problem in a given time limit. * **quiz:** Answer a quiz question. +* **reaction-time:** Test your reaction time. * **rock-paper-scissors:** Play Rock-Paper-Scissors. * **roulette:** Play a game of roulette. * **slots:** Play a game of slots. @@ -545,6 +546,7 @@ Total: 425 * **sepia:** Draws an image or a user's avatar in sepia. * **shields-io-badge:** Creates a badge from shields.io. * **silhouette:** Draws a silhouette of an image or a user's avatar. +* **snapcode:** Responds with the Snapcode of a Snapchat user. * **square:** Draws an image or a user's avatar as a square. * **squish:** Draws an image or a user's avatar but squished across the X or Y axis. * **tint:** Draws an image or a user's avatar but tinted a specific color. @@ -1241,6 +1243,8 @@ here. * steam-card ([Template](https://www.deviantart.com/sinkillerj/art/Steam-Trading-Card-Template-GIMP-372156984)) - [SMWiki](http://www.smwiki.net/) * smw-level ([Level Name Data](http://old.smwiki.net/wiki/List_of_Super_Mario_World_levels)) +- [Snapchat](https://www.snapchat.com/) + * snapcode (API) - [SPAM Brand](https://www.spam.com/) * spam (Image) - [speak lolcat](https://speaklolcat.com/) diff --git a/commands/edit-image/snapcode.js b/commands/edit-image/snapcode.js new file mode 100644 index 00000000..ca466ed0 --- /dev/null +++ b/commands/edit-image/snapcode.js @@ -0,0 +1,44 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); + +module.exports = class SnapcodeCommand extends Command { + constructor(client) { + super(client, { + name: 'snapcode', + aliases: ['snapchat'], + group: 'edit-image', + memberName: 'snapcode', + description: 'Responds with the Snapcode of a Snapchat user.', + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Snapchat', + url: 'https://www.snapchat.com/', + reason: 'API' + } + ], + args: [ + { + key: 'username', + prompt: 'What user do you want to get the Snapcode for?', + type: 'string' + } + ] + }); + } + + async run(msg, { username }) { + try { + const { body } = await request + .get('https://feelinsonice.appspot.com/web/deeplink/snapcode') + .query({ + username, + type: 'PNG', + size: 320 + }); + return msg.say({ files: [{ attachment: body, name: 'snapcode.png' }] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/commands/games-sp/reaction-time.js b/commands/games-sp/reaction-time.js new file mode 100644 index 00000000..667e43f8 --- /dev/null +++ b/commands/games-sp/reaction-time.js @@ -0,0 +1,39 @@ +const Command = require('../../structures/Command'); +const { delay, randomRange } = require('../../util/Util'); +const words = ['fire', 'draw', 'shoot', 'bang', 'pull', 'boom']; + +module.exports = class ReactionTimeCommand extends Command { + constructor(client) { + super(client, { + name: 'reaction-time', + aliases: ['reaction', 'react', 'gunfight-sp', 'sp-gunfight'], + group: 'games-sp', + memberName: 'reaction-time', + description: 'Test your reaction time.' + }); + } + + async run(msg) { + const current = this.client.games.get(msg.channel.id); + if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`); + this.client.games.set(msg.channel.id, { name: this.name }); + try { + await msg.say('Get Ready...'); + await delay(randomRange(1000, 30000)); + const word = words[Math.floor(Math.random() * words.length)]; + await msg.say(`TYPE \`${word.toUpperCase()}\` NOW!`); + const filter = res => msg.author.id === res.author.id && res.content.toLowerCase() === word; + const now = Date.now(); + const msgs = await msg.channel.awaitMessages(filter, { + max: 1, + time: 30000 + }); + this.client.games.delete(msg.channel.id); + if (!msgs.size) return msg.say(`Failed to answer within 30 seconds.`); + return msg.say(`Nice one! (Took ${(Date.now() - now) / 1000} seconds)`); + } catch (err) { + this.client.games.delete(msg.channel.id); + throw err; + } + } +};