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
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