From c721f61059ddc18563394a7ce13a294bd161ac2a Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Fri, 13 Nov 2015 22:19:45 -0600 Subject: [PATCH] Removing demo, replacing it with new. --- examples/restapi.go | 75 --------------------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 examples/restapi.go diff --git a/examples/restapi.go b/examples/restapi.go deleted file mode 100644 index 0d8a5d0..0000000 --- a/examples/restapi.go +++ /dev/null @@ -1,75 +0,0 @@ -/****************************************************************************** - * Discordgo demo program. - * - * Please run this with command line arguments of email and password. - */ -package main - -import ( - "fmt" - "os" - - discord "github.com/bwmarrin/discordgo" -) - -func main() { - - var err error - var email string = os.Args[1] - var password string = os.Args[2] - - // Create new session object and enable debugging. - session := discord.Session{Debug: true} - - // Login to the Discord server with the provided email and password - // from the command line arguments - session.Token, err = session.Login(email, password) - if err != nil { - fmt.Println("Unable to login to Discord.") - fmt.Println(err) - return - } - - // Example using Request function to query a specific URL - // This pulls authenticated user's information. - // Request returns the actual request body not JSON - body, err := discord.Request(&session, "http://discordapp.com/api/users/@me") - fmt.Println(body) - - // Use the User function to do the same as above. This function - // returns a User structure - user, err := discord.Users(&session, "@me") - fmt.Println(user) - - // Use the PrivateChannels function to get a list of PrivateChannels - // for a given user. - private, err := discord.PrivateChannels(&session, "@me") - fmt.Println(private) - - // Use the Servers function to pull all available servers for a given user - // This returns a Server structure - servers, err := discord.Servers(&session, "@me") - fmt.Println(servers) - - // Use the Members function to pull all members of a given server. - members, err := discord.Members(&session, servers[0].Id) - fmt.Println(members) - - // Use the Channels function to pull all available channels for a given - // server. This returns a Channel structure. - channels, err := discord.Channels(&session, servers[0].Id) - fmt.Println(channels) - - // Use the Messages function to pull messages from the given channel - // limit the result to 2 messages and don't provide beforeId or afterId - messages, err := discord.Messages(&session, channels[0].Id, 2, 0, 0) - fmt.Println(messages) - - // Use SendMessage to send a message to the given channel. - responce, err := discord.SendMessage(&session, channels[0].Id, "Testing Discordgo") - fmt.Println(responce) - - // Use the Logout function to Logout from the Discord server. - discord.Logout(&session) - return -}