forked from Galactic/galactic-bot
unlockdown fix
This commit is contained in:
parent
176269ece4
commit
9a879a64e7
@ -32,18 +32,22 @@ class UnlockdownInfraction extends Infraction {
|
||||
// }).first();
|
||||
|
||||
let latest = null;
|
||||
if (!this.data) {
|
||||
// console.log(this.data);
|
||||
if (!this.data || !Object.keys(this.data).length) {
|
||||
latest = await this.client.moderationManager.findLatestInfraction('LOCKDOWN', this.target);
|
||||
if (latest._callbacked || latest.resolved) return this._fail({ message: this.guild.format('INFRACTION_UNLOCKDOWN_NOTLOCKED') });
|
||||
}
|
||||
|
||||
// console.log(latest);
|
||||
const data = latest?.data || this.data;
|
||||
const oldPerms = data.oldPermissions;
|
||||
const permissions = this.target.permissionOverwrites;
|
||||
const overwrites = [...permissions.cache.values()];
|
||||
const newOverwrites = [];
|
||||
// console.log(data, oldPerms);
|
||||
|
||||
for (const permission of overwrites) {
|
||||
// console.log(permission);
|
||||
|
||||
if (!oldPerms[permission.id]) {
|
||||
newOverwrites.push(permission);
|
||||
@ -79,7 +83,7 @@ class UnlockdownInfraction extends Infraction {
|
||||
|
||||
if (latest) {
|
||||
const callback = this.client.moderationManager.callbacks.get(latest.id);
|
||||
await this.client.moderationManager.removeCallback(callback, true);
|
||||
if(callback) await this.client.moderationManager.removeCallback(callback, true);
|
||||
}
|
||||
|
||||
await this.handle();
|
||||
|
Loading…
Reference in New Issue
Block a user