Skip to content

Commit

Permalink
Remove debugging steps, wait until bot is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
vcarl committed Dec 29, 2021
1 parent b390ffe commit a2800d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/features/scheduled-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ If something crosses a line, give it a 👎, or if you'd prefer to remain anonym
export const messages: MessageConfig[] = [];

export const scheduleMessages = (bot: discord.Client) => {
MESSAGE_SCHEDULE.forEach((messageConfig) => sendMessage(bot, messageConfig));
bot.on("ready", () => {
MESSAGE_SCHEDULE.forEach((messageConfig) =>
sendMessage(bot, messageConfig),
);
});
};

const sendMessage = async (
Expand All @@ -126,7 +130,6 @@ const sendMessage = async (
const { message, postTo } = messageConfig;
postTo.forEach(
async ({ guildId = "102860784329052160", channelId, interval }) => {
// const guild = await bot.guilds.fetch(guildId);
const channel = await bot.channels.fetch(channelId);

if (channel === null) {
Expand All @@ -143,13 +146,9 @@ const sendMessage = async (
);
return;
}
// scheduleTask(interval, () => {
try {
scheduleTask(interval, () => {
channel.send(message);
} catch (e) {
console.log("butts", e);
}
// });
});
},
);
};
1 change: 0 additions & 1 deletion src/helpers/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { subDays, parseISO, format } from "date-fns";
* Sunday at midnight.
*/
const getFirstRun = (interval: number, now = new Date()) => {
return 0;
const dayOfWeek = now.getDay();
const sundayMidnight = subDays(
parseISO(format(now, "yyyy-MM-dd")),
Expand Down

0 comments on commit a2800d3

Please sign in to comment.