Add generic Channel method which is slower.

This commit is contained in:
Chris Rhodes 2016-01-02 12:32:18 -08:00
parent 9ba6d5b7c1
commit 14c18b2286

View file

@ -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.")
}