123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- package discordgo
- type Application struct {
- ID string `json:"id,omitempty"`
- Name string `json:"name"`
- Description string `json:"description,omitempty"`
- Icon string `json:"icon,omitempty"`
- Secret string `json:"secret,omitempty"`
- RedirectURIs *[]string `json:"redirect_uris,omitempty"`
- Owner *User `json:"owner"`
- }
- func (s *Session) Application(appID string) (st *Application, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointApplication(appID), nil, EndpointApplication(""))
- if err != nil {
- return
- }
- err = unmarshal(body, &st)
- return
- }
- func (s *Session) Applications() (st []*Application, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointApplications, nil, EndpointApplications)
- if err != nil {
- return
- }
- err = unmarshal(body, &st)
- return
- }
- func (s *Session) ApplicationCreate(ap *Application) (st *Application, err error) {
- data := struct {
- Name string `json:"name"`
- Description string `json:"description"`
- RedirectURIs *[]string `json:"redirect_uris,omitempty"`
- }{ap.Name, ap.Description, ap.RedirectURIs}
- body, err := s.RequestWithBucketID("POST", EndpointApplications, data, EndpointApplications)
- if err != nil {
- return
- }
- err = unmarshal(body, &st)
- return
- }
- func (s *Session) ApplicationUpdate(appID string, ap *Application) (st *Application, err error) {
- data := struct {
- Name string `json:"name"`
- Description string `json:"description"`
- RedirectURIs *[]string `json:"redirect_uris,omitempty"`
- }{ap.Name, ap.Description, ap.RedirectURIs}
- body, err := s.RequestWithBucketID("PUT", EndpointApplication(appID), data, EndpointApplication(""))
- if err != nil {
- return
- }
- err = unmarshal(body, &st)
- return
- }
- func (s *Session) ApplicationDelete(appID string) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointApplication(appID), nil, EndpointApplication(""))
- if err != nil {
- return
- }
- return
- }
- func (s *Session) ApplicationBotCreate(appID string) (st *User, err error) {
- body, err := s.RequestWithBucketID("POST", EndpointApplicationsBot(appID), nil, EndpointApplicationsBot(""))
- if err != nil {
- return
- }
- err = unmarshal(body, &st)
- return
- }
|