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 toolkit9mo 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
Syjalo9mo 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
beanieemannOP9mo ago
This is a mock version of everything, that doesn't happen here
beanieemann
beanieemannOP9mo ago
GitHub
HueHueHue/tests/mock.ts at master · BeanieMen/HueHueHue
Contribute to BeanieMen/HueHueHue development by creating an account on GitHub.
Syjalo
Syjalo9mo ago
Then the question isn't related to discord.js #other-js-ts
beanieemann
beanieemannOP9mo 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
Want results from more Discord servers?
Add your server