Documentation ¶
Overview ¶
Package discord partially implements Discord's HTTP API to streamline the OAuth2 flow for consumers.
Index ¶
- Constants
- Variables
- type Discord
- func (d *Discord) AuthCodeURL(state string) string
- func (d *Discord) Exchange(ctx context.Context, code string) (*oauth2.Token, error)
- func (d *Discord) GuildsFromToken(ctx context.Context, token string) ([]*Guild, error)
- func (d *Discord) UserFromToken(ctx context.Context, token string) (*User, error)
- type Error
- type Guild
- type Option
- type User
Constants ¶
View Source
const (
Version = "v0.1.0"
)
Variables ¶
View Source
var ( // Endpoint is Discord's API endpoint for OAuth2. Endpoint = oauth2.Endpoint{ AuthURL: "https://discord.com/api/oauth2/authorize", TokenURL: "https://discord.com/api/oauth2/token", } // ErrMissingRequiredArgument is returned when a required argument is missing ErrMissingRequiredArgument = errors.New("discord: missing a required argument") )
Functions ¶
This section is empty.
Types ¶
type Discord ¶
type Discord struct {
// contains filtered or unexported fields
}
Discord is an API client.
func (*Discord) AuthCodeURL ¶
AuthCodeURL returns a URL to authenticate a user with.
func (*Discord) GuildsFromToken ¶ added in v0.3.0
GuildsFromToken fetches the list of Guilds a Discord user belongs to. Requires the `guilds` OAuth2 scope.
type Error ¶
type Error struct { HTTPStatus int `json:"-"` Code int `json:"code"` Message string `json:"message"` }
Error is an error returned from the Discord API. It implements the Error interface.
type Guild ¶ added in v0.3.0
type Guild struct { ID string `json:"id"` Name string `json:"name"` IconHash string `json:"icon"` Owner bool `json:"owner"` Permissions string `json:"permissions"` Features []string `json:"features"` }
Guild is a partial guild that the authenticated user belongs to.
type Option ¶
type Option func(*Discord)
Option configures a Discord.
func WithHTTPClient ¶
WithHTTPClient specifies the *http.Client to use.
func WithOAuth2Config ¶
WithOAuth2Config specifies the *oauth2.Config to use.
type User ¶
type User struct { ID string `json:"id"` Username string `json:"username"` Discriminator string `json:"discriminator"` AvatarHash string `json:"avatar"` Bot bool `json:"bot,omitempty"` System bool `json:"system,omitempty"` MFAEnabled bool `json:"mfa_enabled,omitempty"` Locale string `json:"locale,omitempty"` Flags int `json:"flags,omitempty"` PremiumType int `json:"premium_type,omitempty"` PublicFlags int `json:"public_flags,omitempty"` }
User is a partial definition of a Discord User defined by the API.
Click to show internal directories.
Click to hide internal directories.