bugfix to lockdown

This commit is contained in:
Erik 2022-09-06 13:09:58 +03:00
parent bdc8df3334
commit 46c2bf689c
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
2 changed files with 10 additions and 6 deletions

View File

@ -87,12 +87,15 @@ class LockdownInfraction extends Infraction {
// await permissions.edit(permission.id, {
// SendMessages: false,
// AddReactions: false
// }, { type: permission.type === 'role' ? 0 : 1, reason: this._reason });
// }, { type: permission.type, reason: this._reason });
// } catch (error) {
// this._fail();
// console.log(permission.id, permission, error);
// continue;
// // this._fail();
// }
// console.log(this.data.oldPermissions[permission.id]);
}
// return this._fail();
// The everyone role won't be edited unless it has any changes, so ensure it has been processed
if (!this.data.oldPermissions[everyoneRole.id]) {
@ -128,11 +131,12 @@ class LockdownInfraction extends Infraction {
newOverwrites[index].deny.remove('SendMessages');
} else newOverwrites.push({
id: this.client.user.id,
allow: ['SendMessages', 'ManageRoles']
allow: ['SendMessages'],
type: OverwriteType.Member
});
await permissions.set(newOverwrites, this._reason);
await this.handle();
return this._succeed();
@ -141,7 +145,7 @@ class LockdownInfraction extends Infraction {
async verify() {
const perms = this.target.permissionsFor(this.client.user);
const missing = perms.missing(['ManageRoles', 'SendMessages', 'AddReactions']);
const missing = perms.missing(['ManageRoles', 'SendMessages', 'AddReactions', 'ViewChannel']);
if (missing.length) return this._fail(this.guild.format('INFRACTION_LOCKDOWN_MISSING_PERMS', { missing: missing.join('**, **') }), null, true);
return super._verify();

View File

@ -35,7 +35,7 @@ class UnlockdownInfraction extends Infraction {
// 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('INFRACTION_UNLOCKDOWN_NOTLOCKED');
if (!latest || latest._callbacked || latest.resolved) return this._fail('INFRACTION_UNLOCKDOWN_NOTLOCKED');
}
// console.log(latest);