3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-11 20:55:01 +00:00

Centralize periodic checks for mutes, tempbans, vcalerts, reminders, and scheduled posts

This should result in a significant performance improvement.
The new method is also more precise than the old one, allowing
the aforementioned checks to be performed with second-precision.
This commit is contained in:
Dragory 2021-09-25 21:33:59 +03:00
parent c84d1a0be1
commit c7751a9da1
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
55 changed files with 883 additions and 366 deletions

View file

@ -5,6 +5,7 @@ import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { convertDelayStringToMS, messageLink } from "../../../utils";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
import { remindersCmd } from "../types";
import { registerUpcomingReminder } from "../../../data/loops/upcomingRemindersLoop";
export const RemindCmd = remindersCmd({
trigger: ["remind", "remindme", "reminder"],
@ -50,7 +51,7 @@ export const RemindCmd = remindersCmd({
}
const reminderBody = args.reminder || messageLink(pluginData.guild.id, msg.channel.id, msg.id);
await pluginData.state.reminders.add(
const reminder = await pluginData.state.reminders.add(
msg.author.id,
msg.channel.id,
reminderTime.clone().tz("Etc/UTC").format("YYYY-MM-DD HH:mm:ss"),
@ -58,6 +59,8 @@ export const RemindCmd = remindersCmd({
moment.utc().format("YYYY-MM-DD HH:mm:ss"),
);
registerUpcomingReminder(reminder);
const msUntilReminder = reminderTime.diff(now);
const timeUntilReminder = humanizeDuration(msUntilReminder, { largest: 2, round: true });
const prettyReminderTime = (await timeAndDate.inMemberTz(msg.author.id, reminderTime)).format(