From 1cc1d4c9bbe5b85751daf554e69c8cc370cdd069 Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Mon, 14 Mar 2016 09:16:04 -0500 Subject: [PATCH] Add examples for creating bot account --- oauth2_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/oauth2_test.go b/oauth2_test.go index 4d2899a..394cdbf 100644 --- a/oauth2_test.go +++ b/oauth2_test.go @@ -38,6 +38,10 @@ func ExampleApplication() { ap, err = dg.ApplicationUpdate(ap.ID, ap) fmt.Printf("ApplicationUpdate: err: %+v, app: %+v\n", err, ap) + // create a new bot account for this application + bot, err := dg.ApplicationBotCreate(ap.ID, "") + fmt.Printf("BotCreate: err: %+v, bot: %+v\n", err, bot) + // Get a list of all applications for the authenticated user apps, err := dg.Applications() fmt.Printf("Applications: err: %+v, apps : %+v\n", err, apps) @@ -51,3 +55,33 @@ func ExampleApplication() { return } + +// This provides an example on converting an existing normal user account +// into a bot account. You must authentication to Discord using your personal +// username and password then provide the authentication token of the account +// you want converted. +func ExampleApplicationConvertBot() { + + dg, err := discordgo.New("myemail", "mypassword") + if err != nil { + fmt.Println(err) + return + } + + // create an application + ap := &discordgo.Application{} + ap.Name = "Application Name" + ap.Description = "Application Description" + ap, err = dg.ApplicationCreate(ap) + fmt.Printf("ApplicationCreate: err: %+v, app: %+v\n", err, ap) + + // create a bot account + bot, err := dg.ApplicationBotCreate(ap.ID, "existing bot user account token") + fmt.Printf("BotCreate: err: %+v, bot: %+v\n", err, bot) + + if err != nil { + fmt.Printf("You can not login with your converted bot user using the below token\n%s\n", bot.Token) + } + + return +}