S
S
sqtr2020-12-01 21:18:48
Node.js
sqtr, 2020-12-01 21:18:48

The bot stops changing the color of the role. How to fix?

The bot on Discord JS, at one point, simply stopped changing the color of the role at startup. Didn't change anything. I tried to add it to another server, it worked there and later stopped working again.

bot.on('ready', () => {
  console.log('Бот запущен✅');

  setInterval(() => {
    var serv = bot.guilds.cache.get("783324048583032862");
    var channel = serv.roles.cache.get("783395502472691752");
    channel.setColor(`#FF0000`);
    channel.setColor(`#FA8072`);
    channel.setColor(`#FFA500`);
    channel.setColor(`#FFD700`);
    channel.setColor(`#FFFF00`);
    channel.setColor(`#7FFF00`);
    channel.setColor(`#00FFFF`);
    channel.setColor(`#00BFFF`);
    channel.setColor(`#9400D3`);
    channel.setColor(`#DC143C`);
    }, 100);
  });

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2020-12-01
@sqtr

If I'm not mistaken, the Discord API has a kind of "protection system" against rainbow roles, so such a bot will not work for a long time.

A
Amoralny, 2020-12-03
Cat @Amoralny

I certainly don't write in JS, but I would suggest waiting before each color change.

...
#спать 3 секунд
channel.setColor(`#FA8072`);
#спать 3 секунд
channel.setColor(`#FFA500`);
#спать 3 секунд
channel.setColor(`#FFD700`);
...

You can still drive the shift into for, then the code will turn out to be smaller.
The longer the interval, the lower the chance of a ban.
Considering all the nuances - a rather useless function :(

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question