Documentation ¶
Index ¶
- type Application
- type ApplicationCommand
- type ApplicationCommandID
- type ApplicationCommandInteractionDataOption
- type ApplicationCommandOption
- type ApplicationCommandOptionChoice
- type ApplicationCommandOptionType
- type ApplicationCommandType
- type ApplicationID
- type Channel
- type ChannelID
- type ChannelType
- type Discord
- func (d *Discord) AddHandler(f any)
- func (d *Discord) Close() error
- func (d *Discord) Connect() error
- func (d *Discord) CreateMessage(channelID ChannelID, message *MessageParams) (*Message, error)
- func (d *Discord) DeleteGuildRole(guildID GuildID, roleID RoleID) error
- func (d *Discord) DeleteMessage(channelID ChannelID, messageID MessageID) error
- func (d *Discord) GetChannel(channelID ChannelID) (*Channel, error)
- func (s *Discord) GetCurrentUser() (*User, error)
- func (d *Discord) GetCurrentUserGuildMember(guildID GuildID) (*GuildMember, error)
- func (s *Discord) GetCurrentUserGuilds(opts ...GetCurrentUserGuildsOption) ([]*Guild, error)
- func (s *Discord) GetGateway() (*GetGatewayResponse, error)
- func (d *Discord) GetGatewayBot() (*GetGatewayResponse, error)
- func (d *Discord) GetGlobalApplicationCommands(applicationID ApplicationID, withLocalization bool) ([]ApplicationCommand, error)
- func (s *Discord) GetGuildEmoji(guildID GuildID, emojiID EmojiID) (*Emoji, error)
- func (d *Discord) GetGuildRoles(guildID GuildID) ([]*Role, error)
- func (s *Discord) GetUser(id UserID) (*User, error)
- func (s *Discord) ListGuildEmojis(guildID GuildID) ([]*Emoji, error)
- func (s *Discord) ModifyCurrentUser(opts ...ModifyCurrentUserOption) (*User, error)
- type Emoji
- type EmojiID
- type ErrorResponse
- type EventMessageCreate
- type EventReady
- type GetCurrentUserGuildsOption
- type GetGatewayResponse
- type Guild
- type GuildID
- type GuildMember
- type Message
- type MessageID
- type MessageParams
- type ModifyCurrentUserOption
- type Role
- type RoleID
- type Snowflake
- type UnavailableGuild
- type User
- type UserFlag
- type UserID
- type WithAfter
- type WithAvatar
- type WithBefore
- type WithLimit
- type WithUsername
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct { ID ApplicationID `json:"id"` Name string `json:"name"` Icon *string `json:"icon"` Description string `json:"description"` RPCOrigins []string `json:"rpc_origins"` BotPublic bool `json:"bot_public"` BotRequireCodeGrant bool `json:"bot_require_code_grant"` TermsOfServiceURL *string `json:"terms_of_service_url"` PrivacyPolicyURL *string `json:"privacy_policy_url"` Owner *User `json:"owner"` VerifyKey string //Team //TODO GuildID *GuildID `json:"guild_id"` //PrimarySKUID //TODO Slug *string `json:"slug"` CoverImage *string `json:"cover_image"` Flags *int `json:"flags"` Tags []string `json:"tags"` //InstallParams //TODO CustomInstallURL *string `json:"custom_install_url"` }
https://discord.com/developers/docs/resources/application#application-object
type ApplicationCommand ¶
type ApplicationCommand struct { ID ApplicationCommandID `json:"id"` Type *ApplicationCommandType `json:"type,omitempty"` ApplicationID ApplicationID `json:"application_id"` GuildID *GuildID `json:"guild_id,omitempty"` Name string `json:"name"` NameLocalizations map[string]string `json:"name_localizations,omitempty"` Description string `json:"description"` DescriptionLocalizations map[string]string `json:"description_localizations,omitempty"` Options []ApplicationCommandOption `json:"options,omitempty"` DefaultPermission *bool `json:"default_permission,omitempty"` Version Snowflake `json:"version"` }
type ApplicationCommandID ¶
type ApplicationCommandID Snowflake
type ApplicationCommandInteractionDataOption ¶
type ApplicationCommandInteractionDataOption struct { Name string `json:"name"` Type ApplicationCommandOptionType `json:"type"` Value any `json:"value,omitempty"` Options []ApplicationCommandInteractionDataOption `json:"options,omitempty"` Focused *bool `json:"focused,omitempty"` }
type ApplicationCommandOption ¶
type ApplicationCommandOption struct { Type *ApplicationCommandOptionType `json:"type"` Name string `json:"name"` NameLocalizations map[string]string `json:"name_localizations,omitempty"` Description string `json:"description"` DescriptionLocalizations map[string]string `json:"description_localizations,omitempty"` Required *bool `json:"required,omitempty"` Choices []ApplicationCommandOptionChoice `json:"choices,omitempty"` Options []ApplicationCommandOption `json:"options,omitempty"` ChannelTypes []ChannelType `json:"channel_types,omitempty"` MinValue float64 `json:"min_value,omitempty"` MaxValue float64 `json:"max_value,omitempty"` AutoComplete *bool `json:"auto_complete,omitempty"` }
type ApplicationCommandOptionChoice ¶
type ApplicationCommandOptionType ¶
type ApplicationCommandOptionType int
const ( ApplicationCommandOptionTypeSubCommand ApplicationCommandOptionType = iota + 1 ApplicationCommandOptionTypeSubCommandGroup ApplicationCommandOptionTypeString ApplicationCommandOptionTypeInteger ApplicationCommandOptionTypeBoolean ApplicationCommandOptionTypeUser ApplicationCommandOptionTypeChannel ApplicationCommandOptionTypeRole ApplicationCommandOptionTypeMentionable ApplicationCommandOptionTypeNumber ApplicationCommandOptionTypeAttachment )
type ApplicationCommandType ¶
type ApplicationCommandType int
const ( ApplicationCommandTypeChatInput ApplicationCommandType = iota + 1 ApplicationCommandTypeUser ApplicationCommandTypeMessage )
type ApplicationID ¶
type ApplicationID Snowflake
type Channel ¶
type Channel struct { ID ChannelID `json:"id"` Type ChannelType `json:"type"` GuildID *GuildID `json:"guild_id"` Position int `json:"position"` // PermissionOverwrites // TODO Name *string `json:"name"` Topic *string `json:"topic"` NSFW bool `json:"nsfw"` LastMessageID *MessageID `json:"last_message_id"` Bitrate int `json:"bitrate"` UserLimit int `json:"user_limit"` RateLimitPerUser int `json:"rate_limit_per_user"` Recipients []*User `json:"recipients"` Icon *string `json:"icon"` OwnerID UserID `json:"ownerId"` ApplicationID ApplicationID `json:"application_id"` }
Channel Represents a guild or DM channel within Discord.
https://discord.com/developers/docs/resources/channel#channel-object
type ChannelType ¶
type ChannelType int
https://discord.com/developers/docs/resources/channel#channel-object-channel-types
const ( ChannelTypeGuildText ChannelType = iota ChannelTypeDM ChannelTypeGuildVoice ChannelTypeGroupDM ChannelTypeGuildCategory ChannelTypeGuildNews ChannelTypeGuildNewsThread ChannelTypeGubldPublicThread ChannelTypeGuildPrivateThread ChannelTypeGuildStageVoice ChannelTypeGuildDirectory ChannelTypeGuildForum )
type Discord ¶
type Discord struct { BaseURL string APIVersion int HTTPClient *http.Client // contains filtered or unexported fields }
func (*Discord) AddHandler ¶
func (*Discord) CreateMessage ¶
func (d *Discord) CreateMessage(channelID ChannelID, message *MessageParams) (*Message, error)
CreateMessage Post a message to a guild text or DM channel. Returns a message object. Fires a Message Create Gateway event. See message formatting for more information on how to properly format messages.
https://discord.com/developers/docs/resources/channel#create-message
func (*Discord) DeleteGuildRole ¶
func (*Discord) DeleteMessage ¶
DeleteMessage Delete a message. If operating on a guild channel and trying to delete a message that was not sent by the current user, this endpoint requires the MANAGE_MESSAGES permission. Returns a 204 empty response on success. Fires a Message Delete Gateway event.
https://discord.com/developers/docs/resources/channel#delete-message
func (*Discord) GetChannel ¶
GetChannel Get a channel by ID. Returns a channel object. If the channel is a thread, a thread member object is included in the returned result.
https://discord.com/developers/docs/resources/channel#get-channel
func (*Discord) GetCurrentUser ¶
GetCurrentUser returns the user object of the requester's account. For OAuth2, this requires the identify scope, which will return the object without an email, and optionally the email scope, which returns the object with an email.
https://discord.com/developers/docs/resources/user#get-current-user
func (*Discord) GetCurrentUserGuildMember ¶
func (d *Discord) GetCurrentUserGuildMember(guildID GuildID) (*GuildMember, error)
GetCurrentUserGuilds Returns a guild member object for the current user. Requires the guilds.members.read OAuth2 scope.
https://discord.com/developers/docs/resources/user#get-current-user-guild-member
func (*Discord) GetCurrentUserGuilds ¶
func (s *Discord) GetCurrentUserGuilds(opts ...GetCurrentUserGuildsOption) ([]*Guild, error)
GetCurrentUserGuilds returns a list of partial guild objects the current user is a member of. Requires the guilds OAuth2 scope.
https://discord.com/developers/docs/resources/user#get-current-user-guilds
func (*Discord) GetGateway ¶
func (s *Discord) GetGateway() (*GetGatewayResponse, error)
func (*Discord) GetGatewayBot ¶
func (d *Discord) GetGatewayBot() (*GetGatewayResponse, error)
func (*Discord) GetGlobalApplicationCommands ¶
func (d *Discord) GetGlobalApplicationCommands(applicationID ApplicationID, withLocalization bool) ([]ApplicationCommand, error)
GetGlobalApplicationCommands fetch all of the global commands for your application. Returns an array of application command objects.
func (*Discord) GetGuildEmoji ¶
GetGuildEmoji returns an emoji object for the given guild and emoji ID.
https://discord.com/developers/docs/resources/emoji#get-guild-emoji
func (*Discord) ListGuildEmojis ¶
ListGuildEmojis returns a list of emoji objects for the given guild.
https://discord.com/developers/docs/resources/emoji#list-guild-emojis
func (*Discord) ModifyCurrentUser ¶
func (s *Discord) ModifyCurrentUser(opts ...ModifyCurrentUserOption) (*User, error)
ModifyCurrentUser modify the requester's user account settings. Returns a user object on success.
https://discord.com/developers/docs/resources/user#modify-current-user
type Emoji ¶
type Emoji struct { ID *EmojiID `json:"id"` Name *string `json:"name"` Roles []RoleID `json:"roles"` User *User `json:"user"` RequireColons *bool `json:"require_colons"` Managed *bool `json:"managed"` Animated *bool `json:"animated"` Available *bool `json:"available"` }
https://discord.com/developers/docs/resources/emoji#emoji-object
type ErrorResponse ¶
type ErrorResponse struct { Code int `json:"code"` Message string `json:"message"` Raw string `json:"-"` }
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type EventMessageCreate ¶
type EventMessageCreate Message
type EventReady ¶
type EventReady struct { V int `json:"v"` User User `json:"user"` Guilds []UnavailableGuild `json:"guilds"` SessionID string `json:"session_id"` Shard *[2]int `json:"shard"` Application Application `json:"application"` }
EventReady is dispatched when a client has completed the initial handshake with the gateway (for new sessions). The ready event can be the largest and most complex event the gateway will send, as it contains all the state required for a client to begin interacting with the rest of the platform.
https://discord.com/developers/docs/topics/gateway#ready-ready-event-fields
type GetCurrentUserGuildsOption ¶
type GetCurrentUserGuildsOption interface {
// contains filtered or unexported methods
}
type GetGatewayResponse ¶
type GetGatewayResponse struct { URL string `json:"url"` Shards int `json:"shards,omitempty"` SessionStartLimit *struct { Total int `json:"total"` Remaining int `json:"remaining"` ResetAfter int `json:"reset_after"` MaxConcurrency int `json:"max_concurrency"` } `json:"session_start_limit,omitempty"` }
type Guild ¶
type Guild struct { ID GuildID `json:"id"` Name string `json:"name"` Icon *string `json:"icon"` IconHash *string `json:"icon_hash"` Splash *string `json:"splash"` DiscoverySplash *string `json:"discovery_splash"` Owner bool `json:"owner,omitempty"` OwnerID UserID `json:"owner_id"` Permissions string `json:"permissions,omitempty"` AFKChannelID *ChannelID `json:"afk_channel_id"` AFKTimeout int `json:"afk_timeout"` WidgetEnabled bool `json:"widget_enabled"` WidgetChannelID *ChannelID `json:"widget_channel_id"` VerificationLevel int `json:"verification_level"` DefaultMessageNotifications int `json:"default_message_notifications"` ExplicitContentFilter int `json:"explicit_content_filter"` // TODO // Roles // Emojis // Features MFALevel int `json:"mfa_level"` ApplicationID *GuildID `json:"application_id"` SystemChannelID *ChannelID `json:"system_channel_id"` SystemChannelFlags int `json:"system_channel_flags"` RulesChannelID *ChannelID `json:"rules_channel_id"` JoinedAt time.Time `json:"joined_at,omitempty"` Large bool `json:"large,omitempty"` MemberCount int `json:"member_count,omitempty"` // TODO // VoiceStates // Members // Channels // Threads // Presences MaxPresences *int `json:"max_presences,omitempty"` MaxMembers int `json:"max_members,omitempty"` VanityURLCode *string `json:"vanity_url_code"` Description *string `json:"description"` Banner *string `json:"banner"` PremiumTier int `json:"premium_tier"` PremiumSubscriptionCount int `json:"premium_subscription_count,omitempty"` PreferredLocale string `json:"preferred_locale"` PublicUpdatesChannelID *ChannelID `json:"public_updates_channel_id"` MaxVideoChannelUsers int `json:"max_video_channel_users,omitempty"` ApproximateMemberCount int `json:"approximate_member_count,omitempty"` ApproximatePresenceCount int `json:"approximate_presence_count,omitempty"` // WelcomeScreen NSFWLevel int `json:"nsfw_level"` // StageInstances // Stickers // GuildScheduledEvents PremiumProgressbarEnabled bool `json:"premium_progressbar_enabled"` }
Guild
https://discord.com/developers/docs/resources/guild#guild-object
type GuildMember ¶
type GuildMember struct { User *User `json:"user"` Nick *string `json:"nick"` Avatar *string `json:"avatar"` //TODO //Roles []RoleID `json:"roles"` JoinedAt time.Time `json:"joined_at"` PremiumSince *time.Time `json:"premium_since"` Deaf bool `json:"deaf"` Mute bool `json:"mute"` Pending *bool `json:"pending"` Permissions *string CommunicationDisabledUntil *time.Time `json:"communication_disabled_until"` }
GuildMember
https://discord.com/developers/docs/resources/guild#guild-member-object
type Message ¶
type Message struct { ID MessageID `json:"id"` ChannelID ChannelID `json:"channel_id"` GuildID GuildID `json:"guild_id"` Author User `json:"author"` Member *GuildMember `json:"member"` Content string `json:"content"` Timestamp time.Time `json:"timestamp"` EditedTimestamp *time.Time `json:"edited_timestamp"` TTS bool `json:"tts"` MentionEveryone bool `json:"mention_everyone"` Mentions []User `json:"mentions"` //MentionRoles []RoleID `json:"mention_roles"` MentionChannels []ChannelID `json:"mention_channels"` //Attachments //TODO //Embeds //TODO //Reactions //TODO //Nonce //TODO Pinned bool `json:"pinned"` //WebhookID //TODO //Type //TODO //Activity //TODO //Application //TODO ApplicationID *ApplicationID `json:"application_id"` //MessageReference //TODO Flags int `json:"flags"` }
Message Represents a message sent in a channel within Discord.
https://discord.com/developers/docs/resources/channel#message-object
type MessageParams ¶
type MessageParams struct {
Content string `json:"content,omitempty"`
}
type ModifyCurrentUserOption ¶
type ModifyCurrentUserOption interface {
// contains filtered or unexported methods
}
type UnavailableGuild ¶
type UnavailableGuild struct {}
UnavailableGuild A partial guild object. Represents an Offline Guild, or a Guild whose information has not been provided through Guild Create events during the Gateway connect.
https://discord.com/developers/docs/resources/guild#unavailable-guild-object
type User ¶
type User struct { ID UserID `json:"id"` Username string `json:"username"` Discrim string `json:"discriminator"` Avatar *string `json:"avatar"` Bot *bool `json:"bot"` System *bool `json:"system"` MFAEnabled *bool `json:"mfa_enabled"` Banner *string `json:"banner"` AccentColor *int `json:"accent_color"` Locale *string `json:"locale"` Verified *bool `json:"verified"` Email *string `json:"email"` Flags *UserFlag `json:"flags"` PremiumType *int `json:"premium_type"` PublicFlags *int `json:"public_flags"` }
User
https://discord.com/developers/docs/resources/user#user-object
type UserFlag ¶
type UserFlag int
https://discord.com/developers/docs/resources/user#user-object-user-flags
const ( UserFlagStaff UserFlag = 1 << iota UserFlagPartner UserFlagHypesquad UserFlagBugHunterLevel1 UserFlagHypersquadOnlineHouse1 UserFlagHypersquadOnlineHouse2 UserFlagHypersquadOnlineHouse3 UserFlagPremiumEarlySupporter UserFlagTeamPseudoUser UserFlagBugHunterLevel2 UserFlagVerifiedBot UserFlagVerifiedDeveloper UserFlagCertifiedModerator UserFlagBotHTTPInteractions )
type WithAvatar ¶
type WithAvatar []byte
type WithBefore ¶
type WithBefore Snowflake
type WithUsername ¶
type WithUsername string