2

I am using Discord.py for my bot and this error occurs: websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 4008 (private use), reason = Rate limited.

It happens when I use this:

while true:
  activity=discord.Game(name=f"some stuff")
  await client.change_presence(activity=activity, status=status)

It is in an async function, so it is not related to async/await usage.

2 Answers 2

3

Its apparently because of how frequently your status changes, there is almost no delay which makes the discord API considers it as an API abuse.

You might wanna try adding a suitable delay for the changing status

while true:
  activity=discord.Game(name=f"some stuff")
  await client.change_presence(activity=activity, status=status)
  await asyncio.sleep(20) #time in seconds
1
  • Thanks! Also, I fixed the problem myself but this can stay for future reference :) Commented Aug 15, 2019 at 12:38
1

I recently found out that it is caused by the while loop that constantly updates and causes the server to rate-limit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.