Ask coding questions

← Back to all posts
why our discord bot is making too many requests?!
AbdulrahmanShaw (1)

We made a discord for studying server that starts timers and makes a leaderboard, the bot works fine but after random amount of use discord API banns the bot we looked on the code, but we couldn't find the block that could make too many requests.

The case is the bot is just sending messages and fetching some users names for the leaderboard.

Could you guys help us find why this thing is happening ?

Thanks for all.

The error message:

429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently.

HackermonDev (2020)

Although it is not recommended, running kill 1 in the replit's terminal resets the repl and changes the repl's IP address, momentarily bypassing the ban.

ch1ck3n (2065)

i have a feeling you are in a infinite loop. try making it so that the bot says something when it is doing an action to make sure how many times it's making a request or smth

AbdulrahmanShaw (1)

@ch1ck3n of course we have infinite loops to check if the timer ended, if the timer ended the bot will send a message to the channel

AbdulrahmanShaw (1)

@ch1ck3n do i have to add sleep to avoid this problem?

AbdulrahmanShaw (1)

@ch1ck3n but the bot is just uses message send function when the timer ends.

I didn't understand how this could happen while we are not using these functions

ch1ck3n (2065)

@AbdulrahmanShaw what lines accesses the API

AbdulrahmanShaw (1)

@ch1ck3n client.loop.create_task
And all the lines that has "await" word