mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Welcome back, recipe
This commit is contained in:
@@ -8,7 +8,7 @@ Xiao is a Discord bot coded in JavaScript with
|
||||
300 commands, she is one of the most feature-filled bots out there, and formerly
|
||||
served over 10,000 servers with a uniquely devoted fanbase.
|
||||
|
||||
## Commands (293)
|
||||
## Commands (294)
|
||||
### Utility:
|
||||
|
||||
* **prefix**: Shows or sets the command prefix.
|
||||
@@ -147,6 +147,7 @@ served over 10,000 servers with a uniquely devoted fanbase.
|
||||
* **osu**: Responds with information on an Osu! user.
|
||||
* **periodic-table**: Finds an element on the periodic table.
|
||||
* **pokedex**: Searches the Pokédex for a Pokémon.
|
||||
* **recipe**: Searches for recipes based on your query.
|
||||
* **rotten-tomatoes**: Searches Rotten Tomatoes for your query.
|
||||
* **safebooru**: Responds with an image from Safebooru, with optional query.
|
||||
* **spoopy-link**: Determines if a link is spoopy or not.
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class RecipeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'recipe',
|
||||
aliases: ['recipe-puppy'],
|
||||
group: 'search',
|
||||
memberName: 'recipe',
|
||||
description: 'Searches for recipes based on your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What recipe would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get('http://www.recipepuppy.com/api/')
|
||||
.query({ q: query });
|
||||
const body = JSON.parse(text);
|
||||
if (!body.results.length) return msg.say('Could not find any results.');
|
||||
const recipe = body.results[Math.floor(Math.random() * body.results.length)];
|
||||
const embed = new MessageEmbed()
|
||||
.setAuthor('Recipe Puppy', 'https://i.imgur.com/lT94snh.png', 'http://www.recipepuppy.com/')
|
||||
.setColor(0xC20000)
|
||||
.setURL(recipe.href)
|
||||
.setTitle(recipe.title)
|
||||
.setDescription(`**Ingredients**: ${recipe.ingredients}`)
|
||||
.setThumbnail(recipe.thumbnail);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.status === 500) return msg.say('Could not find any results.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "69.4.0",
|
||||
"version": "69.5.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user