From c56fae4243e2743ef25a4930c2229fd869d040a1 Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Fri, 22 Apr 2016 10:13:41 -0500 Subject: [PATCH] Added new example that displays user token --- examples/mytoken/mytoken.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/mytoken/mytoken.go diff --git a/examples/mytoken/mytoken.go b/examples/mytoken/mytoken.go new file mode 100644 index 0000000..a9a8404 --- /dev/null +++ b/examples/mytoken/mytoken.go @@ -0,0 +1,30 @@ +// This is an example of using DiscordGo to obtain the +// authentication token for a given user account. +package main + +import ( + "fmt" + "os" + + "github.com/bwmarrin/discordgo" +) + +func main() { + + // Check for Username and Password CLI arguments. + if len(os.Args) != 3 { + fmt.Println("You must provide username and password as arguments. See below example.") + fmt.Println(os.Args[0], " [email] [password]") + return + } + + // Create a New Discord session and login with the provided + // email and password. + dg, err := discordgo.New(os.Args[1], os.Args[2]) + if err != nil { + fmt.Println(err) + return + } + + fmt.Printf("Your Authentication Token is:\n\n%s\n", dg.Token) +}