mirror of
https://github.com/ION606/selmerBot.git
synced 2026-05-14 21:26:54 +00:00
Fixed an issue with the 'guildDelete' event
This commit is contained in:
@@ -237,10 +237,13 @@ bot.on("guildDelete", guild => {
|
|||||||
|
|
||||||
//ReminderKeys are all stored as userId, the reminders themselves are not
|
//ReminderKeys are all stored as userId, the reminders themselves are not
|
||||||
dbo.findOne({userId: guild.id}).then((doc) => {
|
dbo.findOne({userId: guild.id}).then((doc) => {
|
||||||
|
if (!doc || !doc.times) { return; }
|
||||||
|
|
||||||
times = doc.times;
|
times = doc.times;
|
||||||
const tbo = client.db('main').collection('reminders');
|
const tbo = client.db('main').collection('reminders');
|
||||||
|
|
||||||
tbo.find({time: {$in: times}}).toArray((err, docs) => {
|
tbo.find({time: {$in: times}}).toArray((err, docs) => {
|
||||||
|
try {
|
||||||
for (let i = 0; i < docs.length; i ++) {
|
for (let i = 0; i < docs.length; i ++) {
|
||||||
for (let j in docs[i]) {
|
for (let j in docs[i]) {
|
||||||
if (!isNaN(j) && (docs[i][j].guildId == guild.id)) {
|
if (!isNaN(j) && (docs[i][j].guildId == guild.id)) {
|
||||||
@@ -255,12 +258,15 @@ bot.on("guildDelete", guild => {
|
|||||||
tbo.deleteOne({ time: docs[i].time });
|
tbo.deleteOne({ time: docs[i].time });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
dbo.deleteOne({ userId: guild.id });
|
dbo.deleteOne({ userId: guild.id });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user