From 476d971e4090b8f632f02451d0e3eab1ff18899f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= Date: Sun, 16 Jun 2019 19:15:52 +0200 Subject: [PATCH] also show text and not only image, and show the proper subreddit if using thing like random --- commands/fun/reddit.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/commands/fun/reddit.js b/commands/fun/reddit.js index 2f33d72..9333a51 100644 --- a/commands/fun/reddit.js +++ b/commands/fun/reddit.js @@ -23,8 +23,8 @@ class RedditCommand extends Command { } async exec(message, args) { - let i = 0; - let a = 0; + //let i = 0; + //let a = 0; if (!args.sub) return; @@ -33,20 +33,17 @@ class RedditCommand extends Command { }).then((response) => { if (!response.data) return message.channel.send('Not a valid subreddit'); - while (response.data.children[i].data.post_hint !== 'image') { - i = Math.floor((Math.random() * response.data.children.length)); - a++; - if (a == 5) - return message.channel.send('Could not find any images'); - } + + let i = Math.floor((Math.random() * response.data.children.length)); if (response.data.children[i].data.over_18 == true && !message.channel.nsfw) return message.channel.send('No nsfw'); const redditEmbed = new MessageEmbed() .setColor('#ff9900') .setTitle(response.data.children[i].data.title) .setImage(response.data.children[i].data.url) + .setDescription(response.data.children[i].data.selftext) .setURL('https://reddit.com' + response.data.children[i].data.permalink) - .setFooter(`/r/${args.sub} | ⬆ ${response.data.children[i].data.ups} ⬇ ${response.data.children[i].data.num_comments}`); + .setFooter(`/r/${response.data.children[i].data.subreddit} | ⬆ ${response.data.children[i].data.ups} ⬇ ${response.data.children[i].data.num_comments}`); message.channel.send(redditEmbed); });