unlockdown fix

This commit is contained in:
Erik 2022-07-12 13:11:26 +03:00
parent 176269ece4
commit 9a879a64e7
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -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();