jaredlyon / JareBot

A revisited JS project
GNU General Public License v3.0
5 stars 1 forks source link

checkstreaks.js does not properly concatenate its returned string #33

Open jaredlyon opened 3 years ago

jaredlyon commented 3 years ago

The current code in feature-1:

bot.guilds.cache.get("399740385221672970").members.cache.forEach(async member => {
    let streaks = (await bot.streaks.get(member.id)) || {};
    if (streaks.streak && streaks.streak >= 1 && (new Date() - new Date(streaks.lastDaily) <= 172800000)) {
        msg.channel.send(member.displayName + " has an active streak!");
    }
});

returns: image

Ideally, the code concatenates the results into one message, although all attempts to do so have failed.

jaredlyon commented 3 years ago

The below code (also commented in checkstreaks.js in feature-1) was the original blueprint for the command, though this has been tested multiple times and does not work either:

var message = "**__Active Daily Streaks:__**\n*Does not include streaks that have expired.*\n";

function checkStreaks() {
    bot.guilds.cache.get("399740385221672970").members.cache.forEach(async member => {
        let streaks = (await bot.streaks.get(member.id)) || {};
        if (streaks.streak && streaks.streak >= 1 && (new Date() - new Date(streaks.lastDaily) <= 172800000)) {
            message += member.displayName + "\n";
        }
    });
}

await checkStreaks();
msg.channel.send(message);