mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-16 15:57:54 +02:00
Allow users to pick a specific meme subreddit
This commit is contained in:
@@ -2,15 +2,15 @@
|
|||||||
"memes",
|
"memes",
|
||||||
"dankmemes",
|
"dankmemes",
|
||||||
"surrealmemes",
|
"surrealmemes",
|
||||||
"MemeEconomy",
|
"memeeconomy",
|
||||||
"wholesomememes",
|
"wholesomememes",
|
||||||
"tumblr",
|
"tumblr",
|
||||||
"me_irl",
|
"me_irl",
|
||||||
"meirl",
|
"meirl",
|
||||||
"blessedimages",
|
"blessedimages",
|
||||||
"HistoryMemes",
|
"historymemes",
|
||||||
"WhitePeopleTwitter",
|
"whitepeopletwitter",
|
||||||
"coaxedintoasnafu",
|
"coaxedintoasnafu",
|
||||||
"Animemes",
|
"animemes",
|
||||||
"programmerhumor"
|
"programmerhumor"
|
||||||
]
|
]
|
||||||
|
|||||||
+14
-3
@@ -1,6 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
|
const { list } = require('../../util/Util');
|
||||||
const subreddits = require('../../assets/json/meme');
|
const subreddits = require('../../assets/json/meme');
|
||||||
|
|
||||||
module.exports = class MemeCommand extends Command {
|
module.exports = class MemeCommand extends Command {
|
||||||
@@ -10,12 +11,22 @@ module.exports = class MemeCommand extends Command {
|
|||||||
group: 'random',
|
group: 'random',
|
||||||
memberName: 'meme',
|
memberName: 'meme',
|
||||||
description: 'Responds with a random meme.',
|
description: 'Responds with a random meme.',
|
||||||
clientPermissions: ['ATTACH_FILES']
|
details: `**Subreddits**: ${subreddits.join(', ')}`,
|
||||||
|
clientPermissions: ['ATTACH_FILES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'subreddit',
|
||||||
|
prompt: `What subreddit do you want to get memes from? Either ${list(subreddits, 'or')}.`,
|
||||||
|
type: 'string',
|
||||||
|
oneOf: subreddits,
|
||||||
|
default: () => subreddits[Math.floor(Math.random() * subreddits.length)],
|
||||||
|
parse: subreddit => subreddit.toLowerCase()
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg) {
|
async run(msg, { subreddit }) {
|
||||||
const subreddit = subreddits[Math.floor(Math.random() * subreddits.length)];
|
|
||||||
try {
|
try {
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get(`https://www.reddit.com/r/${subreddit}/top.json`)
|
.get(`https://www.reddit.com/r/${subreddit}/top.json`)
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "90.3.4",
|
"version": "90.3.5",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user