Rearanged a bit more.
This commit is contained in:
parent
09728d6ffe
commit
37e3e53527
1 changed files with 19 additions and 17 deletions
36
session.go
36
session.go
|
@ -115,23 +115,7 @@ func Request(session *Session, urlStr string) (body []byte, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *Session) Servers() (servers []Server, err error) {
|
// Get all of the session user's private channels.
|
||||||
|
|
||||||
body, err := Request(session, fmt.Sprintf("%s/%s", discordApi, fmt.Sprintf("users/@me/guilds")))
|
|
||||||
//body, err := Request(session, fmt.Sprintf("%s/%s", discordApi, fmt.Sprintf("users/%s/guilds", session.Id)))
|
|
||||||
err = json.Unmarshal(body, &servers)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (session *Session) Channels(serverId int) (channels []Channel, err error) {
|
|
||||||
|
|
||||||
body, err := Request(session, fmt.Sprintf("%s/%s", discordApi, fmt.Sprintf("guilds/%d/channels", serverId)))
|
|
||||||
err = json.Unmarshal(body, &channels)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (session *Session) PrivateChannels() (channels []Channel, err error) {
|
func (session *Session) PrivateChannels() (channels []Channel, err error) {
|
||||||
|
|
||||||
body, err := Request(session, fmt.Sprintf("%s/%s", discordApi, fmt.Sprintf("users/@me/channels")))
|
body, err := Request(session, fmt.Sprintf("%s/%s", discordApi, fmt.Sprintf("users/@me/channels")))
|
||||||
|
@ -139,3 +123,21 @@ func (session *Session) PrivateChannels() (channels []Channel, err error) {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get all of the session user's servers
|
||||||
|
func (session *Session) Servers() (servers []Server, err error) {
|
||||||
|
|
||||||
|
body, err := Request(session, fmt.Sprintf("%s/%s", discordApi, fmt.Sprintf("users/@me/guilds")))
|
||||||
|
err = json.Unmarshal(body, &servers)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all channels for the given server
|
||||||
|
func (session *Session) Channels(serverId int) (channels []Channel, err error) {
|
||||||
|
|
||||||
|
body, err := Request(session, fmt.Sprintf("%s/%s", discordApi, fmt.Sprintf("guilds/%d/channels", serverId)))
|
||||||
|
err = json.Unmarshal(body, &channels)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue