Updates to example

This commit is contained in:
Bruce Marriner 2016-04-22 13:03:16 -05:00
parent eb36cad0ff
commit 68ebab258b

View file

@ -1,28 +1,30 @@
// This is an example of using DiscordGo to obtain the
// authentication token for a given user account.
package main package main
import ( import (
"flag"
"fmt" "fmt"
"os"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
) )
func main() { var (
Email string
Password string
)
// Check for Username and Password CLI arguments. func init() {
if len(os.Args) != 3 {
fmt.Println("You must provide username and password as arguments. See below example.") flag.StringVar(&Email, "e", "", "Account Email")
fmt.Println(os.Args[0], " [email] [password]") flag.StringVar(&Password, "p", "", "Account Password")
return flag.Parse()
} }
// Create a New Discord session and login with the provided func main() {
// email and password.
dg, err := discordgo.New(os.Args[1], os.Args[2]) // Create a new Discord session using the provided login information.
dg, err := discordgo.New(Email, Password)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println("error creating Discord session,", err)
return return
} }