Documentation ¶
Index ¶
- Constants
- type ActiveThreadsResponse
- type ApplicationClient
- type AuthorizedUser
- func (authedUser *AuthorizedUser) FetchGuilds() ([]discord.Guild, error)
- func (authedUser *AuthorizedUser) FetchUser() (*discord.User, error)
- func (authedUser *AuthorizedUser) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
- func (authedUser *AuthorizedUser) RefreshTokens() error
- func (authedUser *AuthorizedUser) RevokeTokens() error
- type BotClient
- func (botClient *BotClient) GetApplicationClient(appId discord.Snowflake) *ApplicationClient
- func (botClient *BotClient) GetChannelClient(channelId discord.Snowflake) *ChannelClient
- func (botClient *BotClient) GetGuildClient(guildId discord.Snowflake) *GuildClient
- func (botClient *BotClient) GetSelfUserClient() *UserClient
- func (botClient *BotClient) GetSelfUserID() discord.Snowflake
- func (botClient *BotClient) GetUserClient(userId discord.Snowflake) *UserClient
- func (botClient *BotClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
- type ChannelClient
- func (channelClient *ChannelClient) AddThreadMember(userId discord.Snowflake) error
- func (channelClient *ChannelClient) CreateThread(threadData CreateThreadData) (*discord.Channel, error)
- func (channelClient *ChannelClient) Edit(data ModifyChannelData) (*discord.Channel, error)
- func (channelClient *ChannelClient) EditMessage(messageId discord.Snowflake, editData discord.ResponseEditData) (*discord.Message, error)
- func (channelClient *ChannelClient) FetchChannel() (*discord.Channel, error)
- func (channelClient *ChannelClient) GetThreadMember(request GetThreadMemberRequest) (*discord.ThreadMember, error)
- func (channelClient *ChannelClient) JoinThread() error
- func (channelClient *ChannelClient) LeaveThread() error
- func (channelClient *ChannelClient) ListThreadMembers(request ListThreadMemberRequest) ([]discord.ThreadMember, error)
- func (channelClient *ChannelClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
- func (channelClient *ChannelClient) RemoveThreadMember(userId discord.Snowflake) error
- func (channelClient *ChannelClient) SendMessage(messageData SendMessageData) (*discord.Message, error)
- type CreateApplicationCommand
- type CreateThreadData
- type DiscordRequest
- type GetThreadMemberRequest
- type GuildClient
- func (guildClient *GuildClient) FetchGuild(withCounts bool) (*discord.Guild, error)
- func (guildClient *GuildClient) GetActiveThreads() (ActiveThreadsResponse, error)
- func (guildClient *GuildClient) GetChannels() ([]discord.Channel, error)
- func (guildClient *GuildClient) GetMemberClient(memberId discord.Snowflake) *MemberClient
- func (guildClient *GuildClient) JoinUserToGuild(authedUser *AuthorizedUser, userId discord.Snowflake, ...) (err error)
- func (guildClient *GuildClient) ListMembers(request ListMembersRequest) ([]discord.Member, error)
- func (guildClient *GuildClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
- type JoinUserToGuildRequest
- type ListMembersRequest
- type ListThreadMemberRequest
- type MemberClient
- type ModifyChannelData
- type ModifyGroupDMChannelData
- type ModifyGuildChannelData
- type ModifyMemberRoleOpts
- type ModifyThreadData
- type OAuthClient
- func (oauthClient *OAuthClient) AuthorizeUserFromCode(code string) (*AuthorizedUser, error)
- func (oauthClient *OAuthClient) BuildAuthorizationURL(scopes []oauth_scopes.OAuthScope, state string) string
- func (oauthClient *OAuthClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
- func (oauthClient *OAuthClient) RefreshTokensForUser(refreshToken string) (tokenResponse *TokenResponse, err error)
- func (oauthClient *OAuthClient) RevokeTokensForUser(accessToken string) (err error)
- type RevokeTokenRequest
- type SendMessageData
- type ThreadType
- type TokenGrantType
- type TokenRequest
- type TokenResponse
- type UserClient
- func (userClient *UserClient) CreateDMChannel() (*discord.Channel, error)
- func (userClient *UserClient) GetIdAsString() string
- func (userClient *UserClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
- func (userClient *UserClient) SendMessage(messageData SendMessageData) (*discord.Message, error)
Constants ¶
View Source
const (
DiscordApiURL = "https://discord.com/api/v10"
)
View Source
const DiscordAuthorizationUrl = "https://discordapp.com/api/oauth2/authorize"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActiveThreadsResponse ¶
type ActiveThreadsResponse struct { Threads []discord.Channel `json:"threads"` ThreadMembers []discord.ThreadMember `json:"members"` }
type ApplicationClient ¶ added in v1.1.0
func (*ApplicationClient) MakeRequest ¶ added in v1.1.0
func (appClient *ApplicationClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
func (*ApplicationClient) RegisterCommand ¶ added in v1.1.0
func (appClient *ApplicationClient) RegisterCommand(cmds CreateApplicationCommand) error
func (*ApplicationClient) RegisterCommands ¶ added in v1.1.0
func (appClient *ApplicationClient) RegisterCommands(cmds []CreateApplicationCommand) error
type AuthorizedUser ¶
type AuthorizedUser struct { RefreshToken string AccessToken string ExpiresIn int Scopes []oauth_scopes.OAuthScope Client *http.Client OAuthClient *OAuthClient }
func NewAuthorizedUser ¶
func NewAuthorizedUser(oauthClient *OAuthClient, refreshToken string, accessToken string, expiresIn int, scopes []oauth_scopes.OAuthScope) *AuthorizedUser
func (*AuthorizedUser) FetchGuilds ¶
func (authedUser *AuthorizedUser) FetchGuilds() ([]discord.Guild, error)
func (*AuthorizedUser) FetchUser ¶
func (authedUser *AuthorizedUser) FetchUser() (*discord.User, error)
func (*AuthorizedUser) MakeRequest ¶
func (authedUser *AuthorizedUser) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
func (*AuthorizedUser) RefreshTokens ¶
func (authedUser *AuthorizedUser) RefreshTokens() error
func (*AuthorizedUser) RevokeTokens ¶
func (authedUser *AuthorizedUser) RevokeTokens() error
type BotClient ¶
func (*BotClient) GetApplicationClient ¶ added in v1.1.0
func (botClient *BotClient) GetApplicationClient(appId discord.Snowflake) *ApplicationClient
func (*BotClient) GetChannelClient ¶
func (botClient *BotClient) GetChannelClient(channelId discord.Snowflake) *ChannelClient
func (*BotClient) GetGuildClient ¶
func (botClient *BotClient) GetGuildClient(guildId discord.Snowflake) *GuildClient
func (*BotClient) GetSelfUserClient ¶
func (botClient *BotClient) GetSelfUserClient() *UserClient
func (*BotClient) GetSelfUserID ¶
func (*BotClient) GetUserClient ¶
func (botClient *BotClient) GetUserClient(userId discord.Snowflake) *UserClient
func (*BotClient) MakeRequest ¶
func (botClient *BotClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
type ChannelClient ¶
func (*ChannelClient) AddThreadMember ¶
func (channelClient *ChannelClient) AddThreadMember(userId discord.Snowflake) error
func (*ChannelClient) CreateThread ¶
func (channelClient *ChannelClient) CreateThread(threadData CreateThreadData) (*discord.Channel, error)
func (*ChannelClient) Edit ¶
func (channelClient *ChannelClient) Edit(data ModifyChannelData) (*discord.Channel, error)
func (*ChannelClient) EditMessage ¶
func (channelClient *ChannelClient) EditMessage(messageId discord.Snowflake, editData discord.ResponseEditData) (*discord.Message, error)
func (*ChannelClient) FetchChannel ¶
func (channelClient *ChannelClient) FetchChannel() (*discord.Channel, error)
func (*ChannelClient) GetThreadMember ¶
func (channelClient *ChannelClient) GetThreadMember(request GetThreadMemberRequest) (*discord.ThreadMember, error)
func (*ChannelClient) JoinThread ¶
func (channelClient *ChannelClient) JoinThread() error
func (*ChannelClient) LeaveThread ¶
func (channelClient *ChannelClient) LeaveThread() error
func (*ChannelClient) ListThreadMembers ¶
func (channelClient *ChannelClient) ListThreadMembers(request ListThreadMemberRequest) ([]discord.ThreadMember, error)
func (*ChannelClient) MakeRequest ¶
func (channelClient *ChannelClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
func (*ChannelClient) RemoveThreadMember ¶
func (channelClient *ChannelClient) RemoveThreadMember(userId discord.Snowflake) error
func (*ChannelClient) SendMessage ¶
func (channelClient *ChannelClient) SendMessage(messageData SendMessageData) (*discord.Message, error)
type CreateApplicationCommand ¶ added in v1.1.0
type CreateApplicationCommand struct { Name string `json:"name"` NameLocalizations map[string]string `json:"name_localizations,omitempty"` Description *string `json:"description,omitempty"` DescriptionLocalizations map[string]string `json:"description_localizations,omitempty"` Options []discord.ApplicationCommandOption `json:"options,omitempty"` DefaultMemberPermissions *string `json:"default_member_permissions,omitempty"` DMPermission *bool `json:"dm_permission,omitempty"` DefaultPermission *bool `json:"default_permission,omitempty"` IntegrationTypes []string `json:"integration_types,omitempty"` Contexts []string `json:"contexts,omitempty"` Type *int `json:"type,omitempty"` NSFW *bool `json:"nsfw,omitempty"` }
type CreateThreadData ¶
type CreateThreadData struct { Name string `json:"name"` // Seconds AutoArchiveDuration *int `json:"auto_archive_duration,omitempty"` // Valid types: AnnouncementThread, PublicThread, PrivateThread Type channel_type.ChannelType `json:"type"` // Whether non-mods can invite (only if private thread) Invitable *bool `json:"invitable,omitempty"` // Seconds RateLimit *int `json:"rate_limit_per_user,omitempty"` Reason *string `json:"-"` // Audit log reason, optional }
type DiscordRequest ¶
type DiscordRequest struct { ExpectedStatus int Method string Endpoint string Body []byte UnmarshalTo interface{} DisableAuth bool DisableStatusCheck bool AdditionalHeaders map[string]string }
func (*DiscordRequest) GetUrl ¶
func (discordRequest *DiscordRequest) GetUrl() string
func (*DiscordRequest) ValidateEndpoint ¶
func (discordRequest *DiscordRequest) ValidateEndpoint()
type GetThreadMemberRequest ¶
type GuildClient ¶
func (*GuildClient) FetchGuild ¶
func (guildClient *GuildClient) FetchGuild(withCounts bool) (*discord.Guild, error)
func (*GuildClient) GetActiveThreads ¶
func (guildClient *GuildClient) GetActiveThreads() (ActiveThreadsResponse, error)
func (*GuildClient) GetChannels ¶
func (guildClient *GuildClient) GetChannels() ([]discord.Channel, error)
func (*GuildClient) GetMemberClient ¶
func (guildClient *GuildClient) GetMemberClient(memberId discord.Snowflake) *MemberClient
func (*GuildClient) JoinUserToGuild ¶
func (guildClient *GuildClient) JoinUserToGuild(authedUser *AuthorizedUser, userId discord.Snowflake, guildId discord.Snowflake) (err error)
func (*GuildClient) ListMembers ¶
func (guildClient *GuildClient) ListMembers(request ListMembersRequest) ([]discord.Member, error)
func (*GuildClient) MakeRequest ¶
func (guildClient *GuildClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
type JoinUserToGuildRequest ¶
type ListMembersRequest ¶
type ListThreadMemberRequest ¶
type MemberClient ¶
type MemberClient struct { MemberId discord.Snowflake GuildClient *GuildClient }
func (*MemberClient) AddRoleToMember ¶
func (memberClient *MemberClient) AddRoleToMember(opts ModifyMemberRoleOpts) error
func (*MemberClient) FetchMember ¶
func (memberClient *MemberClient) FetchMember() (*discord.Member, error)
func (*MemberClient) MakeRequest ¶
func (memberClient *MemberClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
type ModifyChannelData ¶
type ModifyGroupDMChannelData ¶
type ModifyGroupDMChannelData struct { Name *string `json:"name,omitempty"` IconBytes []byte `json:"-"` Icon *string `json:"icon,omitempty"` Reason *string `json:"-"` // Audit log reason, optional }
func (ModifyGroupDMChannelData) GetReason ¶
func (modifyData ModifyGroupDMChannelData) GetReason() *string
func (ModifyGroupDMChannelData) ToJson ¶
func (modifyData ModifyGroupDMChannelData) ToJson() ([]byte, error)
type ModifyGuildChannelData ¶
type ModifyGuildChannelData struct { Name *string `json:"name,omitempty"` // Can only switch between text and announcement channels Type *channel_type.ChannelType `json:"type,omitempty"` Position *int `json:"position,omitempty"` Topic *string `json:"topic,omitempty"` NSFW *bool `json:"nsfw,omitempty"` // Slow-mode (in seconds) RateLimit *int `json:"rate_limit_per_user,omitempty"` // Voice Channels Only: Bitrate *int `json:"bitrate,omitempty"` UserLimit *int `json:"user_limit,omitempty"` RtcRegion *string `json:"rtc_region,omitempty"` VideoQualityMode *int `json:"video_quality_mode,omitempty"` // Default archive duration for user-created threads (in minutes), supports: 60, 1440, 4320, 10080 DefaultAutoArchiveDuration *int `json:"default_auto_archive_duration,omitempty"` // Slow-mode (in seconds) DefaultThreadRateLimit *int `json:"default_thread_rate_limit_per_user,omitempty"` PermissionOverwrites []discord.Overwrite `json:"permission_overwrites,omitempty"` // Category ID ParentId *discord.Snowflake `json:"parent_id,omitempty"` // Forums Only: // Only supports REQUIRE_TAG (1<<4) Flags *int `json:"flags,omitempty"` AvailableTags []discord.Tag `json:"available_tags,omitempty"` DefaultReactionEmoji *discord.DefaultReaction `json:"default_reaction_emoji,omitempty"` DefaultSortOrder *int `json:"default_sort_order,omitempty"` DefaultForumLayout *int `json:"default_forum_layout,omitempty"` Reason *string `json:"-"` // Audit log reason, optional }
func (ModifyGuildChannelData) GetReason ¶
func (modifyData ModifyGuildChannelData) GetReason() *string
func (ModifyGuildChannelData) ToJson ¶
func (modifyData ModifyGuildChannelData) ToJson() ([]byte, error)
type ModifyMemberRoleOpts ¶
type ModifyThreadData ¶
type ModifyThreadData struct { Name *string `json:"name,omitempty"` Archived *bool `json:"archived,omitempty"` // Minutes, only supports: 60, 1440, 4320, 10080 AutoArchiveDuration *int `json:"auto_archive_duration,omitempty"` Locked *bool `json:"locked,omitempty"` Invitable *bool `json:"invitable,omitempty"` // Slow-mode (in seconds) RateLimit *int `json:"rate_limit_per_user,omitempty"` Flags *int `json:"flags,omitempty"` AppliedTags []discord.Tag `json:"applied_tags,omitempty"` Reason *string `json:"-"` // Audit log reason, optional }
func (ModifyThreadData) GetReason ¶
func (modifyData ModifyThreadData) GetReason() *string
func (ModifyThreadData) ToJson ¶
func (modifyData ModifyThreadData) ToJson() ([]byte, error)
type OAuthClient ¶
type OAuthClient struct { ClientId string ClientSecret string Client *http.Client // contains filtered or unexported fields }
func NewOAuthClient ¶
func NewOAuthClient(clientId string, clientSecret string, redirectUri string) *OAuthClient
func (*OAuthClient) AuthorizeUserFromCode ¶
func (oauthClient *OAuthClient) AuthorizeUserFromCode(code string) (*AuthorizedUser, error)
func (*OAuthClient) BuildAuthorizationURL ¶
func (oauthClient *OAuthClient) BuildAuthorizationURL(scopes []oauth_scopes.OAuthScope, state string) string
func (*OAuthClient) MakeRequest ¶
func (oauthClient *OAuthClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
func (*OAuthClient) RefreshTokensForUser ¶
func (oauthClient *OAuthClient) RefreshTokensForUser(refreshToken string) (tokenResponse *TokenResponse, err error)
func (*OAuthClient) RevokeTokensForUser ¶
func (oauthClient *OAuthClient) RevokeTokensForUser(accessToken string) (err error)
type RevokeTokenRequest ¶
type RevokeTokenRequest struct { Token string `json:"token"` TokenTypeHint string `json:"token_type_hint"` ClientId string `json:"client_id"` ClientSecret string `json:"client_secret"` }
func (*RevokeTokenRequest) ToString ¶
func (r *RevokeTokenRequest) ToString() string
func (*RevokeTokenRequest) ToValues ¶
func (r *RevokeTokenRequest) ToValues() url.Values
type SendMessageData ¶
type SendMessageData struct { Content *string `json:"content,omitempty"` TTS *bool `json:"tts,omitempty"` Embeds []discord.Embed `json:"embeds,omitempty"` AllowedMentions *discord.AllowedMentions `json:"allowed_mentions,omitempty"` // Channel ID optional MessageReference *discord.MessageReference `json:"message_reference,omitempty"` Components []discord.MessageComponent `json:"components,omitempty"` StickerIds []discord.Snowflake `json:"sticker_ids,omitempty"` Attachments []discord.Attachment `json:"attachments,omitempty"` // Only supports "SUPPRESS_EMBEDS" (1<<2) and "SUPPRESS_NOTIFICATIONS" (1<<12) Flags *int `json:"flags,omitempty"` }
type ThreadType ¶
type ThreadType uint8
type TokenGrantType ¶
type TokenGrantType string
const ( GrantTypeAuthorizationCode TokenGrantType = "authorization_code" GrantTypeRefreshToken TokenGrantType = "refresh_token" )
type TokenRequest ¶
type TokenRequest struct { GrantType TokenGrantType `json:"grant_type"` Code string `json:"code,omitempty"` RedirectUri string `json:"redirect_uri,omitempty"` RefreshToken string `json:"refresh_token,omitempty"` ClientId string `json:"client_id,omitempty"` ClientSecret string `json:"client_secret,omitempty"` }
func (*TokenRequest) ToString ¶
func (t *TokenRequest) ToString() string
func (*TokenRequest) ToValues ¶
func (t *TokenRequest) ToValues() url.Values
type TokenResponse ¶
type TokenResponse struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` TokenType string `json:"token_type"` ExpiresIn int `json:"expires_in"` Scope string `json:"scope"` }
func (*TokenResponse) ToAuthorizedUser ¶
func (response *TokenResponse) ToAuthorizedUser(client *OAuthClient) *AuthorizedUser
type UserClient ¶
func (*UserClient) CreateDMChannel ¶
func (userClient *UserClient) CreateDMChannel() (*discord.Channel, error)
func (*UserClient) GetIdAsString ¶
func (userClient *UserClient) GetIdAsString() string
func (*UserClient) MakeRequest ¶
func (userClient *UserClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)
func (*UserClient) SendMessage ¶
func (userClient *UserClient) SendMessage(messageData SendMessageData) (*discord.Message, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.