Skip to content

Commit

Permalink
fix(reminders): add is_manually_deleted boolean to prevent sending me…
Browse files Browse the repository at this point in the history
…ssage when deleting reminders
  • Loading branch information
chimpdev committed Jan 14, 2025
1 parent 6d8803a commit d9f4e1c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/src/bot/commands/reminder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,17 @@ module.exports = {
break;
case 'delete':
var reminderId = interaction.options.getString('reminder');

var foundReminder = await Reminder.findOne({ _id: reminderId, 'user.id': interaction.user.id });
if (!foundReminder) return interaction.reply({
content: await interaction.translate('commands.reminder.errors.reminder_not_found'),
ephemeral: true
});

foundReminder.is_manually_deleted = true;

await foundReminder.save();

await foundReminder.deleteOne();

interaction.reply({
Expand Down
6 changes: 6 additions & 0 deletions server/src/schemas/Reminder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const ReminderSchema = new Schema({
expire_at: {
type: Date,
default: null
},
is_manually_deleted: {
type: Boolean,
default: false
}
}, {
timestamps: true
Expand All @@ -35,6 +39,8 @@ Model.watch().on('change', async data => {

await metadata.deleteOne();

if (metadata.is_manually_deleted) return;

const user = await client.users.fetch(metadata.userId).catch(() => null);
if (!user) return;

Expand Down

0 comments on commit d9f4e1c

Please sign in to comment.