Poem Command

This commit is contained in:
Dragon Fire
2020-06-30 16:00:09 -04:00
parent 85938042b3
commit b0499e8295
3 changed files with 56 additions and 2 deletions
+4 -1
View File
@@ -231,7 +231,7 @@ in the appropriate channel's topic to use it.
## Commands
Total: 512
Total: 513
### Utility:
@@ -463,6 +463,7 @@ Total: 512
* **osu:** Responds with information on an osu! user.
* **paladins:** Responds with information on a Paladins player.
* **periodic-table:** Finds an element on the periodic table.
* **poem:** Searches for poems by a specific author.
* **pokedex:** Searches the Pokédex for a Pokémon.
* **pornhub:** Searches Pornhub for your query. (NSFW)
* **recipe:** Searches for recipes based on your query.
@@ -1379,6 +1380,8 @@ here.
* communist ([Image](https://www.pngfuel.com/free-png/osnol))
- [pngimg.com](https://pngimg.com/)
* thug-life ([Image](http://pngimg.com/download/58231))
- [PoetryDB](https://poetrydb.org/index.html)
* poem ([API](https://github.com/thundercomb/poetrydb/blob/master/README.md))
- [Pokemon Fusion](https://pokemon.alexonsager.net/)
* pokemon-fusion (Images)
- [PokéAPI](https://pokeapi.co/)
+51
View File
@@ -0,0 +1,51 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { stripIndents } = require('common-tags');
module.exports = class PoemCommand extends Command {
constructor(client) {
super(client, {
name: 'poem',
aliases: ['poetry'],
group: 'search',
memberName: 'poem',
description: 'Searches for poems by a specific author.',
credit: [
{
name: 'PoetryDB',
url: 'https://poetrydb.org/index.html',
reason: 'API',
reasonURL: 'https://github.com/thundercomb/poetrydb/blob/master/README.md'
}
],
args: [
{
key: 'author',
prompt: 'What author would you like to get a poem from?',
type: 'string',
parse: author => encodeURIComponent(author)
},
{
key: 'title',
prompt: 'What is the title of the poem you want to get?',
type: 'string',
parse: title => encodeURIComponent(title)
}
]
});
}
async run(msg, { author, title }) {
try {
const { body } = await request.get(`https://poetrydb.org/author,title/${author};${title}`);
const data = body[0];
return msg.say(stripIndents`
**${data.title}** by **${data.author}**
${data.lines.join('\n')}
`);
} catch (err) {
if (err.status === 404) return msg.say('Could not find any results.');
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "117.8.1",
"version": "117.9.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {