Closed AleeQuintino closed 1 year ago
Is there a reason you pass TOKEN
and not db.TOKEN
to the login call? Because the latter would match the data structure you mentioned, while the former would make each client try to login with the same token.
orque o último corresponderia à estrutura de dados que você mencionou, enquanto o primeiro faria com que cada cliente tentasse fazer login com o mesmo token.
sorry, I think I expressed myself badly. I updated the issue
I have the Token and the Client stored in the DB, a token for each client.
I run the .login with the specific client token
Your code sample isn’t really reproducible though without you showing the actual loop you use. So if you really think this to be a bug provide a reproducible sample.
Your code sample isn’t really reproducible though without you showing the actual loop you use. So if you really think this to be a bug provide a reproducible sample.
Sorry, I edited the issue and added the code sample. This is a simplified working sample of my code
Your code checking which one of your clients caused the error is flawed. You find the first client in your clients
array with status Status.Ready = 0
so you look for the first that did succeed logging in. Not one that didn’t… so you‘re probably looking at the wrong place for a wrong token. And it is a wrong token for sure.
Your code checking which one of your clients caused the error is flawed. You find the first client in your
clients
array with statusStatus.Ready = 0
so you look for the first that did succeed logging in. Not one that didn’t… so you‘re probably looking at the wrong place for a wrong token. And it is a wrong token for sure.
How could I collect the client that has an authentication error efficiently, could you help me?
process.on("uncaughtException", async (exception) => {
for (const clientId in clients) {
if (clients.hasOwnProperty(clientId)) {
try {
await clients[clientId].ws.shards.get(0).status;
continue;
} catch (error) {
console.log(`Erro no cliente ${clientId}:`, error);
clients[clientId].destroy();
clients[clientId] = null;
// Se ocorreu um erro, retorna
return;
}
}
}
console.log(`Ocorreu um erro inesperado que quebraria o código:`, exception);
});
Would that fix my problem? I want to implement and analyze my logs to check if it really is just an invalid token
If you need help fixing your problems please join the support discord server. Unless you can provide an actual reproducible code that shows this is a bug in discord.js and not an invalid token this issue can be closed.
Which package is this bug report for?
discord.js
Issue description
I have an application that runs multiple clients.
For some reason, some are returning Authentication Failed, and even if I destroy the section and start it again, it keeps giving this error. The token is correct because when I destroy it with .destroy() and rebuild the client with .login(token) it logs correctly.
Another point that I noticed is that this error only happens in the client that is at the top, if I destroy it and don't start again, the next one that is at the top starts to give the error.
I build the clients like this:
db: {CLIENTID, TOKEN}
then I do a for on all DB records, and execute:
So I have a process.on to collect general errors that stop the process, generating a log for me. built like this:
then inside process.on I check which client generated the error by looking for the ws status like this:
clients[for.CLIENTID].ws.status === 0 && exception.message == 'Authentication failed'
then it gives this error here:
[9:57 AM] error: unexpected error occurred that would stop the code
Code sample
Versions
discord.js v14.11.0 nodejs v18.16.0
Issue priority
High (immediate attention needed)
Which partials do you have configured?
Channel
Which gateway intents are you subscribing to?
Guilds, GuildEmojisAndStickers, GuildIntegrations, GuildWebhooks, GuildInvites, GuildVoiceStates, GuildMessages, GuildMessageReactions, GuildMessageTyping, DirectMessages, DirectMessageReactions, DirectMessageTyping, MessageContent, GuildScheduledEvents
I have tested this issue on a development release
No response