-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backup member roles #18
Comments
Okay I just found backupMembers option in the code as its not in the docs but it backups the role IDs and it never restores them. Role names have to be stored function backupMemberRoles(members){
return [...members.values()].map(m => ({
id: m.id,
roles: [...m.roles.cache.values()].map(r => r.name).filter(name => name != '@everyone')
}))
}
async function restoreMemberRoles(members, backupRoles, gRoles){
let promises = []
for(let m of members){
let roles = backupRoles.find(o => o.id == m.id)
if(!roles) continue
let roleIDs = gRoles.filter(r => roles.some(name => r.name == name)).map(r => r.id)
promises.push(m.roles.add(roleIDs).then(o => true).catch(err => ({ id: m.id, roles, reason: err.message })))
}
return Promise.allSettled(promises)
} |
Submit a pull request |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be nice to have an option to backup member roles and restore them also an option to fetch members instead of taking them from cache
The text was updated successfully, but these errors were encountered: