The Onion Command

This commit is contained in:
Dragon Fire
2020-04-24 21:24:08 -04:00
parent 92740c1542
commit 52b95e1343
3 changed files with 43 additions and 2 deletions
+4 -1
View File
@@ -132,7 +132,7 @@ in the appropriate channel's topic to use it.
## Commands
Total: 402
Total: 404
### Utility:
@@ -205,6 +205,7 @@ Total: 402
* **subreddit:** Responds with a random post from a subreddit.
* **suggest-command:** Suggests a random command for you to try.
* **superpower:** Responds with a random superpower.
* **the-onion:** Responds with a random "The Onion" article.
* **this-for-that:** So, basically, it's like a bot command for this dumb meme.
* **waifu:** Responds with a randomly generated waifu and backstory.
* **would-you-rather:** Responds with a random "Would you rather ...?" question.
@@ -1129,6 +1130,8 @@ here.
* tv-show ([API](https://www.themoviedb.org/documentation/api))
- [The Newspaper Clipping Generator](https://www.fodey.com/generators/newspaper/snippet.asp)
* newspaper (API)
- [The Onion](https://www.theonion.com/)
* the-onion ([RSS Feed](https://www.theonion.com/rss))
- [The Yoda-Speak Generator](https://www.yodaspeak.co.uk/)
* yoda (API)
- [This Waifu Does Not Exist](https://www.thiswaifudoesnotexist.net/)
+37
View File
@@ -0,0 +1,37 @@
const Command = require('../../structures/Command');
const RSS = require('rss-parser');
const { stripIndents } = require('common-tags');
module.exports = class TheOnionCommand extends Command {
constructor(client) {
super(client, {
name: 'the-onion',
aliases: ['onion'],
group: 'random-res',
memberName: 'the-onion',
description: 'Responds with a random "The Onion" article.',
credit: [
{
name: 'The Onion',
url: 'https://www.theonion.com/',
reason: 'RSS Feed',
reasonURL: 'https://www.theonion.com/rss'
}
]
});
}
async run(msg) {
const parser = new RSS();
try {
const feed = await parser.parseURL('https://www.theonion.com/rss');
const article = feed.items[Math.floor(Math.random() * feed.items.length)];
return msg.say(stripIndents`
${article.title}
${article.link}
`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+2 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "113.17.1",
"version": "113.18.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {
@@ -50,6 +50,7 @@
"moment-timezone": "^0.5.28",
"node-superfetch": "^0.1.10",
"random-js": "^2.1.0",
"rss-parser": "^3.7.6",
"soap": "^0.31.0",
"winston": "^3.2.1"
},