Fix Persist assigning deleted roles (#288)
This commit is contained in:
parent
a45b5c8ba0
commit
2d84a02d48
1 changed files with 4 additions and 2 deletions
|
@ -43,10 +43,12 @@ export const LoadDataEvt = persistEvt({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const guildRoles = Array.from(pluginData.guild.roles.cache.keys());
|
||||||
|
|
||||||
// Check specific role permissions
|
// Check specific role permissions
|
||||||
if (config.persisted_roles) {
|
if (config.persisted_roles) {
|
||||||
for (const roleId of config.persisted_roles) {
|
for (const roleId of config.persisted_roles) {
|
||||||
if (!canAssignRole(pluginData.guild, me, roleId)) {
|
if (!canAssignRole(pluginData.guild, me, roleId) && guildRoles.includes(roleId)) {
|
||||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||||
body: `Missing permissions to assign role \`${roleId}\` in persist plugin`,
|
body: `Missing permissions to assign role \`${roleId}\` in persist plugin`,
|
||||||
});
|
});
|
||||||
|
@ -57,7 +59,7 @@ export const LoadDataEvt = persistEvt({
|
||||||
|
|
||||||
const persistedRoles = config.persisted_roles;
|
const persistedRoles = config.persisted_roles;
|
||||||
if (persistedRoles.length) {
|
if (persistedRoles.length) {
|
||||||
const rolesToRestore = intersection(persistedRoles, persistedData.roles);
|
const rolesToRestore = intersection(persistedRoles, persistedData.roles, guildRoles);
|
||||||
|
|
||||||
if (rolesToRestore.length) {
|
if (rolesToRestore.length) {
|
||||||
restoredData.push("roles");
|
restoredData.push("roles");
|
||||||
|
|
Loading…
Add table
Reference in a new issue