Top.py

Latest version: v1.4.3

Safety actively analyzes 688758 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 3

1.2.0

Not much changed, however it may be notable for some users:

* Anything that took a user ID, now takes a user object. (If you only have the ID, you can just wrap it in `discord.Object(id)`, it works the same)
* lower-level control of the ratelimiter has been removed. This means you cannot toggle the ratelimiter off, be it per-function or for the entire instance.
* The `toppy.errors.Ratelimited` error is now __always__ raised on ratelimit, and you cannot automatically wait it out instead (confusing behaviour)
* `Client.post_stats` no-longer allows an override
* *every request* now fires a new event: `on_toppy_request`, with key-word arguments `url:str` and `method:str`. This is meant to help people debug if they're firing lots of requests.

1.1.3pre.1

**Pre release, not fully tested.**

Changes this version:
Not much, just improved some behind the scenes stuff.

Major changes:
* Added the `Socials` model
* Added docstrings to most things
* Fixed up the vote server

1.1.0

TL;DR:

Basically bugfixes, more class-based objects, aliases and more bug fixes.

Changelog:

Added
* Added missing `fetch_user` function
* Added alias for `ColourOptions` (=> `ColorOptions`)
* Added typehints for most, if not all, data models (thank me later)
* Added `Vote` data class for vote webhooks

Changed
DEPRECATIONS & MAJOR
* `fetch_bot`, `fetch_user` and `fetch_stats` will soon use `discord.Object` and `discord.User` over raw integers. This will be changed in v1.3
* `toppy.server` has been completely re-written to be aiohttp native (untested). Nothing is the same as it was before.

Bug Fixes
* `KeyError` with the `User` model (for the "socials" field)
* `avatar` (and similar) fields not actually being the URL

General changes
* The vote webhook server now dispatches an event when someone votes.

*This update has passed the global-function check. All functions in the Client have suceeded without error before this publish.*
As always, if you find an error, please open an issue!

1.0.1

Updates:

* Fixed a "KeyError" when fetching votes - This was due to an undisclosed API change on behalf of top.gg
* Add new "in-house" ratelimiting, hopefully avoiding those dreaded 429's.
* Added examples to the README


Below are attached a source dist (top.py-1.0.1.tar.gz) and pre-built wheel (top.py-1.0.1-py3-none-any.whl)

1.0.0

Full release!

Features added this version:
* bulk fetch - allows fetching more than 500 bots at once
* Added 2 aliases for the vote check function

Test:
python
import discord
from toppy import TopGG
import toppy
import traceback


print("Imported toppy from", toppy.__file__)
from .toppy.server import


client = discord.Client()
top_client = TopGG(
client,
token=input("top.gg token "),
autopost=False
)


client.event
async def on_ready():
print("Fetching bot")
try:
print(await top_client.fetch_bot(client.user.id))
except Exception as e:
traceback.print_exc()
print(f"\N{cross mark} Failed with {e}.")

print("Fetching 50 bots...")
try:
print(await top_client.fetch_bots(50))
except Exception as e:
traceback.print_exc()
print(f"\N{cross mark} Failed with {e}.")
print("Fetching 1000 bots...")
try:
print(await top_client.bulk_fetch_bots(1000))
except Exception as e:
traceback.print_exc()
print(f"\N{cross mark} Failed with {e}.")

print("Fetching votes...")
try:
print(await top_client.fetch_votes())
except Exception as e:
traceback.print_exc()
print(f"\N{cross mark} Failed with {e}.")

print("Checking if 421698654189912064 has upvoted...")
try:
print(await top_client.fetch_votes())
except Exception as e:
traceback.print_exc()
print(f"\N{cross mark} Failed with {e}.")

print("Fetching bot stats")
try:
print(await top_client.get_stats(client.user.id))
except Exception as e:
traceback.print_exc()
print(f"\N{cross mark} Failed with {e}.")

print("And finally, posting stats...")
try:
print(await top_client.post_stats())
except Exception as e:
traceback.print_exc()
print(f"\N{cross mark} Failed with {e}.")
print("Ok, done. Logging out.")
return await client.logout()


client.run(input("bot token "))

0.2.0

all functions in `client.TopGG` are expected and tested to be functional.

Page 2 of 3

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.