Updates to example
This commit is contained in:
parent
eb36cad0ff
commit
68ebab258b
1 changed files with 16 additions and 14 deletions
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Email string
|
||||||
|
Password string
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
|
||||||
|
flag.StringVar(&Email, "e", "", "Account Email")
|
||||||
|
flag.StringVar(&Password, "p", "", "Account Password")
|
||||||
|
flag.Parse()
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// Check for Username and Password CLI arguments.
|
// Create a new Discord session using the provided login information.
|
||||||
if len(os.Args) != 3 {
|
dg, err := discordgo.New(Email, Password)
|
||||||
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 {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println("error creating Discord session,", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue