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

114
Visualizações
How to use multiple tokens DiscordJS

I'm making custom bots for a project and i'm trying to connect multiple tokens with differents clients so i can manage every clients one by one

My actual code is

const tokens = ['token_1', 'token_2']
const { Client } = require('discord.js');

for(const token of tokens) {
const client = new Client();

client.on('ready', () => {
console.log(client.user.id)
});

client.login(token)
} 

But imagine i want the second bot to send a message in a channel, how do i do this ?

Because if i put the channel.send in the for it will send the message with every bot, and i just want one bot, and i think client[0] does not work, if somebody can help it would be very cool

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

You can for example add a new array which will contain the clients

const { Client } = require('discord.js');
const tokens = ['token_1', 'token_2'];
const clients = [];

for(const token of tokens) {
  const client = new Client();
  clients.push(client);

  client.on('ready', () => {
    console.log(client.user.id);
  });

  client.login(token);
}

clients[0] will now returns the first client

about 4 years ago · Santiago Gelvez Relatório
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