Plugin-Cache Interaction

The interface you should use to have your plugin store data in the global cache.

class antispam.PluginCache(handler: antispam.anti_spam_handler.AntiSpamHandler, caller)

This class handles all data storage. You should simply refer to the methods in this class as your means of interacting with the internal cache

__init__(handler: antispam.anti_spam_handler.AntiSpamHandler, caller)
Parameters:
  • handler (AntiSpamHandler) – Your AntiSpamHandler instance
  • caller (class) – self, from the class using this class
get_guild_data(guild_id: int) → Any

Get a dictionary of all data for this guild that was stored by this class

Parameters:guild_id (int) – The guild to fetch
Returns:The data stored on this
Return type:Any
Raises:GuildNotFound – The given guild could not be found in the cache or it has no stored data
get_member_data(member_id: int, guild_id: int) → Any

Returns a dictionary of data this caller is allowed to access and store how they please

Parameters:
  • member_id (int) – The user we want to get data for
  • guild_id (int) – The guild for the user we want
Returns:

Stored data on this member which has been stored by this class

Return type:

Any

Raises:

MemberNotFound – The given user/guild could not be found internally or they have no stored data

set_guild_data(guild_id: int, addon_data: Any) → None

Stores the given addon data dictionary within the guilds cache

Parameters:
  • guild_id (int) – The guild to store this on
  • addon_data (Any) – The data to store on this guild

Notes

Silently creates a new Guild as required

set_member_data(member_id: int, guild_id: int, addon_data: Any) → None

Stores a member’s data within a guild

Parameters:
  • guild_id (int) – The guild to add this user’s data into
  • member_id (int) – The user’s id to store
  • addon_data (Any) – The data to store

Notes

Silently creates the required Guild / Member objects as needed