mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
Clean up Guild#setRolePosition slightly
This commit is contained in:
@@ -656,15 +656,13 @@ class Guild {
|
|||||||
if (role instanceof Role) {
|
if (role instanceof Role) {
|
||||||
role = role.id;
|
role = role.id;
|
||||||
} else if (typeof role !== 'string') {
|
} else if (typeof role !== 'string') {
|
||||||
return Promise.reject(new Error('Supplied role is not a role or string'));
|
return Promise.reject(new Error('Supplied role is not a role or string.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
position = Number(position);
|
position = Number(position);
|
||||||
if (isNaN(position)) {
|
if (isNaN(position)) return Promise.reject(new Error('Supplied position is not a number.'));
|
||||||
return Promise.reject(new Error('Supplied position is not a number'));
|
|
||||||
}
|
|
||||||
|
|
||||||
const updatedRoles = this.roles.array().map(r => ({
|
const updatedRoles = this.roles.map(r => ({
|
||||||
id: r.id,
|
id: r.id,
|
||||||
position: r.id === role ? position : r.position < position ? r.position : r.position + 1,
|
position: r.id === role ? position : r.position < position ? r.position : r.position + 1,
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user