can anyone help me revise the set position command

setPosition(role: MockRole, position: number) {
if (position < 0) position = 0;
const rolesToAdjust = this.guild.roles.cache.filter(
(role) => role.position! >= position
);
rolesToAdjust.forEach((role) => (role.position! += 1));
role.position = position;
}
setPosition(role: MockRole, position: number) {
if (position < 0) position = 0;
const rolesToAdjust = this.guild.roles.cache.filter(
(role) => role.position! >= position
);
rolesToAdjust.forEach((role) => (role.position! += 1));
role.position = position;
}
6 Replies
d.js toolkit
d.js toolkit3mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Syjalo
Syjalo3mo ago
You don't need to set position for each role. Just set for the one you want move and the position of others will be adjusted automatically
beanieemann
beanieemann3mo ago
This is a mock version of everything, that doesn't happen here
beanieemann
beanieemann3mo ago
GitHub
HueHueHue/tests/mock.ts at master · BeanieMen/HueHueHue
Contribute to BeanieMen/HueHueHue development by creating an account on GitHub.
Syjalo
Syjalo3mo ago
Then the question isn't related to discord.js #other-js-ts
beanieemann
beanieemann3mo ago
but i just wanted to know how the setPosition function works so i can mock it properly if you can explain how it works, i would be grateful Someone is mocking the api It would be redundant for me to do it Until that is completed This will suffice ig