mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
feat: allow multiple permission overwrites when editing channel (#2370)
* feat: allow multiple permission overwrites when editing channel * undo Permissions#resolve change
This commit is contained in:
26
src/structures/shared/resolvePermissions.js
Normal file
26
src/structures/shared/resolvePermissions.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const Permissions = require('../../util/Permissions');
|
||||
const Collection = require('../../util/Collection');
|
||||
|
||||
module.exports = function resolvePermissions(overwrites) {
|
||||
if (overwrites instanceof Collection || overwrites instanceof Array) {
|
||||
overwrites = overwrites.map(overwrite => {
|
||||
const role = this.guild.roles.resolve(overwrite.id);
|
||||
if (role) {
|
||||
overwrite.id = role.id;
|
||||
overwrite.type = 'role';
|
||||
} else {
|
||||
overwrite.id = this.client.users.resolveID(overwrite.id);
|
||||
overwrite.type = 'member';
|
||||
}
|
||||
|
||||
return {
|
||||
allow: Permissions.resolve(overwrite.allowed || 0),
|
||||
deny: Permissions.resolve(overwrite.denied || 0),
|
||||
type: overwrite.type,
|
||||
id: overwrite.id,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return overwrites;
|
||||
};
|
||||
Reference in New Issue
Block a user