mytoken.go 668 B

123456789101112131415161718192021222324252627282930
  1. // This is an example of using DiscordGo to obtain the
  2. // authentication token for a given user account.
  3. package main
  4. import (
  5. "fmt"
  6. "os"
  7. "github.com/bwmarrin/discordgo"
  8. )
  9. func main() {
  10. // Check for Username and Password CLI arguments.
  11. if len(os.Args) != 3 {
  12. fmt.Println("You must provide username and password as arguments. See below example.")
  13. fmt.Println(os.Args[0], " [email] [password]")
  14. return
  15. }
  16. // Create a New Discord session and login with the provided
  17. // email and password.
  18. dg, err := discordgo.New(os.Args[1], os.Args[2])
  19. if err != nil {
  20. fmt.Println(err)
  21. return
  22. }
  23. fmt.Printf("Your Authentication Token is:\n\n%s\n", dg.Token)
  24. }