From 48e17752152257eab73451c0546fd3a841d517a3 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Sun, 30 Jul 2017 02:26:21 +0000 Subject: [PATCH] Steam Command --- commands/random/portal-send.js | 3 ++- commands/search/steam.js | 47 ++++++++++++++++++++++++++++++++++ html/carbonfeat.html | 1 + html/discordbots.html | 1 + package.json | 2 +- 5 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 commands/search/steam.js diff --git a/commands/random/portal-send.js b/commands/random/portal-send.js index 330c742c..a6d3a9ed 100644 --- a/commands/random/portal-send.js +++ b/commands/random/portal-send.js @@ -26,7 +26,8 @@ module.exports = class PortalSendCommand extends Command { async run(msg, args) { const { message } = args; - const channel = parseTopic(this.client.channels, 'portal', this.client.user).random(); + const channels = this.client.channels.filter(c => c.guild.id !== msg.guild.id); + const channel = parseTopic(channels, 'portal', this.client.user).random(); if (!channel) return msg.say('Aww... No channel has an open portal...'); try { await channel.send(`**${msg.author.tag} (${msg.guild.name}):** ${message}`); diff --git a/commands/search/steam.js b/commands/search/steam.js new file mode 100644 index 00000000..569c1c00 --- /dev/null +++ b/commands/search/steam.js @@ -0,0 +1,47 @@ +const Command = require('../../structures/Command'); +const { MessageEmbed } = require('discord.js'); +const snekfetch = require('snekfetch'); + +module.exports = class SteamCommand extends Command { + constructor(client) { + super(client, { + name: 'steam', + group: 'search', + memberName: 'steam', + description: 'Searches Steam for your query.', + clientPermissions: ['EMBED_LINKS'], + args: [ + { + key: 'query', + prompt: 'What game would you like to search for?', + type: 'string' + } + ] + }); + } + + async run(msg, args) { + const { query } = args; + const { body } = await snekfetch + .get('https://store.steampowered.com/api/storesearch') + .query({ + cc: 'us', + l: 'en', + term: query + }); + if (!body.total) return msg.say('No Results.'); + const current = body.items[0].price ? body.items[0].price.final / 100 : 0.00; + const original = body.items[0].price ? body.items[0].price.initial / 100 : 0.00; + const price = current === original ? `$${current}` : `~~$${original}~~ $${current}`; + const embed = new MessageEmbed() + .setColor(0x101D2F) + .setAuthor(`Steam - ${body.items[0].name}`, 'https://i.imgur.com/vL8b4D5.png') + .setURL(`http://store.steampowered.com/app/${body.items[0].id}`) + .setImage(body.items[0].tiny_image) + .addField('❯ Price', + price, true) + .addField('❯ Metascore', + body.items[0].metascore || 'N/A', true); + return msg.embed(embed); + } +}; diff --git a/html/carbonfeat.html b/html/carbonfeat.html index e9bb5662..d1ad3c4f 100644 --- a/html/carbonfeat.html +++ b/html/carbonfeat.html @@ -54,6 +54,7 @@
  • Reddit
  • Rule34
  • SoundCloud
  • +
  • Steam
  • Urban Dictionary
  • Wattpad
  • Wikia (Any Wiki)
  • diff --git a/html/discordbots.html b/html/discordbots.html index bf2c9656..a2e2ebc0 100644 --- a/html/discordbots.html +++ b/html/discordbots.html @@ -51,6 +51,7 @@
  • Reddit
  • Rule34
  • SoundCloud
  • +
  • Steam
  • Urban Dictionary
  • Wattpad
  • Wikia (Any Wiki)
  • diff --git a/package.json b/package.json index f5e915e9..fbc74c71 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "28.0.2", + "version": "28.1.0", "description": "Your personal server companion.", "main": "Shard.js", "scripts": {