RoleUpdate Bug
I want to get the last updated role id, but it constantly prints the role id to the console .log.
Is it normal to log this much?
46 Replies
- 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!self-assignable roles (server guide etc.) are also emitted as roles updates
also make sure you don't nest listeners within one another
for example nesting this listener inside a messageCreate listener would attach a new roleUpdate listener for every message you receive and that can get out of hand quite quickly
i just want to get the id of the last updated role
but it seems to loop when I do it this way.
there is no other listener only rolupdate listener in my bot
put a log directly above the
client.on
and see if it gets attached multiple timesCan you write a sample code?
I'm trying now
only outside
the inner one would be execution, not attaching
its ok ?
sure
if you get that log more than once that explains everything
only wrote 1 message to the log
do more happen if you use the bot, assign/remove roles, etc.
attaching roleUpdate listener
but we didn't include that log in the listener except that log will only be triggered when the bot starts.
if that is actually the case, that's good
i did everything it just wrote a message to the log once
There is a problem with the roleupdate listener
now I'm getting the code to write messages to that log inside the role update listener
this for
when i change role permission it sends message like this
you are changing one permission of one role and get this?
yes
even when there is no loop i created a new bot just for this
maybe there is a bug in this version
When I update a role only once, it logs as much as the number of roles on the server.
you only change permission, not the role order?
if you move the role, that'd make sense, since the position of the others will change as well
No, I just change the permission, for example, when I open the manage server permission to any role, it logs like this.
it just goes into loop when i change role permission
i cannot reproduce that behaviour, if i change a permission i get a single roleUpdate event, as expected
If you want I can share my codes with you.
that's the minimal sample, works as expected
(can ofc drop some intents, but this is my test instance with no code whatsoever)
What is the discord.js version?
14.13.0
now i will try with this code
issue with that is that it's integrated and uses quite a lot of things that i cannot just run here
i created a new blank project i am trying now
I tried your same codes
you update various roles here
those are all different ids
maybe your server has a bot that does weird things
well, then i have no idea
there is only bot and me, and when I update 1 role on the server, it logs like this, it's ridiculous, don't you have the same thing?
nope
okey
i mean, we can euqalize the comparison: https://discord.gg/ZStBC2Vj
press the admin button and invite your bot
Thanks ı will trying
I solved my mistake, the error was not in me or in the codes, the error was in the server, the server entered the bug, I put the same bot in a different server and it works without any errors.
hm, interesting
1 bot and 60 roles open
test
If you read the message from the beginning, you will understand what I have done.
I was manually updating the server settings from the roles section with the manual discord application.
Yes exactly
I solved the problem, it was a problem with the server
The server has entered a bug, for example, there are 2 roles named new roles, I cannot delete them.
I'm writing a bot, I'm writing console.log('new attack') to the roleupdate event on my bot, when I update a role, it enters a manual loop
so i don't actually loop it but it keeps throwing the log message as if it is looping when the role is due