Add generic Channel method which is slower.
This commit is contained in:
parent
9ba6d5b7c1
commit
14c18b2286
1 changed files with 21 additions and 0 deletions
21
state.go
21
state.go
|
@ -245,3 +245,24 @@ func (s *State) PrivateChannel(channelID string) (*Channel, error) {
|
|||
|
||||
return nil, errors.New("Channel not found.")
|
||||
}
|
||||
|
||||
// Channel gets a channel by ID, it will look in all guilds an private channels.
|
||||
func (s *State) Channel(channelID string) (*Channel, error) {
|
||||
if s == nil {
|
||||
return nil, nilError
|
||||
}
|
||||
|
||||
c, err := s.PrivateChannel(channelID)
|
||||
if err == nil {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
for _, g := range s.Guilds {
|
||||
c, err := s.GuildChannel(g.ID, channelID)
|
||||
if err == nil {
|
||||
return c, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, errors.New("Channel not found.")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue