Skip to content

Commit

Permalink
Merge pull request #62 from DeltaCoderr/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
DeltaCoderr authored May 27, 2021
2 parents 686c500 + d56f4e7 commit b7601f0
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 15 deletions.
96 changes: 82 additions & 14 deletions commands/fun/reddit.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,84 @@
const Discord = require('discord.js');
const { MessageEmbed } = require('discord.js')
const config = require('../../configs/config.json');
const Discord = require('discord.js');
const { MessageEmbed } = require('discord.js')
const redditimage = require("reddit.images");
const config = require('../../configs/config.json');

module.exports = {
config: {
name: 'reddit',
description: 'Shows pic from Reddit',
aliases: ["reddit"],
usage: '<subreddit>',
accessableby: "",
},
run: async (client, message, args) => {
message.channel.send("This command is locked for now.")
module.exports = {
config: {
name: 'reddit',
description: 'Shows pic from Reddit',
aliases: ["reddit"],
usage: '<subreddit>',
accessableby: "",
},
run: async (client, message, args) => {

try {
if(!args[0]) return message.reply("**Please provide a subreddit.**")
const subreds = args[0]

redditimage.FetchSubreddit(subreds).then((data) => {
const reddit = new MessageEmbed()
.setTitle(data.title)
.setURL(data.postLink)
.setImage(data.image)
.setDescription(`👍 **${data.upvotes}** | 👎 **${data.downvotes}**`)
.setAuthor(`r/${subreds}`, "https://cdn.discordapp.com/attachments/799226474640048149/799273472990642196/2018_social_media_popular_app_logo_reddit-512.png", data.postLink)
.setColor(config.embedcolor)
.setFooter(`If the image didn't load click the title.`, message.guild.iconURL({ dynamic: true }))
.setTimestamp()


if(data.NSFW === true) {
message.channel.send('Wait... this meme was flagged as `nsfw` meme, are you sure you want to continue? (`yes`) or (`no`)')
let nsfwFilter = m => m.author.id === message.author.id;
let nsfwCollector = new Discord.MessageCollector(message.channel, nsfwFilter, { max: 999 });
nsfwCollector.on('collect', async msg => {
if(msg.content.toLowerCase() === 'yes') {
if(msg.channel.nsfw) {
message.channel.send(reddit)
await nsfwCollector.stop()
return;
} else {
message.channel.send('This channel is NOT a nsfw channel.')
await nsfwCollector.stop()
return;
}
} else if(msg.content.toLowerCase() === 'no') {
message.channel.send('Alright.')
await nsfwCollector.stop()
return;
} else {
message.channel.send('Please provide a valid answer! (`yes`) or (`no`)')
return;
}
})
} else if(data.spoiler === true) {
message.channel.send('This meme was flagged as `spoiler` meme, are you sure you want to continue? (`yes`) or (`no`)')
let spoilerFilter = m => m.author.id === message.author.id;
let spoilerCollector = new Discord.MessageCollector(message.channel, spoilerFilter, { max: 999 });
spoilerCollector.on('collect', async msg => {
if(msg.content.toLowerCase() === 'yes') {
message.channel.send(reddit)
await spoilerCollector.stop()
return;
} else if(msg.content.toLowerCase() === 'no') {
message.channel.send('Seems like you dont want spoilers, alright ig.')
await spoilerCollector.stop()
return;
} else {
message.channel.send('Please provide a valid answer! (`yes`) or (`no`)')
return;
}
})
} else if(data.NSFW !== true || data.spoiler !== true) {
return message.channel.send(reddit)
}
})
} catch(e) {
if(e.status === 403) return message.channel.send('Meme Is Private!')
if(e.status === 404) return message.channel.send('Meme Not Found!')
return message.channel.send('Invalid subreddit.')
}
}
}
}
2 changes: 1 addition & 1 deletion commands/other/serverinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
.setColor(config.embedcolor)
.setTitle(`${message.guild.name}`)
.setThumbnail(message.guild.iconURL)
.addField(`<:discord_online:739717108882997278> **Online Users**`, `≫ \`${onlineUsers.online}\``, true)
.addField(`**Online Users**`, `≫ \`${onlineUsers.online}\``, true)
.addField(`👤 **Total Users**`, `≫ \`${message.guild.memberCount}\``, true)
.addField(`📜 **Roles**`, `≫ \`${message.guild.roles.cache.size}\``, true)
.addField(`💬 **Text Channels**`, `≫ \`${message.guild.channels.cache.size}\``, true)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"ping-monitor": "^0.5.2",
"quick.db": "^7.1.3",
"quickmongo": "^3.0.0",
"reddit.images": "^1.0.0",
"relevant-urban": "^2.0.0",
"request": "^2.88.2",
"snekfetch": "^4.0.4",
Expand Down

0 comments on commit b7601f0

Please sign in to comment.