discord

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCodeGeneral      APIErrorCode = 0
	ErrorCodeUnknownGuild APIErrorCode = 10004

	PremiumTypeNone         PremiumTypes = 0
	PremiumTypeNitroClassic PremiumTypes = 1
	PremiumTypeNitro        PremiumTypes = 2
	PremiumTypeNitroBasic   PremiumTypes = 3

	UserFlagStaff                 UserFlags = 1 << 0
	UserFlagPartner               UserFlags = 1 << 1
	UserFlagHypesquad             UserFlags = 1 << 2
	UserFlagBugHunterLevel1       UserFlags = 1 << 3
	UserFlagHypesquadOnlineHouse1 UserFlags = 1 << 6
	UserFlagHypesquadOnlineHouse2 UserFlags = 1 << 7
	UserFlagHypesquadOnlineHouse3 UserFlags = 1 << 8
	UserFlagPremiumEarlySupporter UserFlags = 1 << 9
	UserFlagTeamPseudoUser        UserFlags = 1 << 10
	UserFlagBugHunterLevel2       UserFlags = 1 << 14
	UserFlagVerifiedBot           UserFlags = 1 << 16
	UserFlagVerifiedDeveloper     UserFlags = 1 << 17
	UserFlagCertifiedModerator    UserFlags = 1 << 18
	UserFlagBotHttpInteractions   UserFlags = 1 << 19
	UserFlagActiveDeveloper       UserFlags = 1 << 22
)

Variables

View Source
var (
	ErrDiscordGeneric = errors.New("discord response indicated failed")
	ErrUnknownGuild   = errors.New("user does not exist within guild")

	//ErrBadRequest        = errors.New("failed")
	ErrRateLimited       = errors.New("request has failed due to exceeding Discord rate limits")
	ErrInsufficientScope = errors.New("request failed due to lack of permission")
	ErrTokenExpired      = errors.New("discord authorization failed")
)

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	// contains filtered or unexported fields
}

func NewClientWrapper

func NewClientWrapper(client *http.Client) *APIClient

func (*APIClient) FetchCurrentUser

func (d *APIClient) FetchCurrentUser() (*User, error)

func (*APIClient) FetchGuildMembership

func (d *APIClient) FetchGuildMembership(guildID string) (*GuildMemberResponse, error)

type ErrJSONError

type ErrJSONError struct {
	// contains filtered or unexported fields
}

func NewErrorDiscordResponse

func NewErrorDiscordResponse(message string, code APIErrorCode) *ErrJSONError

func (*ErrJSONError) Error

func (e *ErrJSONError) Error() string

type ErrorResponse

type ErrorResponse struct {
	Message string       `json:"message"`
	Code    APIErrorCode `json:"code"`
}

type GuildMemberResponse

type GuildMemberResponse struct {
	User                       User        `json:"user"`
	Nick                       string      `json:"nick"`
	Avatar                     interface{} `json:"avatar"`
	Roles                      []string    `json:"roles"`
	JoinedAt                   time.Time   `json:"joined_at"`
	PremiumSince               *time.Time  `json:"premiumSince"`
	Deaf                       bool        `json:"deaf"`
	Mute                       bool        `json:"mute"`
	Pending                    *bool       `json:"pending"`
	Permissions                *string     `json:"permissions"`
	CommunicationDisabledUntil *time.Time  `json:"communication_disabled_until"`
}

type User

type User struct {
	ID               string        `json:"id"`
	Username         string        `json:"username"`
	Discriminator    string        `json:"discriminator"`
	Avatar           string        `json:"avatar"`
	AvatarDecoration string        `json:"avatar_decoration"`
	Verified         *bool         `json:"verified"`
	Email            *string       `json:"email"`
	Flags            *UserFlags    `json:"flags"`
	Bot              *bool         `json:"bot"`
	System           *bool         `json:"system"`
	Banner           *string       `json:"banner"`
	MFAEnabled       *bool         `json:"mfa_enabled"`
	Locale           *string       `json:"locale"`
	AccentColor      *int          `json:"accent_color"`
	PremiumType      *PremiumTypes `json:"premium_type"`
	PublicFlags      *UserFlags    `json:"public_flags"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL