updated stuff
This commit is contained in:
26
internal/discord/api.go
Normal file
26
internal/discord/api.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package discord
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type OAuthSession struct {
|
||||
*discordgo.Session
|
||||
}
|
||||
|
||||
func NewOAuthSession(token *Token) (*OAuthSession, error) {
|
||||
session, err := discordgo.New("Bearer " + token.AccessToken)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "discordgo.New")
|
||||
}
|
||||
return &OAuthSession{Session: session}, nil
|
||||
}
|
||||
|
||||
func (s *OAuthSession) GetUser() (*discordgo.User, error) {
|
||||
user, err := s.User("@me")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "s.User")
|
||||
}
|
||||
return user, nil
|
||||
}
|
||||
Reference in New Issue
Block a user