Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!