Bugfix for removerole
This commit is contained in:
parent
a17420e87a
commit
4c5cb81e42
@ -18,6 +18,7 @@ class RemoveroleInfraction extends Infraction
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected member?: MemberWrapper;
|
protected member?: MemberWrapper;
|
||||||
|
private executorMember?: MemberWrapper;
|
||||||
|
|
||||||
constructor (client: DiscordClient, logger: LoggerClient, opts: RemoveRoleData)
|
constructor (client: DiscordClient, logger: LoggerClient, opts: RemoveRoleData)
|
||||||
{
|
{
|
||||||
@ -46,6 +47,7 @@ class RemoveroleInfraction extends Infraction
|
|||||||
if (!(opts.target instanceof MemberWrapper))
|
if (!(opts.target instanceof MemberWrapper))
|
||||||
throw new Error('Guild member required');
|
throw new Error('Guild member required');
|
||||||
this.member = opts.target;
|
this.member = opts.target;
|
||||||
|
this.executorMember = opts.executor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,10 +76,10 @@ class RemoveroleInfraction extends Infraction
|
|||||||
if (filtered.length === 0)
|
if (filtered.length === 0)
|
||||||
return super._fail('C_REMOVEROLE_ROLEHIERARCHYBOT');
|
return super._fail('C_REMOVEROLE_ROLEHIERARCHYBOT');
|
||||||
|
|
||||||
if (!(this.executor instanceof MemberWrapper))
|
if (!(this.executorMember instanceof MemberWrapper))
|
||||||
throw new Error('Invalid executor');
|
throw new Error('Invalid executor');
|
||||||
|
|
||||||
if (grantable.enabled && !this.executor!.permissions.has('ManageRoles'))
|
if (grantable.enabled && !this.executorMember!.permissions.has('ManageRoles'))
|
||||||
{
|
{
|
||||||
// Only use grantable roles
|
// Only use grantable roles
|
||||||
filtered = this.data.roles!.filter((r) => grantable.roles.includes(r.id));
|
filtered = this.data.roles!.filter((r) => grantable.roles.includes(r.id));
|
||||||
@ -89,7 +91,7 @@ class RemoveroleInfraction extends Infraction
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Just filter roles by position to your highest role
|
// Just filter roles by position to your highest role
|
||||||
const { highest: memberHighest } = this.executor.roles;
|
const { highest: memberHighest } = this.executorMember.roles;
|
||||||
filtered = this.data.roles!.filter((r) => r.comparePositionTo(memberHighest) < 0);
|
filtered = this.data.roles!.filter((r) => r.comparePositionTo(memberHighest) < 0);
|
||||||
if (filtered.length === 0)
|
if (filtered.length === 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user