forked from pothtonswer/discordmuffin
Add examples for creating bot account
This commit is contained in:
parent
50cc4df965
commit
1cc1d4c9bb
1 changed files with 34 additions and 0 deletions
|
@ -38,6 +38,10 @@ func ExampleApplication() {
|
||||||
ap, err = dg.ApplicationUpdate(ap.ID, ap)
|
ap, err = dg.ApplicationUpdate(ap.ID, ap)
|
||||||
fmt.Printf("ApplicationUpdate: err: %+v, app: %+v\n", err, 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
|
// Get a list of all applications for the authenticated user
|
||||||
apps, err := dg.Applications()
|
apps, err := dg.Applications()
|
||||||
fmt.Printf("Applications: err: %+v, apps : %+v\n", err, apps)
|
fmt.Printf("Applications: err: %+v, apps : %+v\n", err, apps)
|
||||||
|
@ -51,3 +55,33 @@ func ExampleApplication() {
|
||||||
|
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue