setNickName limitations

Hi everyone!
I have a bot that changes its nickname every time a websocket is updated (around 10/15 seconds) and I can't find the problem why it stops changing.
As a test, I made this method that I call every 1 second and you can see that after change #20 it stops updating.
As I checked on the Discord developers discord the API has a limitation that "it is returned in the response headers", but I don't know how to handle it from discord.js. Can anyone help me?

client.guilds.cache.forEach((guild) => {
        if (nickname != guild.members.me?.nickname) {
          debug(
            `Updating nickname of ${guild.members.me?.displayName} to ${nickname}`
          );
          guild.members.me
            ?.setNickname(nickname)
            .then((m) => debug("Nickname updated %O", m.nickname))
            .catch((e) => error(e));
        }
      });

Output

  bot-btc:updateNick:debug Updating nickname of 0 to 1 +0ms
  bot-btc:updateNick:debug Nickname updated '1' +301ms
  bot-btc:updateNick:debug Updating nickname of 1 to 2 +0ms
  bot-btc:updateNick:debug Nickname updated '2' +247ms
  [...]
  bot-btc:updateNick:debug Updating nickname of 18 to 19 +0ms
  bot-btc:updateNick:debug Nickname updated '19' +797ms
  bot-btc:updateNick:debug Updating nickname of 19 to 20 +0ms
  bot-btc:updateNick:debug Nickname updated '20' +334ms
  bot-btc:updateNick:debug Updating nickname of 20 to 21 +0ms
  bot-btc:updateNick:debug Updating nickname of 20 to 22 +0ms
  bot-btc:updateNick:debug Updating nickname of 20 to 23 +0ms
  bot-btc:updateNick:debug Updating nickname of 20 to 24 +0ms
  bot-btc:updateNick:debug Updating nickname of 20 to 25 +0ms
Was this page helpful?