but receiving commands but not responding and not restarting

Hi! I've got a problem with my bot. It works fine most of the time and restarts correctly every day. However, it sometimes stops responding to commands and can no longer send messages. In the console I can see that commands are received but not answered. There are no errors sent (even with .catch). I can evaluate javascript code via discord with an eval command which allows me to deduce the following elements: - I can access client data such as client.username or client.id, I can console.log and view them. - When I make a fetch attempt, for example: (eval client.users.fetch("360034833876910082").then(console.log).catch(console.log)) I get no response, positive or negative. When I try to restart the bot, the commands are loaded, it connects to its database but the shard doesn't spawn. Without an error, nothing happens and no shard spawns. It's on just over 22k guilds. I wonder if there isn't a ratelimit story behind this, where I might have done something wrong. But not having made any mistakes I don't understand. Has anyone encountered a similar problem? Thanks in advance!
9 Replies
d.js toolkit
d.js toolkit12mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
Beau de l'aire
Beau de l'aireOP12mo ago
I just found that I have the same problem with a test bot on the same host
jordan
jordan12mo ago
Are the test bot and your main bot the same? I'm not really sure what is happening, I haven't had anything like this happen before, but I feel like if no error is being thrown, maybe the request is timing out or something? If you do a command, does the bot reply anything at all, even like a Discord generated error like "The application timed out"?
TheActualGamer1YT
You would still most likely get the error
jordan
jordan12mo ago
yeah I figured it probably would.
d.js docs
d.js docs11mo ago
Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.
client
.on("debug", console.log)
.on("warn", console.log)
client
.on("debug", console.log)
.on("warn", console.log)
- Note: if you initialize your Client as bot or other identifiers you need to use these instead of client - If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebin
Beau de l'aire
Beau de l'aireOP11mo ago
No, it's two different tokens I will try this, thanks Would I get an error or something if that was it? Ok, thanks, I will see After seeing the problem again, I get the "Preparing to connect to the gateway..." log, even when the bot doesn't start up. However, the shard does not spawn and does not receive its guilds and I have no additional log Ouch I'm not sure what a 429s is. I have a dozen shards, running on the same server and the same PM2 process.
d.js docs
d.js docs11mo ago
discord Rate Limits - Invalid Request Limit aka CloudFlare bans 429 responses are avoided by inspecting the rate limit headers documented above and by not making requests on exhausted buckets until after they have reset. 429 errors returned with X-RateLimit-Scope: shared are not counted against you read more
Beau de l'aire
Beau de l'aireOP10mo ago
Hmmm, so it's to much invalid requests ? I saw I should have 22 shards for 22k guilds, could add shards solve the problem ? To be honest, I don't know much about it, does Discord JS implement this? Or would there be documentation? Thanks a lot, I will look at this, I have a last question, shouldn't I have received error messages telling me that I was rate-limited? Hmmm, good to know, I'm going to find out all about it, thanks again! Hello again, after a bit of investigation and your messages I think I've understood the problem. My bot is divided into shards, and the shards independently manage the queue system to avoid ratelimits. So some people send requests when I'm already limited, which leads to a cloudflare ban. So to avoid this I'd have to "group" the shards (queues) using a rest proxy. All I know about proxies is that they are intermediaries for communicating between a client and a server, for example. I've done some research but I can't see how to implement this "grouping". I guess the code in the documentation isn't enough:
import { REST } from '@discordjs/rest';

const rest = new REST({
api: 'http://localhost:8080/api',
});
import { REST } from '@discordjs/rest';

const rest = new REST({
api: 'http://localhost:8080/api',
});
but I have no idea what I should add / start developing. I don't want to take up too much of your time, but maybe you've got a hint or example handy? Yep, they are all on the same host I'm gonna learn to use Docker, I think the time has come So, while doing this, I will have a rest instance running in local, something like this ? Discord API <-> Cloudflare <-> My local rest <-> Shards 0, 1, 2 etc. Discord API <- Cloudflare <- My local rest <- Shards 0, 1, 2 etc. And it should work That's true, thanks Hi, and sorry for coming back after so long. It seems that Docker isn't compatible with my host T_T Do you know if it's possible to install the proxy without it ? Thanks ! I'm searching for example on the guide and the documentation but I can't find anything... I'm trying to play with "proxyRequests" but I don't think it's the way that works Start and run the proxy With the docker command I succeeded locally It works perfectly both in local and on the host I don't know how to thanks you, you really helped me a lot, have a nice sunday !
Want results from more Discord servers?
Add your server