Question: How to listen for new level rated (any level)
Closed this issue · 4 comments
Deleted user commented
Im really confused on how to use the available listeners from this module. I wanna do something if a level gets rated like printing the information about it or storing into a variable. Can someone help me please.
DenoXen commented
interesting question..
nekitdev commented
First of all, listener's stable API is available only in development version as of now.
You can install it via
python -m pip install --upgrade https://github.com/NeKitDS/gd.py/archive/master.zip
I thought I described events and listeners fine in the docs
Anyways, here is a quick example of doing something when a level gets rated:
import gd
client = gd.Client() # create our client
client.listen_for("rate") # create level rate listener
@client.event
async def on_level_rated(level: gd.Level) -> None:
print(f"{level.name} was rated! ID: {level.id}.")
gd.events.run() # blocks the thread until stopped
Deleted user commented
Thanks, that was a fast response.
nekitdev commented
No problem, have fun! :)