Skip to content

hikaripersist.rule

ChannelRule

ChannelRule(
    *,
    channel_denylist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    channel_allowlist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    guild_denylist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    guild_allowlist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    predicate: (
        Callable[[hikari.GuildChannel], bool] | None
    ) = None
)

Channel cache rule.

Create a cache channel rule.

PARAMETER DESCRIPTION
channel_denylist

If provided, an iterable of channels to ignore.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

channel_allowlist

If provided, ignore all channels except these.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

guild_denylist

If provided, an iterable of guilds to ignore.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

guild_allowlist

If provided, ignore all guilds except these.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

predicate

If provided, a predicate method used for advanced, custom filtration of pending channels. Returns True if the channel should be cached, False otherwise.

TYPE: Callable[[hikari.GuildChannel], bool] | None DEFAULT: None

RAISES DESCRIPTION
TypeError

If any parameter except predicate is provided and is not Iterable of hikari.Snowflakeish.

can_cache

can_cache(channel: hikari.GuildChannel) -> bool

Return whether a channel passes the rule.

GuildRule

GuildRule(
    *,
    guild_denylist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    guild_allowlist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    predicate: Callable[[hikari.Guild], bool] | None = None
)

Guild cache rule.

Create a cache guild rule.

PARAMETER DESCRIPTION
guild_denylist

If provided, an iterable of all guilds to ignore.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

guild_allowlist

If provided, ignore all guilds except these.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

predicate

If provided, a predicate method used for advanced, custom filtration of pending guilds. Returns True if the guild should be cached, False otherwise.

TYPE: Callable[[hikari.Guild], bool] | None DEFAULT: None

RAISES DESCRIPTION
TypeError

If any parameter except predicate is provided and is not Iterable of hikari.Snowflakeish.

can_cache

can_cache(guild: hikari.Guild) -> bool

Return whether a guild passes the rule.

MemberRule

MemberRule(
    *,
    guild_denylist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    guild_allowlist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    user_denylist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    user_allowlist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    predicate: Callable[[hikari.Member], bool] | None = None
)

Member cache rule.

Create a cache member rule.

PARAMETER DESCRIPTION
guild_denylist

If provided, an iterable of all guilds to ignore.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

guild_allowlist

If provided, ignore all guilds except these.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

user_denylist

If provided, an iterable of all users to ignore.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

user_allowlist

If provided, ignore all users except these.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

predicate

If provided, a predicate method used for advanced, custom filtration of pending members. Returns True if the member should be cached, False otherwise.

TYPE: Callable[[hikari.Member], bool] | None DEFAULT: None

RAISES DESCRIPTION
TypeError

If any parameter except predicate is provided and is not Iterable of hikari.Snowflakeish.

can_cache

can_cache(member: hikari.Member) -> bool

Return whether a member passes the rule.

RoleRule

RoleRule(
    *,
    guild_denylist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    guild_allowlist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    role_denylist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    role_allowlist: (
        Iterable[hikari.Snowflakeish] | None
    ) = None,
    predicate: Callable[[hikari.Role], bool] | None = None
)

Role cache rule.

Create a cache role rule.

PARAMETER DESCRIPTION
guild_denylist

If provided, an iterable of all guilds to ignore.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

guild_allowlist

If provided, ignore all guilds except these.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

role_denylist

If provided, an iterable of all roles to ignore.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

role_allowlist

If provided, ignore all roles except these.

TYPE: Iterable[hikari.Snowflakeish] | None DEFAULT: None

predicate

If provided, a predicate method used for advanced, custom filtration of pending roles. Returns True if the role should be cached, False otherwise.

TYPE: Callable[[hikari.Role], bool] | None DEFAULT: None

RAISES DESCRIPTION
TypeError

If any parameter except predicate is provided and is not Iterable of hikari.Snowflakeish.

can_cache

can_cache(role: hikari.Role) -> bool

Return whether a role passes the rule.

Rule

Rule(
    *,
    channel: ChannelRule | None = None,
    guild: GuildRule | None = None,
    member: MemberRule | None = None,
    role: RoleRule | None = None
)

Cache ruleset.

Create a cache rule.

PARAMETER DESCRIPTION
channel

If provided, rule regarding channel caching.

TYPE: ChannelRule | None DEFAULT: None

guild

If provided, rule regarding guild caching.

TYPE: GuildRule | None DEFAULT: None

member

If provided, rule regarding member caching.

TYPE: MemberRule | None DEFAULT: None

role

If provided, rule regarding role caching.

TYPE: RoleRule | None DEFAULT: None

RAISES DESCRIPTION
TypeError
  • If channel is provided and is not ChannelRule.
  • If guild is provided and is not GuildRule.
  • If member is provided and is not MemberRule.
  • If role is provided and is not RoleRule.