Closed fourjr closed 6 years ago
Additionally to comply to PEP8 which an example really should, you should have two linebreaks before your class declaration. And following d.py best practices your file at the top and class should have descriptions.
In the example I would also demonstrate hooking into the guild join/leave events and the on ready event for posting stats.
It shouldn't hook into join/leave imo, because of API ratelimits.
As this is a full library for API contact, I would personally expect the library to handle ratelimiting itself so that you can do what you want and it will stop you getting api blocked by doing its own ratelimiting. This would then allow you to safely hook into join/leave.
With regards to get_server_count
, that function is there to also get the server count of other bots (if need be), so personally I feel getting the id from the passed bot object wouldn't be useful in this case.
Hooking into join/leave is not necessary. Hooking like the js library is now preferred. js lib does every 30 minutes
On Mon, Feb 12, 2018, 00:50 Matt (IPv4), notifications@github.com wrote:
As this is a full library for API contact, I would personally expect the library to handle ratelimiting itself so that you can do what you want and it will stop you getting api blocked by doing its own ratelimiting. This would then allow you to safely hook into join/leave.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DiscordBotList/DBL-Python-Library/issues/2#issuecomment-364797505, or mute the thread https://github.com/notifications/unsubscribe-auth/AENItLwd-7RIEbLrhRoGsJmEOIQduYGCks5tT262gaJpZM4SBi47 .
@FishyFing, Bot ID can be an optional argument but it defaults to the current bot
Refer to #3
TODO:
[x] Fix docstrings
[x] Implement ratelimits
[x] Update README.rst with correct example
[x] Push to Pypi
Example
asyncio
bot = bot
should beself.bot = bot
An example of background task (with an interval of maybe 3 hours) of posting server countRefer to below @MattIPv4 repliesClient
methods as wellWrapper
Client
Client
get_server_count
andpost_server_count
as it can be retrieved from the bot object passed from initClient