Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
Discord.io bot stops being able to change server name after reconnecting

I've got a discord server that uses a bot using the discord.io library for Node.js. The bot has been running for over a year with no real problems but recently it's been breaking and I'm having a hard time figuring out why.

One of the things the bot does is periodically change the discord server name. This works fine for a bit, but every couple hours Discord will disconnect the bot and the bot will automatically reconnect, and after this happens the attempts by the bot to rename the server will fail. No error messages occur, and the bot continues to log messages as if it's renaming the server. Other bot functions still work normally.

The only way I've found to fix this issue is to manually go into server settings and change the server name while the bot is running. After doing this, the bot will successfully be able to rename the server until the next disconnect, at which point it will break again.

Simply restarting the bot does not fix the issue, and changing the server name manually while the bot is not running also does not fix the issue (i.e. bot breaks -> force quit bot -> manually rename server -> restart bot - doesn't fix it).

Here's some of the relevant parts of the code:

var Discord = require('discord.io');
var logger = require('winston');
var auth = require('./auth.json');

var bot = new Discord.Client({
   token: auth.token,
   autorun: true
});

function renameServer(){
    var myName = generateName();
    bot.editServer({serverID: myserverID, name: myName});
    logString('Server name changed to: ' + myName);
    
    currentName = myName;
}

bot.on('ready', function (evt) {
    logger.info('Connected');
    if (!intervalSet){
        renameInterval = setInterval(renameServer, renameTimer);
        intervalSet = true;
    }
    logger.info('renameTimer set to default of ' + renameTimer + ' milliseconds');
});

bot.on('disconnect', function (errMsg, code) {
    logger.info('Disconnected, attempting to reconnect...');
    bot.connect();
    logger.info(errMsg); //errMsg = "Reconnect requested by Discord"
});

Again, this code was running without issue for a year and only recently started breaking recently. Not really sure how to begin troubleshooting this, and experimentation can be awkward when I have to wait multiple hours for a disconnect each time. Any ideas on what could be causing this?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda