I've been working on a program for a program for running a Discord bot using Replit as the host. Recently, my bot has been getting rate limited by Discord. I read in this post that the cause of this is most likely due to Replit sharing an IP address between my bot and other users' bots.
As a temporary fix, I've been rebooting my Replit by typing "kill 1" into the shell console to restart the bot on different IP addresses. However, this process has been cumbersome and problematic since I want to have my bot running 24/7. Another user in the post linked above suggested that it was possible to write a script that detects and executes the kill 1 command every time the bot is banned. I was curious if this is possible and if it is what an example script may look like. For reference, my bot is coded in Python. Thanks for any help.
...
The question deemed a duplicate to mine does not answer my question nor does it help me to understand how I can create my own code to fix this problem.
My aim is to: 1. Detect when the bot has been rate limited 2. Kill the program 3. Have the program automatically restart on a new IP address without having to manually press the "Run" button.
I am not sure if there is a way to use os.kill()
to accomplish all of these tasks although if it can I would like help understanding how.
My problem is the same outline in the post I referred to earlier if that helps.
if <program detects ban>
//kill program
//restart Replit