Skip to content

Commit

Permalink
fix occasional duplicates + remove edit command
Browse files Browse the repository at this point in the history
  • Loading branch information
wdhdev committed Jul 27, 2024
1 parent 3669c9a commit abb15ee
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 135 deletions.
125 changes: 0 additions & 125 deletions src/commands/reminders/edit.ts

This file was deleted.

12 changes: 3 additions & 9 deletions src/events/client/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ const event: Event = {
}, 30 * 1000) // 30 seconds

// Manage timeouts
const setReminders: string[] = [];

async function manageExistingTimeouts() {
let reminders = await Reminder.find({});
const dueReminders = reminders.filter(reminder => reminder.due <= Date.now().toString());
Expand Down Expand Up @@ -84,9 +82,7 @@ const event: Event = {
}

for(const reminder of reminders) {
const result = await setReminder(reminder, client);

if(result) setReminders.push(`${reminder.user}-${reminder.reminder_id}`);
await setReminder(reminder, client);
}
}

Expand All @@ -97,11 +93,9 @@ const event: Event = {
if(reminders.length === 0) return;

for(const reminder of reminders) {
if(setReminders.includes(`${reminder.user}-${reminder.reminder_id}`)) continue;

const result = await setReminder(reminder, client);
if(client.reminders.get(`${reminder.user}-${reminder.reminder_id}`)) continue;

if(result) setReminders.push(`${reminder.user}-${reminder.reminder_id}`);
await setReminder(reminder, client);
}
}, 60000)
})
Expand Down
2 changes: 1 addition & 1 deletion src/util/setReminder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function (reminder: any, client: ExtendedClient): Promise<B
.setTitle("Reminder")
.setDescription(reminder.reason)
.addFields (
{ name: "Set", value: `<t:${reminder.set.toString().slice(0, -3)}:f>` }
{ name: "Set", value: `<t:${reminder.set.toString().slice(0, -3)}:f> (<t:${reminder.set.toString().slice(0, -3)}:R>)` }
)
.setFooter({ text: `ID: ${reminder.reminder_id}` })
.setTimestamp()
Expand Down

0 comments on commit abb15ee

Please sign in to comment.