State: Added VoiceStates
This commit is contained in:
parent
05d49527f8
commit
d4d8172d26
|
@ -11,6 +11,11 @@ before_script:
|
|||
stages:
|
||||
- test
|
||||
|
||||
build_test:
|
||||
stage: test
|
||||
script:
|
||||
- go build ./...
|
||||
|
||||
unit_test:
|
||||
stage: test
|
||||
script:
|
||||
|
|
|
@ -492,10 +492,6 @@ func (s *State) Presence(guildID, userID discord.Snowflake) (*discord.Presence,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
func (s *State) Presences(guildID discord.Snowflake) ([]discord.Presence, error) {
|
||||
return s.Store.Presences(guildID)
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
func (s *State) Role(guildID, roleID discord.Snowflake) (*discord.Role, error) {
|
||||
|
|
|
@ -53,6 +53,7 @@ type StoreGetter interface {
|
|||
Roles(guildID discord.Snowflake) ([]discord.Role, error)
|
||||
|
||||
VoiceState(guildID discord.Snowflake, userID discord.Snowflake) (*discord.VoiceState, error)
|
||||
VoiceStates(guildID discord.Snowflake) ([]discord.VoiceState, error)
|
||||
}
|
||||
|
||||
type StoreModifier interface {
|
||||
|
|
|
@ -18,10 +18,10 @@ type DefaultStore struct {
|
|||
privates map[discord.Snowflake]*discord.Channel // channelID:channel
|
||||
guilds map[discord.Snowflake]*discord.Guild // guildID:guild
|
||||
|
||||
channels map[discord.Snowflake][]discord.Channel // guildID:channels
|
||||
members map[discord.Snowflake][]discord.Member // guildID:members
|
||||
presences map[discord.Snowflake][]discord.Presence // guildID:presences
|
||||
messages map[discord.Snowflake][]discord.Message // channelID:messages
|
||||
channels map[discord.Snowflake][]discord.Channel // guildID:channels
|
||||
members map[discord.Snowflake][]discord.Member // guildID:members
|
||||
presences map[discord.Snowflake][]discord.Presence // guildID:presences
|
||||
messages map[discord.Snowflake][]discord.Message // channelID:messages
|
||||
voiceStates map[discord.Snowflake][]discord.VoiceState // guildID:voiceStates
|
||||
|
||||
mut sync.Mutex
|
||||
|
@ -686,6 +686,18 @@ func (s *DefaultStore) VoiceState(guildID, userID discord.Snowflake) (*discord.V
|
|||
return nil, ErrStoreNotFound
|
||||
}
|
||||
|
||||
func (s *DefaultStore) VoiceStates(guildID discord.Snowflake) ([]discord.VoiceState, error) {
|
||||
s.mut.Lock()
|
||||
defer s.mut.Unlock()
|
||||
|
||||
states, ok := s.voiceStates[guildID]
|
||||
if !ok {
|
||||
return nil, ErrStoreNotFound
|
||||
}
|
||||
|
||||
return append([]discord.VoiceState{}, states...), nil
|
||||
}
|
||||
|
||||
func (s *DefaultStore) VoiceStateSet(guildID discord.Snowflake, voiceState *discord.VoiceState) error {
|
||||
s.mut.Lock()
|
||||
defer s.mut.Unlock()
|
||||
|
|
|
@ -153,6 +153,10 @@ func (NoopStore) VoiceState(_, _ discord.Snowflake) (*discord.VoiceState, error)
|
|||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (NoopStore) VoiceStates(_ discord.Snowflake) ([]discord.VoiceState, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (NoopStore) VoiceStateSet(discord.Snowflake, *discord.VoiceState) error {
|
||||
return ErrNotImplemented
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue