Documentation ¶
Index ¶
- func PolicyAll[T any](_ T) bool
- func PolicyMembersPending(member discord.Member) bool
- func PolicyNone[T any](_ T) bool
- type Cache
- type Caches
- type ChannelCache
- type Config
- type ConfigOpt
- func WithCaches(flags ...Flags) ConfigOpt
- func WithChannelCache(channelCache ChannelCache) ConfigOpt
- func WithChannelCachePolicy(policy Policy[discord.GuildChannel]) ConfigOpt
- func WithEmojiCache(emojiCache EmojiCache) ConfigOpt
- func WithEmojiCachePolicy(policy Policy[discord.Emoji]) ConfigOpt
- func WithGuildCache(guildCache GuildCache) ConfigOpt
- func WithGuildCachePolicy(policy Policy[discord.Guild]) ConfigOpt
- func WithGuildScheduledEventCache(guildScheduledEventCache GuildScheduledEventCache) ConfigOpt
- func WithGuildScheduledEventCachePolicy(policy Policy[discord.GuildScheduledEvent]) ConfigOpt
- func WithMemberCache(memberCache MemberCache) ConfigOpt
- func WithMemberCachePolicy(policy Policy[discord.Member]) ConfigOpt
- func WithMessageCache(messageCache MessageCache) ConfigOpt
- func WithMessageCachePolicy(policy Policy[discord.Message]) ConfigOpt
- func WithPresenceCache(presenceCache PresenceCache) ConfigOpt
- func WithPresenceCachePolicy(policy Policy[discord.Presence]) ConfigOpt
- func WithRoleCache(roleCache RoleCache) ConfigOpt
- func WithRoleCachePolicy(policy Policy[discord.Role]) ConfigOpt
- func WithStageInstanceCache(stageInstanceCache StageInstanceCache) ConfigOpt
- func WithStageInstanceCachePolicy(policy Policy[discord.StageInstance]) ConfigOpt
- func WithStickerCache(stickerCache StickerCache) ConfigOpt
- func WithStickerCachePolicy(policy Policy[discord.Sticker]) ConfigOpt
- func WithThreadMemberCache(threadMemberCache ThreadMemberCache) ConfigOpt
- func WithThreadMemberCachePolicy(policy Policy[discord.ThreadMember]) ConfigOpt
- func WithVoiceStateCache(voiceStateCache VoiceStateCache) ConfigOpt
- func WithVoiceStateCachePolicy(policy Policy[discord.VoiceState]) ConfigOpt
- type DefaultCache
- func (c *DefaultCache[T]) ForEach(forEachFunc func(entity T))
- func (c *DefaultCache[T]) Get(id snowflake.ID) (T, bool)
- func (c *DefaultCache[T]) Len() int
- func (c *DefaultCache[T]) Put(id snowflake.ID, entity T)
- func (c *DefaultCache[T]) Remove(id snowflake.ID) (T, bool)
- func (c *DefaultCache[T]) RemoveIf(filterFunc FilterFunc[T])
- type EmojiCache
- type FilterFunc
- type Flags
- type GroupedCache
- type GroupedFilterFunc
- type GuildCache
- type GuildScheduledEventCache
- type MemberCache
- type MessageCache
- type Policy
- func AllPolicies[T any](policies ...Policy[T]) Policy[T]
- func AnyPolicy[T any](policies ...Policy[T]) Policy[T]
- func PolicyChannelExclude(channelTypes ...discord.ChannelType) Policy[discord.Channel]
- func PolicyChannelInclude(channelTypes ...discord.ChannelType) Policy[discord.Channel]
- func PolicyMembersInVoice(caches Caches) Policy[discord.Member]
- func PolicyMembersInclude(guildIDs ...snowflake.ID) Policy[discord.Member]
- type PresenceCache
- type RoleCache
- type SelfUserCache
- type Set
- type StageInstanceCache
- type StickerCache
- type ThreadMemberCache
- type VoiceStateCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PolicyMembersPending ¶ added in v0.12.0
PolicyMembersPending is a policy that will only cache members that are pending.
func PolicyNone ¶ added in v0.10.3
PolicyNone returns a policy that will never cache anything.
Types ¶
type Cache ¶
type Cache[T any] interface { // Get returns a copy of the entity with the given snowflake and a bool whether it was found or not. Get(id snowflake.ID) (T, bool) // Put stores the given entity with the given snowflake as key. If the entity is already present, it will be overwritten. Put(id snowflake.ID, entity T) // Remove removes the entity with the given snowflake as key and returns a copy of the entity and a bool whether it was removed or not. Remove(id snowflake.ID) (T, bool) // RemoveIf removes all entities that pass the given FilterFunc RemoveIf(filterFunc FilterFunc[T]) // Len returns the number of entities in the cache. Len() int // ForEach calls the given function for each entity in the cache. ForEach(func(entity T)) }
Cache is a simple key value store. They key is always a snowflake.ID. The cache provides a simple way to store and retrieve entities. But is not guaranteed to be thread safe as this depends on the underlying implementation.
func NewCache ¶
NewCache returns a new DefaultCache implementation which filter the entities after the gives Flags and Policy. This cache implementation is thread safe and can be used in multiple goroutines without any issues. It also only hands out copies to the entities. Regardless these entities should be handles as immutable.
type Caches ¶
type Caches interface { SelfUserCache GuildCache ChannelCache StageInstanceCache GuildScheduledEventCache RoleCache MemberCache ThreadMemberCache PresenceCache VoiceStateCache MessageCache EmojiCache StickerCache // CacheFlags returns the current configured FLags of the caches. CacheFlags() Flags // MemberPermissions returns the calculated permissions of the given member. // This requires the FlagRoles to be set. MemberPermissions(member discord.Member) discord.Permissions // MemberPermissionsInChannel returns the calculated permissions of the given member in the given channel. // This requires the FlagRoles and FlagChannels to be set. MemberPermissionsInChannel(channel discord.GuildChannel, member discord.Member) discord.Permissions // MemberRoles returns all roles of the given member. // This requires the FlagRoles to be set. MemberRoles(member discord.Member) []discord.Role // AudioChannelMembers returns all members which are in the given audio channel. // This requires the FlagVoiceStates to be set. AudioChannelMembers(channel discord.GuildAudioChannel) []discord.Member // SelfMember returns the current bot member from the given guildID. // This is only available after we received the gateway.EventTypeGuildCreate event for the given guildID. SelfMember(guildID snowflake.ID) (discord.Member, bool) // GuildThreadsInChannel returns all discord.GuildThread from the ChannelCache and a bool indicating if it exists. GuildThreadsInChannel(channelID snowflake.ID) []discord.GuildThread // GuildMessageChannel returns a discord.GuildMessageChannel from the ChannelCache and a bool indicating if it exists. GuildMessageChannel(channelID snowflake.ID) (discord.GuildMessageChannel, bool) // GuildThread returns a discord.GuildThread from the ChannelCache and a bool indicating if it exists. GuildThread(channelID snowflake.ID) (discord.GuildThread, bool) // GuildAudioChannel returns a discord.GetGuildAudioChannel from the ChannelCache and a bool indicating if it exists. GuildAudioChannel(channelID snowflake.ID) (discord.GuildAudioChannel, bool) // GuildTextChannel returns a discord.GuildTextChannel from the ChannelCache and a bool indicating if it exists. GuildTextChannel(channelID snowflake.ID) (discord.GuildTextChannel, bool) // GuildVoiceChannel returns a discord.GuildVoiceChannel from the ChannelCache and a bool indicating if it exists. GuildVoiceChannel(channelID snowflake.ID) (discord.GuildVoiceChannel, bool) // GuildCategoryChannel returns a discord.GuildCategoryChannel from the ChannelCache and a bool indicating if it exists. GuildCategoryChannel(channelID snowflake.ID) (discord.GuildCategoryChannel, bool) // GuildNewsChannel returns a discord.GuildNewsChannel from the ChannelCache and a bool indicating if it exists. GuildNewsChannel(channelID snowflake.ID) (discord.GuildNewsChannel, bool) // GuildNewsThread returns a discord.GuildThread from the ChannelCache and a bool indicating if it exists. GuildNewsThread(channelID snowflake.ID) (discord.GuildThread, bool) // GuildPublicThread returns a discord.GuildThread from the ChannelCache and a bool indicating if it exists. GuildPublicThread(channelID snowflake.ID) (discord.GuildThread, bool) // GuildPrivateThread returns a discord.GuildThread from the ChannelCache and a bool indicating if it exists. GuildPrivateThread(channelID snowflake.ID) (discord.GuildThread, bool) // GuildStageVoiceChannel returns a discord.GuildStageVoiceChannel from the ChannelCache and a bool indicating if it exists. GuildStageVoiceChannel(channelID snowflake.ID) (discord.GuildStageVoiceChannel, bool) // GuildForumChannel returns a discord.GuildForumChannel from the ChannelCache and a bool indicating if it exists. GuildForumChannel(channelID snowflake.ID) (discord.GuildForumChannel, bool) // GuildMediaChannel returns a discord.GuildMediaChannel from the ChannelCache and a bool indicating if it exists. GuildMediaChannel(channelID snowflake.ID) (discord.GuildMediaChannel, bool) }
Caches combines all different entity caches into one with some utility methods.
type ChannelCache ¶
type ChannelCache interface { Channel(channelID snowflake.ID) (discord.GuildChannel, bool) ChannelsForEach(fn func(channel discord.GuildChannel)) ChannelsLen() int AddChannel(channel discord.GuildChannel) RemoveChannel(channelID snowflake.ID) (discord.GuildChannel, bool) RemoveChannelsByGuildID(guildID snowflake.ID) }
func NewChannelCache ¶
func NewChannelCache(cache Cache[discord.GuildChannel]) ChannelCache
type Config ¶
type Config struct { CacheFlags Flags SelfUserCache SelfUserCache GuildCache GuildCache GuildCachePolicy Policy[discord.Guild] ChannelCache ChannelCache ChannelCachePolicy Policy[discord.GuildChannel] StageInstanceCache StageInstanceCache StageInstanceCachePolicy Policy[discord.StageInstance] GuildScheduledEventCache GuildScheduledEventCache GuildScheduledEventCachePolicy Policy[discord.GuildScheduledEvent] RoleCache RoleCache RoleCachePolicy Policy[discord.Role] MemberCache MemberCache MemberCachePolicy Policy[discord.Member] ThreadMemberCache ThreadMemberCache ThreadMemberCachePolicy Policy[discord.ThreadMember] PresenceCache PresenceCache PresenceCachePolicy Policy[discord.Presence] VoiceStateCache VoiceStateCache VoiceStateCachePolicy Policy[discord.VoiceState] MessageCache MessageCache MessageCachePolicy Policy[discord.Message] EmojiCache EmojiCache EmojiCachePolicy Policy[discord.Emoji] StickerCache StickerCache StickerCachePolicy Policy[discord.Sticker] }
Config lets you configure your Caches instance.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with sensible defaults.
type ConfigOpt ¶
type ConfigOpt func(config *Config)
ConfigOpt is a type alias for a function that takes a Config and is used to configure your Caches.
func WithCaches ¶ added in v0.15.0
WithCaches sets the Flags of the Config.
func WithChannelCache ¶ added in v0.15.0
func WithChannelCache(channelCache ChannelCache) ConfigOpt
WithChannelCache sets the ChannelCache of the Config.
func WithChannelCachePolicy ¶ added in v0.10.3
func WithChannelCachePolicy(policy Policy[discord.GuildChannel]) ConfigOpt
WithChannelCachePolicy sets the Policy[discord.Channel] of the Config.
func WithEmojiCache ¶ added in v0.15.0
func WithEmojiCache(emojiCache EmojiCache) ConfigOpt
WithEmojiCache sets the EmojiCache of the Config.
func WithEmojiCachePolicy ¶ added in v0.10.3
WithEmojiCachePolicy sets the Policy[discord.Emoji] of the Config.
func WithGuildCache ¶ added in v0.15.0
func WithGuildCache(guildCache GuildCache) ConfigOpt
WithGuildCache sets the GuildCache of the Config.
func WithGuildCachePolicy ¶ added in v0.10.3
WithGuildCachePolicy sets the Policy[discord.Guild] of the Config.
func WithGuildScheduledEventCache ¶ added in v0.15.0
func WithGuildScheduledEventCache(guildScheduledEventCache GuildScheduledEventCache) ConfigOpt
WithGuildScheduledEventCache sets the GuildScheduledEventCache of the Config.
func WithGuildScheduledEventCachePolicy ¶ added in v0.10.3
func WithGuildScheduledEventCachePolicy(policy Policy[discord.GuildScheduledEvent]) ConfigOpt
WithGuildScheduledEventCachePolicy sets the Policy[discord.GuildScheduledEvent] of the Config.
func WithMemberCache ¶ added in v0.15.0
func WithMemberCache(memberCache MemberCache) ConfigOpt
WithMemberCache sets the MemberCache of the Config.
func WithMemberCachePolicy ¶
WithMemberCachePolicy sets the Policy[discord.Member] of the Config.
func WithMessageCache ¶ added in v0.15.0
func WithMessageCache(messageCache MessageCache) ConfigOpt
WithMessageCache sets the MessageCache of the Config.
func WithMessageCachePolicy ¶
WithMessageCachePolicy sets the Policy[discord.Message] of the Config.
func WithPresenceCache ¶ added in v0.15.0
func WithPresenceCache(presenceCache PresenceCache) ConfigOpt
WithPresenceCache sets the PresenceCache of the Config.
func WithPresenceCachePolicy ¶ added in v0.10.3
WithPresenceCachePolicy sets the Policy[discord.Presence] of the Config.
func WithRoleCache ¶ added in v0.15.0
WithRoleCache sets the RoleCache of the Config.
func WithRoleCachePolicy ¶ added in v0.10.3
WithRoleCachePolicy sets the Policy[discord.Role] of the Config.
func WithStageInstanceCache ¶ added in v0.15.0
func WithStageInstanceCache(stageInstanceCache StageInstanceCache) ConfigOpt
WithStageInstanceCache sets the StageInstanceCache of the Config.
func WithStageInstanceCachePolicy ¶ added in v0.10.3
func WithStageInstanceCachePolicy(policy Policy[discord.StageInstance]) ConfigOpt
WithStageInstanceCachePolicy sets the Policy[discord.Guild] of the Config.
func WithStickerCache ¶ added in v0.15.0
func WithStickerCache(stickerCache StickerCache) ConfigOpt
WithStickerCache sets the StickerCache of the Config.
func WithStickerCachePolicy ¶ added in v0.10.3
WithStickerCachePolicy sets the Policy[discord.Sticker] of the Config.
func WithThreadMemberCache ¶ added in v0.15.0
func WithThreadMemberCache(threadMemberCache ThreadMemberCache) ConfigOpt
WithThreadMemberCache sets the ThreadMemberCache of the Config.
func WithThreadMemberCachePolicy ¶ added in v0.10.3
func WithThreadMemberCachePolicy(policy Policy[discord.ThreadMember]) ConfigOpt
WithThreadMemberCachePolicy sets the Policy[discord.ThreadMember] of the Config.
func WithVoiceStateCache ¶ added in v0.15.0
func WithVoiceStateCache(voiceStateCache VoiceStateCache) ConfigOpt
WithVoiceStateCache sets the VoiceStateCache of the Config.
func WithVoiceStateCachePolicy ¶ added in v0.10.3
func WithVoiceStateCachePolicy(policy Policy[discord.VoiceState]) ConfigOpt
WithVoiceStateCachePolicy sets the Policy[discord.VoiceState] of the Config.
type DefaultCache ¶
type DefaultCache[T any] struct { // contains filtered or unexported fields }
DefaultCache is a simple thread safe cache key value store.
func (*DefaultCache[T]) ForEach ¶
func (c *DefaultCache[T]) ForEach(forEachFunc func(entity T))
func (*DefaultCache[T]) Get ¶
func (c *DefaultCache[T]) Get(id snowflake.ID) (T, bool)
func (*DefaultCache[T]) Len ¶ added in v0.12.0
func (c *DefaultCache[T]) Len() int
func (*DefaultCache[T]) Put ¶
func (c *DefaultCache[T]) Put(id snowflake.ID, entity T)
func (*DefaultCache[T]) Remove ¶
func (c *DefaultCache[T]) Remove(id snowflake.ID) (T, bool)
func (*DefaultCache[T]) RemoveIf ¶
func (c *DefaultCache[T]) RemoveIf(filterFunc FilterFunc[T])
type EmojiCache ¶ added in v0.15.0
type EmojiCache interface { Emoji(guildID snowflake.ID, emojiID snowflake.ID) (discord.Emoji, bool) EmojisForEach(guildID snowflake.ID, fn func(emoji discord.Emoji)) EmojisAllLen() int EmojisLen(guildID snowflake.ID) int AddEmoji(emoji discord.Emoji) RemoveEmoji(guildID snowflake.ID, emojiID snowflake.ID) (discord.Emoji, bool) RemoveEmojisByGuildID(guildID snowflake.ID) }
func NewEmojiCache ¶ added in v0.15.0
func NewEmojiCache(cache GroupedCache[discord.Emoji]) EmojiCache
type Flags ¶
type Flags int
Flags are used to enable/disable certain internal caches
const ( FlagGuilds Flags = 1 << iota FlagGuildScheduledEvents FlagMembers FlagThreadMembers FlagMessages FlagPresences FlagChannels FlagRoles FlagEmojis FlagStickers FlagVoiceStates FlagStageInstances FlagsNone Flags = 0 FlagsAll = FlagGuilds | FlagGuildScheduledEvents | FlagMembers | FlagThreadMembers | FlagMessages | FlagPresences | FlagChannels | FlagRoles | FlagEmojis | FlagStickers | FlagVoiceStates | FlagStageInstances )
values for CacheFlags
type GroupedCache ¶
type GroupedCache[T any] interface { // Get returns a copy of the entity with the given groupID and ID and a bool wheaten it was found or not. Get(groupID snowflake.ID, id snowflake.ID) (T, bool) // Put stores the given entity with the given groupID and ID as key. If the entity is already present, it will be overwritten. Put(groupID snowflake.ID, id snowflake.ID, entity T) // Remove removes the entity with the given groupID and ID as key and returns a copy of the entity and a bool whether it was removed or not. Remove(groupID snowflake.ID, id snowflake.ID) (T, bool) // GroupRemove removes all entities in the given groupID. GroupRemove(groupID snowflake.ID) // RemoveIf removes all entities that pass the given GroupedFilterFunc. RemoveIf(filterFunc GroupedFilterFunc[T]) // GroupRemoveIf removes all entities that pass the given GroupedFilterFunc within the groupID. GroupRemoveIf(groupID snowflake.ID, filterFunc GroupedFilterFunc[T]) // Len returns the total number of entities in the cache. Len() int // GroupLen returns the number of entities in the cache within the groupID. GroupLen(groupID snowflake.ID) int // ForEach calls the given function for each entity in the cache. ForEach(func(groupID snowflake.ID, entity T)) // GroupForEach calls the given function for each entity in the cache within the groupID. GroupForEach(groupID snowflake.ID, forEachFunc func(entity T)) }
GroupedCache is a simple key value store grouped by a snowflake.ID. They key is always a snowflake.ID. The cache provides a simple way to store and retrieve entities. But is not guaranteed to be thread safe as this depends on the underlying implementation.
func NewGroupedCache ¶
func NewGroupedCache[T any](flags Flags, neededFlags Flags, policy Policy[T]) GroupedCache[T]
NewGroupedCache returns a new default GroupedCache with the provided flags, neededFlags and policy.
type GroupedFilterFunc ¶ added in v0.12.0
GroupedFilterFunc is used to filter grouped cached entities.
type GuildCache ¶
type GuildCache interface { IsGuildUnready(guildID snowflake.ID) bool SetGuildUnready(guildID snowflake.ID, unready bool) UnreadyGuildIDs() []snowflake.ID Guild(guildID snowflake.ID) (discord.Guild, bool) GuildsForEach(fn func(guild discord.Guild)) GuildsLen() int AddGuild(guild discord.Guild) RemoveGuild(guildID snowflake.ID) (discord.Guild, bool) }
func NewGuildCache ¶
type GuildScheduledEventCache ¶ added in v0.15.0
type GuildScheduledEventCache interface { GuildScheduledEvent(guildID snowflake.ID, guildScheduledEventID snowflake.ID) (discord.GuildScheduledEvent, bool) GuildScheduledEventsForEach(guildID snowflake.ID, fn func(guildScheduledEvent discord.GuildScheduledEvent)) GuildScheduledEventsAllLen() int GuildScheduledEventsLen(guildID snowflake.ID) int AddGuildScheduledEvent(guildScheduledEvent discord.GuildScheduledEvent) RemoveGuildScheduledEvent(guildID snowflake.ID, guildScheduledEventID snowflake.ID) (discord.GuildScheduledEvent, bool) RemoveGuildScheduledEventsByGuildID(guildID snowflake.ID) }
func NewGuildScheduledEventCache ¶ added in v0.15.0
func NewGuildScheduledEventCache(cache GroupedCache[discord.GuildScheduledEvent]) GuildScheduledEventCache
type MemberCache ¶ added in v0.15.0
type MemberCache interface { Member(guildID snowflake.ID, userID snowflake.ID) (discord.Member, bool) MembersForEach(guildID snowflake.ID, fn func(member discord.Member)) MembersAllLen() int MembersLen(guildID snowflake.ID) int AddMember(member discord.Member) RemoveMember(guildID snowflake.ID, userID snowflake.ID) (discord.Member, bool) RemoveMembersByGuildID(guildID snowflake.ID) }
func NewMemberCache ¶ added in v0.15.0
func NewMemberCache(cache GroupedCache[discord.Member]) MemberCache
type MessageCache ¶ added in v0.15.0
type MessageCache interface { Message(channelID snowflake.ID, messageID snowflake.ID) (discord.Message, bool) MessagesForEach(channelID snowflake.ID, fn func(message discord.Message)) MessagesAllLen() int MessagesLen(guildID snowflake.ID) int AddMessage(message discord.Message) RemoveMessage(channelID snowflake.ID, messageID snowflake.ID) (discord.Message, bool) RemoveMessagesByChannelID(channelID snowflake.ID) RemoveMessagesByGuildID(guildID snowflake.ID) }
func NewMessageCache ¶ added in v0.15.0
func NewMessageCache(cache GroupedCache[discord.Message]) MessageCache
type Policy ¶
Policy can be used to define your own policy for when entities should be cached.
func AllPolicies ¶
AllPolicies is a shorthand for CachePolicy.And(CachePolicy).And(CachePolicy) etc.
func PolicyChannelExclude ¶ added in v0.12.0
func PolicyChannelExclude(channelTypes ...discord.ChannelType) Policy[discord.Channel]
PolicyChannelExclude returns a policy that will not cache channels of the given types.
func PolicyChannelInclude ¶ added in v0.12.0
func PolicyChannelInclude(channelTypes ...discord.ChannelType) Policy[discord.Channel]
PolicyChannelInclude returns a policy that will only cache channels of the given types.
func PolicyMembersInVoice ¶ added in v0.12.0
PolicyMembersInVoice returns a policy that will only cache members that are connected to an audio channel.
func PolicyMembersInclude ¶ added in v0.12.0
PolicyMembersInclude returns a policy that will only cache members of the given guilds.
type PresenceCache ¶ added in v0.15.0
type PresenceCache interface { Presence(guildID snowflake.ID, userID snowflake.ID) (discord.Presence, bool) PresenceForEach(guildID snowflake.ID, fn func(presence discord.Presence)) PresencesAllLen() int PresencesLen(guildID snowflake.ID) int AddPresence(presence discord.Presence) RemovePresence(guildID snowflake.ID, userID snowflake.ID) (discord.Presence, bool) RemovePresencesByGuildID(guildID snowflake.ID) }
func NewPresenceCache ¶ added in v0.15.0
func NewPresenceCache(cache GroupedCache[discord.Presence]) PresenceCache
type RoleCache ¶ added in v0.15.0
type RoleCache interface { Role(guildID snowflake.ID, roleID snowflake.ID) (discord.Role, bool) RolesForEach(guildID snowflake.ID, fn func(role discord.Role)) RolesAllLen() int RolesLen(guildID snowflake.ID) int AddRole(role discord.Role) RemoveRole(guildID snowflake.ID, roleID snowflake.ID) (discord.Role, bool) RemoveRolesByGuildID(guildID snowflake.ID) }
func NewRoleCache ¶ added in v0.15.0
func NewRoleCache(cache GroupedCache[discord.Role]) RoleCache
type SelfUserCache ¶ added in v0.15.0
type SelfUserCache interface { SelfUser() (discord.OAuth2User, bool) SetSelfUser(selfUser discord.OAuth2User) }
func NewSelfUserCache ¶ added in v0.15.0
func NewSelfUserCache() SelfUserCache
type Set ¶ added in v0.16.6
type Set[T comparable] interface { // Add adds an item to the set. Add(item T) // Remove removes an item from the set. Remove(item T) // Has returns true if the item is in the set, false otherwise. Has(item T) bool // Len returns the number of items in the set. Len() int // Clear removes all items from the set. Clear() // ForEach iterates over the items in the set. ForEach(f func(item T)) }
Set is a collection of unique items. It should be thread-safe.
func NewSet ¶ added in v0.16.6
func NewSet[T comparable]() Set[T]
NewSet returns a thread-safe in memory implementation of a set.
type StageInstanceCache ¶ added in v0.15.0
type StageInstanceCache interface { StageInstance(guildID snowflake.ID, stageInstanceID snowflake.ID) (discord.StageInstance, bool) StageInstanceForEach(guildID snowflake.ID, fn func(stageInstance discord.StageInstance)) StageInstancesAllLen() int StageInstancesLen(guildID snowflake.ID) int AddStageInstance(stageInstance discord.StageInstance) RemoveStageInstance(guildID snowflake.ID, stageInstanceID snowflake.ID) (discord.StageInstance, bool) RemoveStageInstancesByGuildID(guildID snowflake.ID) }
func NewStageInstanceCache ¶ added in v0.15.0
func NewStageInstanceCache(cache GroupedCache[discord.StageInstance]) StageInstanceCache
type StickerCache ¶ added in v0.15.0
type StickerCache interface { Sticker(guildID snowflake.ID, stickerID snowflake.ID) (discord.Sticker, bool) StickersForEach(guildID snowflake.ID, fn func(sticker discord.Sticker)) StickersAllLen() int StickersLen(guildID snowflake.ID) int AddSticker(sticker discord.Sticker) RemoveSticker(guildID snowflake.ID, stickerID snowflake.ID) (discord.Sticker, bool) RemoveStickersByGuildID(guildID snowflake.ID) }
func NewStickerCache ¶ added in v0.15.0
func NewStickerCache(cache GroupedCache[discord.Sticker]) StickerCache
type ThreadMemberCache ¶ added in v0.15.0
type ThreadMemberCache interface { ThreadMember(threadID snowflake.ID, userID snowflake.ID) (discord.ThreadMember, bool) ThreadMemberForEach(threadID snowflake.ID, fn func(threadMember discord.ThreadMember)) ThreadMembersAllLen() int ThreadMembersLen(guildID snowflake.ID) int AddThreadMember(threadMember discord.ThreadMember) RemoveThreadMember(threadID snowflake.ID, userID snowflake.ID) (discord.ThreadMember, bool) RemoveThreadMembersByThreadID(threadID snowflake.ID) }
func NewThreadMemberCache ¶ added in v0.15.0
func NewThreadMemberCache(cache GroupedCache[discord.ThreadMember]) ThreadMemberCache
type VoiceStateCache ¶ added in v0.15.0
type VoiceStateCache interface { VoiceState(guildID snowflake.ID, userID snowflake.ID) (discord.VoiceState, bool) VoiceStatesForEach(guildID snowflake.ID, fn func(discord.VoiceState)) VoiceStatesAllLen() int VoiceStatesLen(guildID snowflake.ID) int AddVoiceState(voiceState discord.VoiceState) RemoveVoiceState(guildID snowflake.ID, userID snowflake.ID) (discord.VoiceState, bool) RemoveVoiceStatesByGuildID(guildID snowflake.ID) }
func NewVoiceStateCache ¶ added in v0.15.0
func NewVoiceStateCache(cache GroupedCache[discord.VoiceState]) VoiceStateCache