← Back to Community
Uptime Robot not working with Discord Cloudflare
Profile icon
cloudagon

Apparently Uptime Robot is sending invalid requests so my bot got temporarily banned from discord.com and I cannot run it anymore. Is there any alternative to Uptime Robot that will work with Discord?

Answered by c4syner [earned 5 cycles]
View Answer
Voters
Profile icon
aboud8alaa
Profile icon
KrishnanShankar
Profile icon
G4RR3TTjonnyboi
Profile icon
cloudagon
Comments
hotnewtop
Profile icon
c4syner

Try using my modified version of keep_alive, it doesn't require an external pinger.

from flask import Flask from threading import Thread import random import time import requests import logging app = Flask('') @app.route('/') def home(): return "You have found the home of a Python program!" def run(): app.run(host='0.0.0.0',port=random.randint(2000,9000)) def ping(target, debug): while(True): r = requests.get(target) if(debug == True): print("Status Code: " + str(r.status_code)) time.sleep(random.randint(180,300)) #alternate ping time between 3 and 5 minutes def awake(target, debug=False): log = logging.getLogger('werkzeug') log.disabled = True app.logger.disabled = True t = Thread(target=run) r = Thread(target=ping, args=(target,debug,)) t.start() r.start()

Then usage would look like:

import neverSleep neverSleep.awake(yourReplURL, False) #All your code: \/
Profile icon
c4syner

@c4syner Oh and rename the top code to neverSleep.py. BTW I've had a discord bot staying alive for the past 2 months without issue with this!

Profile icon
cloudagon

@c4syner This looks promising! So I would put never sleep.awake at the top as opposed to right before bot.run?

Profile icon
c4syner

@xCloudzx That's just what I did, you could put this where keep_alive is. (removing keep_alive of course)

Profile icon
cloudagon

@c4syner Okay, thank you!

Profile icon
G4RR3TTjonnyboi

@c4syner Sorry I am just viewing this, I was wondering... Does it require Uptimerobot still? or is it just possible to have neversleep and no uptimerobot, idk thanks I know this was 5 months ago but just wondering...

Profile icon
c4syner

@G4RR3TTjonnyboi It's been a while since I've used this but when I first built this, it didn't need any external programs. It kept itself alive by essentially pinging itself every few random minutes.

Profile icon
G4RR3TTjonnyboi

@c4syner Thank you I know it has been a few months, It's just I have had the same problem and had to use this, Thanks and sorry for the trouble.

Profile icon
c4syner

@G4RR3TTjonnyboi No trouble at all! If you need help getting it set up just ping me here.

Profile icon
renderlab

@c4syner syntax error in "@app.route('/')"

Profile icon
c4syner

@renderlab Odd that wasn't there when I posted that a year ago, replace the faulty line with:

@app.route('/')
Profile icon
Coder100

Anyways, this has been happening to a lot of us recently with our bots going down and such. You can only keep up to 20 servers online at a time, however I feel like in your case, https://keeper-upper.turbio.repl.co and https://ping.matdoes.dev are good solutions.

Profile icon
cloudagon

@Coder100 I only have one bot on one server so that isn't a problem for me. Also those websites don't seem to be different from Uptime Robot's system so wouldn't it still break with them? Thanks for your help.

Profile icon
Coder100

@xCloudzx hi, the thing is, repl.it right now is a bit unstable, so the best thing you can do is to have as many pinging services as possible

Profile icon
Coder100

also, btw, keeper-upper is repl.it's official one @xCloudzx

Profile icon
Coder100

your bot cannot be banned unless the code is malicious, not anything to do with requests.

Profile icon
cloudagon

My bot was temporarily banned. I think Discord considers what I did to be API Abuse. @Coder100

Profile icon
Coder100

ohh no, that's a message overflow @xCloudzx

Profile icon
Coder100

basically someone sent a lot of commands and made your bot spam, and reach the quota @xCloudzx

Profile icon
Coder100

not a big deal, just make sure to add cooldown @xCloudzx

Profile icon
cloudagon

@Coder100 How would I do that? I've looked it up and found no answers. Is there any code I can look at?

Profile icon
Coder100

Store it in a dict, something like this:

cooldown = {} # set cooldown cooldown["user_id"] = 10 # now just make it go down every 1 second

@xCloudzx

Profile icon
cloudagon

@Coder100 Wouldn't that only allow me to send one message every 10 seconds on the whole bot, not just one server? That's too slow. Is there any way to just get the amount of time I need to wait and do it only when I need to wait?

Profile icon
Coder100
Profile icon
Coder100

right now, it will set the cooldown for that user globally, because doing it in just one server will not help with your problem @xCloudzx

Profile icon
Coder100
Profile icon
cloudagon

@Coder100 How do other bots handle this problem though? Because I'm sure not all of them have cooldowns.

Profile icon
Coder100

soft rate-limiting @xCloudzx

Profile icon
Coder100

unfortunately, you will need lower-level access to how the commands are executed to implement that @xCloudzx

Profile icon
Coder100

basically, every time a user sends a message, it will be put into a waiting line (an array), and every 0.5 seconds that array gets executed and cleared. If the bot experiences an API rate limiting, the array gets cleared to prevent spam. @xCloudzx

Profile icon
cloudagon

@Coder100 This looks like a very nice solution, I will definitely try it. Thanks!

Profile icon
cloudagon

@Coder100 I see, but how does that break my bot? I understand not sending the message, but why was I not able to run my bot?