Top-gg-Community / python-sdk

A simple API wrapper for top.gg written in Python
https://docs.top.gg/docs/Libraries/python
MIT License
90 stars 54 forks source link

Ratelimited #71

Closed Hype3808 closed 2 years ago

Hype3808 commented 2 years ago

This issue tracker is ONLY used for reporting bugs with topggpy. Feel free to share your suggestions in the #api channel in our Discord server!

For help with general Python issues, use StackOverflow, our #development channel, or the Python Discord server.

I keep being ratelimited. All my logging files are full with topggpy ratelimited, retrying in ????s

Expected Behavior

I shouldn't be ratelimited

Current Behavior

I am being ratelimited after some time I started my bot

Development Environment

Python 3.9.10 topggpy@master Linux

Steps to Reproduce

  1. Start my bot
  2. Check logging files and will see [2022-03-17 02:23:59] [WARNING] topgg.http: We are being ratelimited. Retrying in ???.?? seconds (??? minutes).
  3. Wait for sometime and will see some html come out from the terminal which half of it is gone probably too long

Context

My logging files are full of topgg.http

Possible Solution

Make the task loop longer/let us set the loop

Detailed Description

Possible Implementation

norinorin commented 2 years ago

It's been a while since the last time I worked on a Discord bot but I'm fairly sure the loop interval is pretty long enough. If anything, you can set the interval manually—please refer to this.

Also, did you by any chance run multiple instances of your bot?

Hype3808 commented 2 years ago

It's been a while since the last time I worked on a Discord bot but I'm fairly sure the loop interval is pretty long enough. If anything, you can set the interval manually—please refer to this.

Also, did you by any chance run multiple instances of your bot?

wdym by running multiple instances of my bot?

Hype3808 commented 2 years ago

or is there anywhere to avoid html from outputting? the terminal is full of htmls

Hype3808 commented 2 years ago
self.topgg_client = topgg.DBLClient(getenv('TOPGG_TOKEN'), default_bot_id=803405588993540147).set_data(self)
        self.autoposter: topgg.AutoPoster = (
            self.topgg_client.autopost()
            .on_success(on_autopost_success)
            .on_error(on_autopost_error)
            .stats(autopost)
            .set_interval(datetime.timedelta(hours=5))
        )

the code if needed... this is in the subclass of commands.Bot

Hype3808 commented 2 years ago

i recently just added .set_interval to the code..

Hype3808 commented 2 years ago

i recently just added .set_interval to the code..

even tho i did this, i still get the html output after a few minutes of startup? could it be something else?

Hype3808 commented 2 years ago

This issue is resolved by by putting it to setup_hook