Right Stuf Command

This commit is contained in:
Dragon Fire
2020-03-14 11:22:52 -04:00
parent 39f229aae2
commit b5d15b827a
3 changed files with 85 additions and 2 deletions
+4 -1
View File
@@ -119,7 +119,7 @@ don't grant that permission.
## Commands
Total: 366
Total: 367
### Utility:
@@ -296,6 +296,7 @@ Total: 366
* **pokedex:** Searches the Pokédex for a Pokémon.
* **recipe:** Searches for recipes based on your query.
* **reddit:** Responds with information on a Reddit user.
* **right-stuf:** Searches Right Stuf Anime for your query.
* **rotten-tomatoes:** Searches Rotten Tomatoes for your query.
* **rule:** Responds with a rule of the internet.
* **safebooru:** Responds with an image from Safebooru, with optional query.
@@ -931,6 +932,8 @@ here.
* subreddit ([API](https://www.reddit.com/dev/api/))
- [Redeeming God](https://redeeminggod.com/)
* approved ([Image](https://redeeminggod.com/courses/gospel-dictionary/lessons/gospel-dictionary-approved/))
- [Right Stuf Anime](https://www.rightstufanime.com/)
* right-stuf (API)
- [Riot Games](https://www.riotgames.com/en)
* league-of-legends ([API](https://developer.riotgames.com/))
- [RoboHash](https://robohash.org/)
+80
View File
@@ -0,0 +1,80 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const request = require('node-superfetch');
const { stripIndents } = require('common-tags');
const { shorten } = require('../../util/Util');
module.exports = class RightStufCommand extends Command {
constructor(client) {
super(client, {
name: 'right-stuf',
aliases: ['right-stuf-anime'],
group: 'search',
memberName: 'right-stuf',
description: 'Searches Right Stuf Anime for your query.',
clientPermissions: ['EMBED_LINKS'],
credit: [
{
name: 'Right Stuf Anime',
url: 'https://www.rightstufanime.com/',
reason: 'API'
}
],
args: [
{
key: 'query',
prompt: 'What product would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, { query }) {
try {
const { body } = await request
.get('https://www.rightstufanime.com/api/items')
.query({
country: 'US',
currency: 'USD',
fieldset: 'search',
include: '',
language: 'en',
limit: 1,
pricelevel: 2,
q: query,
sort: 'relevance:asc',
custitem_rs_adult: msg.channel.nsfw ? true : false
});
if (!body.items.length) return msg.say('Could not find any results.');
const data = body.items[0];
const embed = new MessageEmbed()
.setColor(0x00D474)
.setTitle(data.storedisplayname)
.setURL(`https://www.rightstufanime.com/${data.urlcomponent}`)
.setAuthor('Right Stuf', 'https://i.imgur.com/CTB8Imp.jpg', 'https://www.rightstufanime.com/')
.setDescription(shorten(data.storedescription))
.setThumbnail(this.getImageURL(data))
.addField(' Price', stripIndents`
Retail Price: ${data.pricelevel1_formatted}
Non-Member Price: ${data.pricelevel5_formatted}
Member Price: ${data.onlinecustomerprice_formatted}
`);
return msg.embed(embed);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
getImageURL(item) {
let found = null;
let current = item.itemimages_detail
while (!found) {
if (current.primary) found = current.primary.url;
const key = Object.keys(current)[0];
if (!key) break;
current = current[key];
}
return found;
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "112.6.2",
"version": "112.7.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {