hikaripersist.cache
Cache
Cache(
bot: hikari.GatewayBot,
backend: Backend,
*,
rule: Rule | None = None
)
Persistent cache for hikari-based Discord bots.
Create a new persistent cache.
| PARAMETER | DESCRIPTION |
|---|---|
bot
|
The bot to interface this cache with.
TYPE:
|
backend
|
The database backend to use with this cache.
TYPE:
|
rule
|
If provided, a ruleset regarding what is cached.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If an instance of |
TypeError
|
|
backup
async
clear
async
clear(
*,
channels: bool = False,
guilds: bool = False,
members: bool = False,
roles: bool = False
) -> None
Clear the cache of specific data.
| PARAMETER | DESCRIPTION |
|---|---|
channels
|
If cache channel data should be cleared.
TYPE:
|
guilds
|
If cache guild data should be cleared.
TYPE:
|
members
|
If cache member data should be cleared.
TYPE:
|
roles
|
If cache role data should be cleared.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If any parameter is not |
listen
listen(
event: type[EventT] | None = None,
*,
confirm: bool = False
) -> Callable[
[Callable[[EventT], Awaitable[None]]],
Callable[[EventT], Awaitable[None]],
]
Listen for an event and add this method as a callback.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
The event object to listen for, if provided, otherwise extracted from callback's first parameter type.
TYPE:
|
confirm
|
If
TYPE:
|
Note
To ensure that the cache sees all event data before being handled, the cache acts as a
middle-man in event dispatching. Instead of using @bot.listen(), use @cache.listen()
and the cache will dispatch each event normally after it's complete.
restore
async
subscribe
subscribe(
event: type[EventT],
callback: Callable[[EventT], Awaitable[None]],
*,
confirm: bool = False
) -> None
Subscribe to an event with a handler callback.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
The event object to subscribe to.
TYPE:
|
callback
|
The handler callback method. |
confirm
|
If
TYPE:
|