Skip to content

Commit

Permalink
prompt user each morning
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetrunic committed Apr 7, 2021
1 parent ab9710f commit 212b1b9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
16 changes: 10 additions & 6 deletions commands/showPrompt.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
module.exports = {
name: "show",
description: "Shows standup prompt",
async execute(message, args) {
message.channel.send(`
const PROMPT =`
Here is the daily standup prompt:
\`\`\`
1. What have you done since yesterday?
2. What are you planning on doing today?
3. Any impediments or stumbling blocks?
\`\`\`Please make sure you have thought about your response **_very carefully_** as standups are more for *the entire team*.
Once you are ready to respond, simply DM me with \`!reply ...\` where \`...\` represents your response. :stuck_out_tongue:
`);
`

module.exports.message = PROMPT;

module.exports = {
name: "show",
description: "Shows standup prompt",
async execute(message, args) {
message.channel.send(PROMPT);
},
};
31 changes: 28 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const mongoose = require("mongoose");
const { Client, MessageEmbed, Collection } = require("discord.js");
const schedule = require("node-schedule");
const standupModel = require("./models/standup.model");
const showPromptCommand = require("./commands/showPrompt");

const PREFIX = "!";

Expand Down Expand Up @@ -150,12 +151,36 @@ bot.on("guildDelete", (guild) => {
});

/**
* Cron Job: 10:30:00 AM EST - Go through each standup and output the responses to the channel
* Cron Job: 08:00:00 AM Europe/Zagreb - Go through each member and ask for standup
*/
let cron = schedule.scheduleJob(
{ hour: 15, minute: 30, dayOfWeek: new schedule.Range(1, 5) },
{ hour: 8, minute: 0, dayOfWeek: new schedule.Range(1, 5), tz: "Europe/Zagreb" },
(time) => {
console.log(`[${time}] - CRON JOB START`);
console.log(`[${time}] - CRON JOB 1 START`);
standupModel
.find()
.then((standups) => {
standups.forEach((standup) => {
const members = new Set();
standup.members.forEach((member) => {
members.add(member);
})
members.forEach((member) => {
bot.users.cache.get(member).send(showPromptCommand.message);
})
});
})
.catch((err) => console.error(err));
}
);

/**
* Cron Job: 10:30:00 AM Europe/Zagreb - Go through each standup and output the responses to the channel
*/
let cron = schedule.scheduleJob(
{ hour: 10, minute: 30, dayOfWeek: new schedule.Range(1, 5), tz: "Europe/Zagreb" },
(time) => {
console.log(`[${time}] - CRON JOB 2 START`);
standupModel
.find()
.then((standups) => {
Expand Down

0 comments on commit 212b1b9

Please # to comment.