Discord Ratelimit

Some users are seeing issues where their Discord Bot will go down without any errors or logs, even though the Repl will still be running.

This is due to Discord’s rate-limiting system and the fact that we use shared IPs. Discord blocks access to the Discord API for multiple Repls when a single IP is rate-limited.

We have recognized this issue and are working towards a resolution. Please refer to this forum post for updates on the issue.

18 Likes

Thank you for raising this issue.
I moved my bot from the Heroku platform (it’s clear for what reason) and these problems appeared here.
Last night my bot was disconnected from the Discord API without any errors displayed in the log. I will be following this topic with great attention. I can help if any tests are needed.

4 Likes

It is called a 429 Error btw! I have the code to get past this for anyone using Discord.py

1 Like

Hey dude, could I have it?

This was the reason I stopped hosting my bots on replit. If anyone has a solution or workaround (as it appears ex130 may) that would be great.

Don’t expect 24/7 reliability, but dis-uniter · PyPI

1 Like

Here it is:
Main.py:

(At the top of the file)

import os
from os import system

(At the bottom of the file)

try:
  client.run(os.getenv("TOKEN"))
#Bot Restarter
except discord.errors.HTTPException:
  print("\n\n\nBLOCKED BY RATE LIMITS\nRESTARTING NOW\n\n\n")
  system("restarter.py")
  system('kill 1')

Restarter.py:

from time import sleep
from os import system

sleep(7)
system("main.py")

Hope this helped!

thanks! it turns out my bot isnt getting blocked anymore for some reason, but im saving the code!

This code does not prevent ratelimits. It just restarts when it gets ratelimited and switches IP address. But even after switching it can still get ratelimited.

Replit is just not reliable for hosting Discord bots.

3 Likes

Appreciate that code for restarting on rate limits is hard to test (unless you’re one of the spammer bot owners causing them on replit :supervillain:), but the code wouldn’t work as expected. restarter.py is an invalid command in the scope of this code (why not just import restarter?) The system commands execute before the kill 1 happens… but you don’t see the 7-second delay because the commands are invalid anyhow.
The code works visibly while you’re looking at the repl because the webview sends a request to the repl right after it recognises that it’s disconnected, so the code restarts. Also the rate limit error would have to not have been caught somewhere else, e.g. by on_error

2 Likes

Just a question, are you using discord.py or (the less known) interactions.py? Becuase interactions.py has built-in features to handle rate limits.

so does discord.py along with the listed libraries… but they don’t handle invalid request (cloudflare) rate limits, and normal rate limits cause them to wait for long even though someone else on your IP is causing it.
This person was probably using discord.js because this is its behaviour on an invalid request rate limit

1 Like

I use discord.js
Need similar workaround code but in JS.
Hope replit team will fix this problem soon

You can make a bounty for this or ask in #code-help:html-css-js but there is no guarantee somebody would write the program for you in the category.

replit-dis-uniter - npm (npmjs.com) was written only for others :man_shrugging: but yeah, definitely no guarantee for any future similar things

1 Like

Is there any solution till date ?
i used discord.js

No there is no solution. A member of the Replit team will give an update when one comes

but there is a workaround

this not work… This is not solution.
I have workaround code for node.js with shell kill 1 command. Will paste later

sob., 7 sty 2023, 20:07 użytkownik Umar Sharief via Replit Ask <notifications@replitteams.discoursemail.com> napisał: