Skip to content

Commit

Permalink
Added examples to RoRClient.on and RoRClient.once
Browse files Browse the repository at this point in the history
  • Loading branch information
danmackey committed Sep 2, 2023
1 parent a16db7e commit 1bcb955
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ror_server_bot/ror_bot/ror_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ async def __aexit__(self, exc_type, exc, tb):
def on(self, event: RoRClientEvents, listener: Callable | None = None):
"""Decorator to register an event handler on the event emitter.
Example:
```
@client.on(RoRClientEvents.USER_JOIN)
def on_user_join(unique_id: int, user_info: UserInfo):
print(f'User {user_info.name} joined the server')
```
:param event: The event to register the handler on.
:param listener: The listener to register.
"""
Expand All @@ -71,6 +78,13 @@ def once(self, event: RoRClientEvents, listener: Callable | None = None):
"""Decorator to register a one-time event handler on the event
emitter.
Example:
```
@client.once(RoRClientEvents.CHAT)
def once_chat(unique_id: int, message: str):
print(f'User {unique_id} sent a message: {message}')
```
:param event: The event to register the handler on.
:param listener: The listener to register.
"""
Expand Down

0 comments on commit 1bcb955

Please sign in to comment.