route

package
v0.8.10 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIVersion = "10"
	Base       = "https://discord.com/"
	CDN        = "https://cdn.discordapp.com"
	API        = Base + "api/v" + APIVersion
)

Discord Endpoint Constants

View Source
const MajorParameters = "guild.id:channel.id:webhook.id:interaction.token"

MajorParameters is a list of url parameters which decide in which bucket a route belongs (https://discord.com/developers/docs/topics/rate-limits#rate-limits)

Variables

View Source
var (
	GetGateway      = NewAPIRoute(GET, "/gateway")
	GetGatewayBot   = NewAPIRoute(GET, "/gateway/bot")
	GetVoiceRegions = NewAPIRoute(GET, "/voice/regions")
)

Misc

View Source
var (
	GetBotApplicationInfo = NewAPIRoute(GET, "/oauth2/applications/@me")
	GetAuthorizationInfo  = NewAPIRouteNoAuth(GET, "/oauth2/@me")
	Authorize             = NewRoute("/oauth2/authorize", "client_id", "permissions", "redirect_uri", "response_type", "scope", "state", "guild_id", "disable_guild_select")
	Token                 = NewAPIRouteNoAuth(POST, "/oauth2/token")
)

OAuth2

View Source
var (
	GetUser                   = NewAPIRoute(GET, "/users/{user.id}")
	GetCurrentUser            = NewAPIRoute(GET, "/users/@me")
	UpdateSelfUser            = NewAPIRoute(PATCH, "/users/@me")
	GetCurrentUserConnections = NewAPIRouteNoAuth(GET, "/users/@me/connections")
	GetCurrentUserGuilds      = NewAPIRouteNoAuth(GET, "/users/@me/guilds", "before", "after", "limit")
	LeaveGuild                = NewAPIRoute(DELETE, "/users/@me/guilds/{guild.id}")
	GetDMChannels             = NewAPIRoute(GET, "/users/@me/channels")
	CreateDMChannel           = NewAPIRoute(POST, "/users/@me/channels")
)

Users

View Source
var (
	GetGuild          = NewAPIRoute(GET, "/guilds/{guild.id}", "with_counts")
	GetGuildPreview   = NewAPIRoute(GET, "/guilds/{guild.id}/preview")
	CreateGuild       = NewAPIRoute(POST, "/guilds")
	UpdateGuild       = NewAPIRoute(PATCH, "/guilds/{guild.id}")
	DeleteGuild       = NewAPIRoute(DELETE, "/guilds/{guild.id}")
	GetGuildVanityURL = NewAPIRoute(GET, "/guilds/{guild.id}/vanity-url")

	CreateGuildChannel     = NewAPIRoute(POST, "/guilds/{guild.id}/channels")
	GetGuildChannels       = NewAPIRoute(GET, "/guilds/{guild.id}/channels")
	UpdateChannelPositions = NewAPIRoute(PATCH, "/guilds/{guild.id}/channels")

	GetBans   = NewAPIRoute(GET, "/guilds/{guild.id}/bans", "before", "after", "limit")
	GetBan    = NewAPIRoute(GET, "/guilds/{guild.id}/bans/{user.id}")
	AddBan    = NewAPIRoute(PUT, "/guilds/{guild.id}/bans/{user.id}")
	DeleteBan = NewAPIRoute(DELETE, "/guilds/{guild.id}/bans/{user.id}")

	GetMember        = NewAPIRoute(GET, "/guilds/{guild.id}/members/{user.id}")
	GetMembers       = NewAPIRoute(GET, "/guilds/{guild.id}/members")
	SearchMembers    = NewAPIRoute(GET, "/guilds/{guild.id}/members/search", "query", "limit")
	AddMember        = NewAPIRoute(PUT, "/guilds/{guild.id}/members/{user.id}")
	UpdateMember     = NewAPIRoute(PATCH, "/guilds/{guild.id}/members/{user.id}")
	RemoveMember     = NewAPIRoute(DELETE, "/guilds/{guild.id}/members/{user.id}", "reason")
	AddMemberRole    = NewAPIRoute(PUT, "/guilds/{guild.id}/members/{user.id}/roles/{role.id}")
	RemoveMemberRole = NewAPIRoute(DELETE, "/guilds/{guild.id}/members/{user.id}/roles/{role.id}")

	UpdateSelfNick = NewAPIRoute(PATCH, "/guilds/{guild.id}/members/@me/nick")

	GetPruneMembersCount = NewAPIRoute(GET, "/guilds/{guild.id}/prune")
	PruneMembers         = NewAPIRoute(POST, "/guilds/{guild.id}/prune")

	GetGuildWebhooks = NewAPIRoute(GET, "/guilds/{guild.id}/webhooks")

	GetAuditLogs = NewAPIRoute(GET, "/guilds/{guild.id}/audit-logs", "user_id", "action_type", "before", "limit")

	GetGuildVoiceRegions = NewAPIRoute(GET, "/guilds/{guild.id}/regions")

	UpdateCurrentUserVoiceState = NewAPIRoute(PATCH, "/guilds/{guild.id}/voice-states/@me")
	UpdateUserVoiceState        = NewAPIRoute(PATCH, "/guilds/{guild.id}/voice-states/{user.id}")
)

Guilds

View Source
var (
	GetIntegrations   = NewAPIRoute(GET, "/guilds/{guild.id}/integrations")
	CreateIntegration = NewAPIRoute(POST, "/guilds/{guild.id}/integrations")
	UpdateIntegration = NewAPIRoute(PATCH, "/guilds/{guild.id}/integrations/{integration.id}")
	DeleteIntegration = NewAPIRoute(DELETE, "/guilds/{guild.id}/integrations/{integration.id}")
	SyncIntegration   = NewAPIRoute(POST, "/guilds/{guild.id}/integrations/{integration.id}/sync")
)

GuildIntegrations

View Source
var (
	GetGuildTemplate        = NewAPIRoute(GET, "/guilds/templates/{template.code}")
	GetGuildTemplates       = NewAPIRoute(GET, "/guilds/{guild.id}/templates")
	CreateGuildTemplate     = NewAPIRoute(POST, "/guilds/{guild.id}/templates")
	SyncGuildTemplate       = NewAPIRoute(PUT, "/guilds/{guild.id}/templates/{template.code}")
	UpdateGuildTemplate     = NewAPIRoute(PATCH, "/guilds/{guild.id}/templates/{template.code}")
	DeleteGuildTemplate     = NewAPIRoute(DELETE, "/guilds/{guild.id}/templates/{template.code}")
	CreateGuildFromTemplate = NewAPIRoute(POST, "/guilds/templates/{template.code}")
)

GuildTemplates

View Source
var (
	GetGuildScheduledEvents   = NewAPIRoute(GET, "/guilds/{guild.id}/scheduled-events", "with_user_count")
	GetGuildScheduledEvent    = NewAPIRoute(GET, "/guilds/{guild.id}/scheduled-events/{guild_scheduled_event.id}", "with_user_count")
	CreateGuildScheduledEvent = NewAPIRoute(POST, "/guilds/{guild.id}/scheduled-events")
	UpdateGuildScheduledEvent = NewAPIRoute(PATCH, "/guilds/{guild.id}/scheduled-events/{guild_scheduled_event.id}")
	DeleteGuildScheduledEvent = NewAPIRoute(DELETE, "/guilds/{guild.id}/scheduled-events/{guild_scheduled_event.id}")

	GetGuildScheduledEventUsers = NewAPIRoute(GET, "/guilds/{guild.id}/scheduled-events/{guild_scheduled_event.id}/users", "limit", "with_member", "before", "after")
)

GuildScheduledEvents

View Source
var (
	GetStageInstance    = NewAPIRoute(GET, "/stage-instances/{channel.id}")
	CreateStageInstance = NewAPIRoute(POST, "/stage-instances")
	UpdateStageInstance = NewAPIRoute(PATCH, "/stage-instances/{channel.id}")
	DeleteStageInstance = NewAPIRoute(DELETE, "/stage-instances/{channel.id}")
)

StageInstance

View Source
var (
	GetRoles            = NewAPIRoute(GET, "/guilds/{guild.id}/roles")
	GetRole             = NewAPIRoute(GET, "/guilds/{guild.id}/roles/{role.id}")
	CreateRole          = NewAPIRoute(POST, "/guilds/{guild.id}/roles")
	UpdateRole          = NewAPIRoute(PATCH, "/guilds/{guild.id}/roles/{role.id}")
	UpdateRolePositions = NewAPIRoute(PATCH, "/guilds/{guild.id}/roles")
	DeleteRole          = NewAPIRoute(DELETE, "/guilds/{guild.id}/roles/{role.id}")
)

Roles

View Source
var (
	GetChannel    = NewAPIRoute(GET, "/channels/{channel.id}")
	UpdateChannel = NewAPIRoute(PATCH, "/channels/{channel.id}")
	DeleteChannel = NewAPIRoute(DELETE, "/channels/{channel.id}")

	GetChannelWebhooks = NewAPIRoute(GET, "/channels/{channel.id}/webhooks")
	CreateWebhook      = NewAPIRoute(POST, "/channels/{channel.id}/webhooks")

	GetPermissionOverwrites   = NewAPIRoute(GET, "/channels/{channel.id}/permissions")
	GetPermissionOverwrite    = NewAPIRoute(GET, "/channels/{channel.id}/permissions/{overwrite.id}")
	UpdatePermissionOverwrite = NewAPIRoute(PUT, "/channels/{channel.id}/permissions/{overwrite.id}")
	DeletePermissionOverwrite = NewAPIRoute(DELETE, "/channels/{channel.id}/permissions/{overwrite.id}")

	SendTyping    = NewAPIRoute(POST, "/channels/{channel.id}/typing")
	FollowChannel = NewAPIRoute(POST, "/channels/{channel.id}/followers")
)

Channels

View Source
var (
	CreateThreadWithMessage = NewAPIRoute(POST, "/channels/{channel.id}/messages/{message.id}/threads")
	CreateThread            = NewAPIRoute(POST, "/channels/{channel.id}/threads")
	JoinThread              = NewAPIRoute(PUT, "/channels/{channel.id}/thread-members/@me")
	LeaveThread             = NewAPIRoute(DELETE, "/channels/{channel.id}/thread-members/@me")
	AddThreadMember         = NewAPIRoute(PUT, "/channels/{channel.id}/thread-members/{user.id}")
	RemoveThreadMember      = NewAPIRoute(DELETE, "/channels/{channel.id}/thread-members/{user.id}")
	GetThreadMember         = NewAPIRoute(GET, "/channels/{channel.id}/thread-members/{user.id}")
	GetThreadMembers        = NewAPIRoute(GET, "/channels/{channel.id}/thread-members")

	GetArchivedPublicThreads        = NewAPIRoute(GET, "/channels/{channel.id}/threads/archived/public", "before", "limit")
	GetArchivedPrivateThreads       = NewAPIRoute(GET, "/channels/{channel.id}/threads/archived/private", "before", "limit")
	GetJoinedAchievedPrivateThreads = NewAPIRoute(GET, "/channels/{channel.id}/users/@me/threads/archived/private", "before", "limit")
)

Threads

View Source
var (
	GetMessages        = NewAPIRoute(GET, "/channels/{channel.id}/messages")
	GetMessage         = NewAPIRoute(GET, "/channels/{channel.id}/messages/{message.id}")
	CreateMessage      = NewAPIRoute(POST, "/channels/{channel.id}/messages")
	UpdateMessage      = NewAPIRoute(PATCH, "/channels/{channel.id}/messages/{message.id}")
	DeleteMessage      = NewAPIRoute(DELETE, "/channels/{channel.id}/messages/{message.id}")
	BulkDeleteMessages = NewAPIRoute(POST, "/channels/{channel.id}/messages/bulk-delete")

	GetPinnedMessages = NewAPIRoute(GET, "/channels/{channel.id}/pins")
	PinMessage        = NewAPIRoute(PUT, "/channels/{channel.id}/pins/{message.id}")
	UnpinMessage      = NewAPIRoute(DELETE, "/channels/{channel.id}/pins/{message.id}")

	CrosspostMessage = NewAPIRoute(POST, "/channels/{channel.id}/messages/{message.id}/crosspost")

	GetReactions               = NewAPIRoute(GET, "/channels/{channel.id}/messages/{message.id}/reactions/{emoji}", "after", "limit")
	AddReaction                = NewAPIRoute(PUT, "/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me")
	RemoveOwnReaction          = NewAPIRoute(DELETE, "/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me")
	RemoveUserReaction         = NewAPIRoute(DELETE, "/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/{user.id}")
	RemoveAllReactions         = NewAPIRoute(DELETE, "/channels/{channel.id}/messages/{message.id}/reactions")
	RemoveAllReactionsForEmoji = NewAPIRoute(DELETE, "/channels/{channel.id}/messages/{message.id}/reactions/{emoji}")
)

Messages

View Source
var (
	GetEmojis   = NewAPIRoute(GET, "/guilds/{guild.id}/emojis")
	GetEmoji    = NewAPIRoute(GET, "/guilds/{guild.id}/emojis/{emoji.id}")
	CreateEmoji = NewAPIRoute(POST, "/guilds/{guild.id}/emojis")
	UpdateEmoji = NewAPIRoute(PATCH, "/guilds/{guild.id}/emojis/{emote.id}")
	DeleteEmoji = NewAPIRoute(DELETE, "/guilds/{guild.id}/emojis/{emote.id}")
)

Emojis

View Source
var (
	GetNitroStickerPacks = NewAPIRoute(GET, "/sticker-packs")
	GetSticker           = NewAPIRoute(GET, "/stickers/{sticker.id}")
	GetGuildStickers     = NewAPIRoute(GET, "/guilds/{guild.id}/stickers")
	CreateGuildSticker   = NewAPIRoute(POST, "/guilds/{guild.id}/stickers")
	UpdateGuildSticker   = NewAPIRoute(PATCH, "/guilds/{guild.id}/stickers/{sticker.id}")
	DeleteGuildSticker   = NewAPIRoute(DELETE, "/guilds/{guild.id}/stickers/{sticker.id}")
)

Stickers

View Source
var (
	GetWebhook    = NewAPIRoute(GET, "/webhooks/{webhook.id}")
	UpdateWebhook = NewAPIRoute(PATCH, "/webhooks/{webhook.id}")
	DeleteWebhook = NewAPIRoute(DELETE, "/webhooks/{webhook.id}")

	GetWebhookWithToken    = NewAPIRouteNoAuth(GET, "/webhooks/{webhook.id}/{webhook.token}")
	UpdateWebhookWithToken = NewAPIRouteNoAuth(PATCH, "/webhooks/{webhook.id}/{webhook.token}")
	DeleteWebhookWithToken = NewAPIRouteNoAuth(DELETE, "/webhooks/{webhook.id}/{webhook.token}")

	CreateWebhookMessage       = NewAPIRouteNoAuth(POST, "/webhooks/{webhook.id}/{webhook.token}", "wait", "thread_id")
	CreateWebhookMessageSlack  = NewAPIRouteNoAuth(POST, "/webhooks/{webhook.id}/{webhook.token}/slack", "wait", "thread_id")
	CreateWebhookMessageGitHub = NewAPIRouteNoAuth(POST, "/webhooks/{webhook.id}/{webhook.token}/github", "wait", "thread_id")
	UpdateWebhookMessage       = NewAPIRouteNoAuth(PATCH, "/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}", "thread_id")
	DeleteWebhookMessage       = NewAPIRouteNoAuth(DELETE, "/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}", "thread_id")
)

Webhooks

View Source
var (
	GetInvite    = NewAPIRoute(GET, "/invites/{code}", "with_counts", "with_expiration", "guild_scheduled_event_id")
	CreateInvite = NewAPIRoute(POST, "/channels/{channel.id}/invites")
	DeleteInvite = NewAPIRoute(DELETE, "/invites/{code}")

	GetGuildInvites   = NewAPIRoute(GET, "/guilds/{guild.id}/invites")
	GetChannelInvites = NewAPIRoute(GET, "/channels/{channel.id}/invites")
)

Invites

View Source
var (
	GetGlobalCommands   = NewAPIRoute(GET, "/applications/{application.id}/commands", "with_localizations")
	GetGlobalCommand    = NewAPIRoute(GET, "/applications/{application.id}/command/{command.id}")
	CreateGlobalCommand = NewAPIRoute(POST, "/applications/{application.id}/commands")
	SetGlobalCommands   = NewAPIRoute(PUT, "/applications/{application.id}/commands")
	UpdateGlobalCommand = NewAPIRoute(PATCH, "/applications/{application.id}/commands/{command.id}")
	DeleteGlobalCommand = NewAPIRoute(DELETE, "/applications/{application.id}/commands")

	GetGuildCommands   = NewAPIRoute(GET, "/applications/{application.id}/guilds/{guild.id}/commands", "with_localizations")
	GetGuildCommand    = NewAPIRoute(GET, "/applications/{application.id}/guilds/{guild.id}/command/{command.id}")
	CreateGuildCommand = NewAPIRoute(POST, "/applications/{application.id}/guilds/{guild.id}/commands")
	SetGuildCommands   = NewAPIRoute(PUT, "/applications/{application.id}/guilds/{guild.id}/commands")
	UpdateGuildCommand = NewAPIRoute(PATCH, "/applications/{application.id}/guilds/{guild.id}/commands/{command.id}")
	DeleteGuildCommand = NewAPIRoute(DELETE, "/applications/{application.id}/guilds/{guild.id}/commands")

	GetGuildCommandsPermissions = NewAPIRoute(GET, "/applications/{application.id}/guilds/{guild.id}/commands/permissions")
	GetGuildCommandPermissions  = NewAPIRoute(GET, "/applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissions")
	SetGuildCommandsPermissions = NewAPIRoute(PUT, "/applications/{application.id}/guilds/{guild.id}/commands/permissions")
	SetGuildCommandPermissions  = NewAPIRoute(PUT, "/applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissions")

	GetInteractionResponse    = NewAPIRouteNoAuth(GET, "/webhooks/{application.id}/{interaction.token}/messages/@original")
	CreateInteractionResponse = NewAPIRouteNoAuth(POST, "/interactions/{interaction.id}/{interaction.token}/callback")
	UpdateInteractionResponse = NewAPIRouteNoAuth(PATCH, "/webhooks/{application.id}/{interaction.token}/messages/@original")
	DeleteInteractionResponse = NewAPIRouteNoAuth(DELETE, "/webhooks/{application.id}/{interaction.token}/messages/@original")

	GetFollowupMessage    = NewAPIRouteNoAuth(GET, "/webhooks/{application.id}/{interaction.token}")
	CreateFollowupMessage = NewAPIRouteNoAuth(POST, "/webhooks/{application.id}/{interaction.token}")
	UpdateFollowupMessage = NewAPIRouteNoAuth(PATCH, "/webhooks/{application.id}/{interaction.token}/messages/{message.id}")
	DeleteFollowupMessage = NewAPIRouteNoAuth(DELETE, "/webhooks/{application.id}/{interaction.token}/messages/{message.id}")
)

Interactions

View Source
var (
	CustomEmoji = NewCDNRoute("/emojis/{emote.id}", PNG, GIF)

	GuildIcon            = NewCDNRoute("/icons/{guild.id}/{guild.icon.hash}", PNG, JPEG, WebP, GIF)
	GuildSplash          = NewCDNRoute("/splashes/{guild.id}/{guild.splash.hash}", PNG, JPEG, WebP)
	GuildDiscoverySplash = NewCDNRoute("/discovery-splashes/{guild.id}/{guild.discovery.splash.hash}", PNG, JPEG, WebP)
	GuildBanner          = NewCDNRoute("/banners/{guild.id}/{guild.banner.hash}", PNG, JPEG, WebP, GIF)

	RoleIcon = NewCDNRoute("/role-icons/{role.id}/{role.icon.hash}", PNG, JPEG)

	UserBanner        = NewCDNRoute("/banners/{user.id}/{user.banner.hash}", PNG, JPEG, WebP, GIF)
	UserAvatar        = NewCDNRoute("/avatars/{user.id}/{user.avatar.hash}", PNG, JPEG, WebP, GIF)
	DefaultUserAvatar = NewCDNRoute("/embed/avatars/{user.discriminator%5}", PNG)

	ChannelIcon = NewCDNRoute("/channel-icons/{channel.id}/{channel.icon.hash}", PNG, JPEG, WebP)

	MemberAvatar = NewCDNRoute("/guilds/{guild.id}/users/{user.id}/avatars/{member.avatar.hash}", PNG, JPEG, WebP, GIF)

	ApplicationIcon  = NewCDNRoute("/app-icons/{application.id}/{icon.hash}", PNG, JPEG, WebP)
	ApplicationCover = NewCDNRoute("/app-assets/{application.id}/{cover.image.hash}", PNG, JPEG, WebP)
	ApplicationAsset = NewCDNRoute("/app-assets/{application.id}/{asset.id}", PNG, JPEG, WebP)

	AchievementIcon = NewCDNRoute("/app-assets/{application.id}/achievements/{achievement.id}/icons/{icon.hash}", PNG, JPEG, WebP)

	TeamIcon = NewCDNRoute("/team-icons/{team.id}/{team.icon.hash}", PNG, JPEG, WebP)

	StickerPackBanner = NewCDNRoute("app-assets/710982414301790216/store/{banner.asset.id}", PNG, JPEG, WebP)
	CustomSticker     = NewCDNRoute("/stickers/{sticker.id}", PNG, Lottie)

	Attachment = NewCDNRoute("/attachments/{channel.id}/{attachment.id}/{file.name}", BLANK)
)

CDN

View Source
var (
	InviteURL  = NewCustomRoute("https://discord.gg", "/{code}")
	WebhookURL = NewCustomRoute("https://discord.com", "/api/webhooks/{webhook.id}/{webhook.token}")
)

Other

Functions

func ErrImageFormatNotSupported

func ErrImageFormatNotSupported(imageFormat ImageFormat) error

ErrImageFormatNotSupported returns a new error for if you provide an image format that is not supported for this resource

func ErrInvalidArgCount

func ErrInvalidArgCount(argCount int, paramCount int) error

ErrInvalidArgCount returns a new error for invalid argument count

func ErrUnexpectedQueryParam

func ErrUnexpectedQueryParam(param string) error

ErrUnexpectedQueryParam returns a new error for unexpected query parameters

Types

type APIRoute

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

APIRoute is a basic struct containing Method and URL

func NewAPIRoute

func NewAPIRoute(method Method, path string, queryParams ...string) *APIRoute

NewAPIRoute generates a new discord api path struct

func NewAPIRouteNoAuth

func NewAPIRouteNoAuth(method Method, path string, queryParams ...string) *APIRoute

func NewCustomAPIRoute

func NewCustomAPIRoute(method Method, basePath string, path string, queryParams ...string) *APIRoute

NewCustomAPIRoute generates a new custom path struct

func (*APIRoute) Compile

func (r *APIRoute) Compile(queryValues QueryValues, params ...any) (*CompiledAPIRoute, error)

Compile returns a CompiledAPIRoute

func (*APIRoute) Method

func (r *APIRoute) Method() Method

Method returns the request method used by the path

func (*APIRoute) NeedsBotAuth

func (r *APIRoute) NeedsBotAuth() bool

NeedsBotAuth returns whether the route requires authentication

func (*APIRoute) Path

func (r *APIRoute) Path() string

Path returns the request path used by the path

type CDNRoute

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

CDNRoute is a path for interacting with images hosted on discord's CDN

func NewCDNRoute

func NewCDNRoute(path string, supportedImageFormats ...ImageFormat) *CDNRoute

NewCDNRoute generates a new discord cdn path struct

func NewCustomCDNRoute

func NewCustomCDNRoute(basePath string, path string, supportedImageFormats ...ImageFormat) *CDNRoute

NewCustomCDNRoute generates a new custom cdn path struct

func (*CDNRoute) Compile

func (r *CDNRoute) Compile(queryValues QueryValues, imageFormat ImageFormat, size int, params ...any) (*CompiledCDNRoute, error)

Compile builds a full request URL based on provided arguments

func (*CDNRoute) Path

func (r *CDNRoute) Path() string

Path returns the request path used by the path

type CompiledAPIRoute

type CompiledAPIRoute struct {
	APIRoute *APIRoute
	// contains filtered or unexported fields
}

CompiledAPIRoute is APIRoute compiled with all URL args

func (*CompiledAPIRoute) MajorParams

func (r *CompiledAPIRoute) MajorParams() string

MajorParams returns the major parameter from the request

func (*CompiledAPIRoute) URL

func (r *CompiledAPIRoute) URL() string

URL returns the full URL for the request

type CompiledCDNRoute

type CompiledCDNRoute struct {
	CDNRoute *CDNRoute
	// contains filtered or unexported fields
}

CompiledCDNRoute is CDNRoute compiled with all URL args

func (*CompiledCDNRoute) URL

func (r *CompiledCDNRoute) URL() string

URL returns the full URL for the resource

type CompiledRoute

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

CompiledRoute is Route compiled with all URL args

func (*CompiledRoute) URL

func (r *CompiledRoute) URL() string

URL returns the full URL of the CompiledRoute

type ImageFormat

type ImageFormat string

ImageFormat is the type of image on Discord's CDN (https://discord.com/developers/docs/reference#image-formatting-image-formats)

const (
	PNG    ImageFormat = "png"
	JPEG   ImageFormat = "jpg"
	WebP   ImageFormat = "webp"
	GIF    ImageFormat = "gif"
	Lottie ImageFormat = "json"
	BLANK  ImageFormat = ""
)

The available ImageFormat(s)

func (ImageFormat) CanBeAnimated

func (f ImageFormat) CanBeAnimated() bool

func (ImageFormat) String

func (f ImageFormat) String() string

type Method

type Method string

Method is an HTTP request Method

const (
	DELETE Method = "DELETE"
	GET    Method = "GET"
	POST   Method = "POST"
	PUT    Method = "PUT"
	PATCH  Method = "PATCH"
)

HTTP Methods used by Discord

func (Method) String

func (m Method) String() string

String returns the string representation of the Method

type QueryValues

type QueryValues map[string]any

QueryValues is used to supply query param value pairs to Route.Compile

type Route

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

Route is a basic struct containing Method and URL

func NewCustomRoute

func NewCustomRoute(basePath string, path string, queryParams ...string) *Route

NewCustomRoute generates a new custom path struct

func NewRoute

func NewRoute(path string, queryParams ...string) *Route

NewRoute generates a new discord path struct

func (*Route) Compile

func (r *Route) Compile(queryValues QueryValues, params ...any) (*CompiledRoute, error)

Compile returns a CompiledRoute

func (*Route) Path

func (r *Route) Path() string

Path returns the request path used by the path

Jump to

Keyboard shortcuts

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