Updating command permissions removes any custom overrides. Using multiple add()
instead of set()
calls could be a solution, but could also cause rate-limiting if there are a lot of staff roles.
|
if (req.user.accessToken) { |
|
Promise.all([ |
|
'Create ticket for user', |
|
'claim', |
|
'force-close', |
|
'move', |
|
'priority', |
|
'release', |
|
].map(name => |
|
client.application.commands.permissions.set({ |
|
command: client.application.commands.cache.find(cmd => cmd.name === name), |
|
guild, |
|
permissions: [ |
|
{ |
|
id: guild.id, // @everyone |
|
permission: false, |
|
type: ApplicationCommandPermissionType.Role, |
|
}, |
|
...category.staffRoles.map(id => ({ |
|
id, |
|
permission: true, |
|
type: ApplicationCommandPermissionType.Role, |
|
})), |
|
], |
|
token: req.user.accessToken, |
|
}), |
|
)) |
|
.then(() => client.log.success('Updated application command permissions in "%s"', guild.name)) |
|
.catch(error => client.log.error(error)); |
|
} |