From 37e3e53527f8400991376e51d37d6127aa1727bb Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Mon, 2 Nov 2015 18:53:12 -0600 Subject: [PATCH] Rearanged a bit more. --- session.go | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/session.go b/session.go index c3eae3c..6ceeb9b 100644 --- a/session.go +++ b/session.go @@ -115,23 +115,7 @@ func Request(session *Session, urlStr string) (body []byte, err error) { return } -func (session *Session) Servers() (servers []Server, err error) { - - 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 -} - +// Get all of the session user's private channels. func (session *Session) PrivateChannels() (channels []Channel, err error) { 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 } + +// 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 +}