Added ApplicationBotCreate function
This commit is contained in:
parent
f4f68879ab
commit
24be2cda0b
2 changed files with 36 additions and 4 deletions
|
@ -86,7 +86,8 @@ var (
|
||||||
|
|
||||||
EMOJI = func(eID string) string { return API + "emojis/" + eID + ".png" }
|
EMOJI = func(eID string) string { return API + "emojis/" + eID + ".png" }
|
||||||
|
|
||||||
OAUTH2 = API + "oauth2/"
|
OAUTH2 = API + "oauth2/"
|
||||||
APPLICATIONS = OAUTH2 + "applications"
|
APPLICATIONS = OAUTH2 + "applications"
|
||||||
APPLICATION = func(aID string) string { return APPLICATIONS + "/" + aID }
|
APPLICATION = func(aID string) string { return APPLICATIONS + "/" + aID }
|
||||||
|
APPLICATIONS_BOT = func(aID string) string { return APPLICATIONS + "/" + aID + "/bot" }
|
||||||
)
|
)
|
||||||
|
|
33
oauth2.go
33
oauth2.go
|
@ -5,7 +5,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// This file contains functions related to Discord OAuth2 applications
|
// This file contains functions related to Discord OAuth2 endpoints
|
||||||
|
|
||||||
package discordgo
|
package discordgo
|
||||||
|
|
||||||
|
@ -13,6 +13,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Code specific to Discord OAuth2 Applications
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// An Application struct stores values for a Discord OAuth2 Application
|
// An Application struct stores values for a Discord OAuth2 Application
|
||||||
type Application struct {
|
type Application struct {
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
|
@ -132,3 +136,30 @@ func (a *Application) Delete() (err error) {
|
||||||
func (a *Application) DeleteB(s *Session) (err error) {
|
func (a *Application) DeleteB(s *Session) (err error) {
|
||||||
return s.ApplicationDelete(a.ID)
|
return s.ApplicationDelete(a.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Code specific to Discord OAuth2 Application Bots
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// ApplicationBotCreate creates an Application Bot Account
|
||||||
|
//
|
||||||
|
// appID : The ID of an Application
|
||||||
|
// token : The authentication Token for a user account to convert into
|
||||||
|
// a bot account. This is optional, if omited a new account
|
||||||
|
// is created using the name of the application.
|
||||||
|
//
|
||||||
|
// NOTE: func name may change, if I can think up something better.
|
||||||
|
func (s *Session) ApplicationBotCreate(appID, token string) (st *User, err error) {
|
||||||
|
|
||||||
|
data := struct {
|
||||||
|
Token string `json:"token,omitempty"`
|
||||||
|
}{token}
|
||||||
|
|
||||||
|
body, err := s.Request("POST", APPLICATIONS_BOT(appID), data)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = unmarshal(body, &st)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue