mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-13 13:57:18 +00:00
Add safety check for role availability
This commit is contained in:
parent
c3f54954ca
commit
499853bb52
2 changed files with 4 additions and 2 deletions
|
@ -17,8 +17,9 @@ export async function clearExpiredMutes(pluginData: GuildPluginData<MutesPluginT
|
|||
}
|
||||
if (mute.roles_to_restore) {
|
||||
const memberOptions: MemberOptions = {};
|
||||
const guildRoles = pluginData.guild.roles;
|
||||
memberOptions.roles = Array.from(
|
||||
new Set([...mute.roles_to_restore, ...member.roles.filter(x => x !== muteRole)]),
|
||||
new Set([...mute.roles_to_restore, ...member.roles.filter(x => x !== muteRole && guildRoles.has(x))]),
|
||||
);
|
||||
member.edit(memberOptions);
|
||||
}
|
||||
|
|
|
@ -38,8 +38,9 @@ export async function unmuteUser(
|
|||
}
|
||||
if (existingMute?.roles_to_restore) {
|
||||
const memberOptions: MemberOptions = {};
|
||||
const guildRoles = pluginData.guild.roles;
|
||||
memberOptions.roles = Array.from(
|
||||
new Set([...existingMute.roles_to_restore, ...member.roles.filter(x => x !== muteRole)]),
|
||||
new Set([...existingMute.roles_to_restore, ...member.roles.filter(x => x !== muteRole && guildRoles.has(x))]),
|
||||
);
|
||||
member.edit(memberOptions);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue