{"size": 1653, "ext": "js", "max_stars_repo_path": "src/events/guild/ready.js", "max_stars_repo_name": "Pandowner/overbotprotect", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/events/guild/ready.js", "max_issues_repo_name": "Pandowner/overbotprotect", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/events/guild/ready.js", "max_forks_repo_name": "Pandowner/overbotprotect", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 35.170212766, "max_line_length": 80, "alphanum_fraction": 0.5958862674}
const Discord = require("discord.js");
const request = require("request");
const { MessageEmbed } = require("discord.js");
const {
    memesChannel,
    memberCountChannelId,
    guildId,
} = require("../../../config.json");

module.exports = async (client) => {
    console.log("MemesAPI ready");
    var interval = setInterval(function () {
        let urls = [
            "https://meme-api.herokuapp.com/gimme/dankmemes",
            "https://meme-api.herokuapp.com/gimme/wholesomememes",
            "https://meme-api.herokuapp.com/gimme/memes",
        ];

        let subreddit = urls[Math.floor(Math.random() * urls.length)];
        return request(subreddit, (err, response, body) => {
            if (err) throw err;
            var data = JSON.parse(body);

            let meme = new Discord.MessageEmbed()
                .setDescription(`**[${data.title}](${data.postLink})**`)
                .setImage(data.url)
                .setFooter(`👍 ${data.ups}`)
                .setColor("#32CD32");

            const memeSendChannel = client.channels.cache.get(memesChannel);
            memeSendChannel.send(meme).catch(console.error);
        });
    }, 1 * 3600000);

    const channelId = memberCountChannelId;

    const updateMembers = (guild) => {
        const channel = guild.channels.cache.get(channelId);
        channel.setName(`💂 Members: ${guild.memberCount.toLocaleString()}`);

        client.on("guildMemberAdd", (member) => updateMembers(member.guild));
        client.on("guildMemberRemove", (member) => updateMembers(member.guild));
    };
    const guild = client.guilds.cache.get(guildId);
    updateMembers(guild);
};
