sonya

package
v0.0.0-...-47768c9 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

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"`
}

https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure

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"`
}

https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure

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"`
}

https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure

type ApplicationCommandOptionChoice

type ApplicationCommandOptionChoice struct {
	Name              string            `json:"name"`
	NameLocalizations map[string]string `json:"name_localizations,omitempty"`
	Value             any               `json:"value"`
}

https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure

type ApplicationCommandOptionType

type ApplicationCommandOptionType int

https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type

const (
	ApplicationCommandOptionTypeSubCommand ApplicationCommandOptionType = iota + 1
	ApplicationCommandOptionTypeSubCommandGroup
	ApplicationCommandOptionTypeString
	ApplicationCommandOptionTypeInteger
	ApplicationCommandOptionTypeBoolean
	ApplicationCommandOptionTypeUser
	ApplicationCommandOptionTypeChannel
	ApplicationCommandOptionTypeRole
	ApplicationCommandOptionTypeMentionable
	ApplicationCommandOptionTypeNumber
	ApplicationCommandOptionTypeAttachment
)

type ApplicationCommandType

type ApplicationCommandType int

https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types

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 ChannelID

type ChannelID Snowflake

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 New

func New(token string, isBot bool) *Discord

func (*Discord) AddHandler

func (d *Discord) AddHandler(f any)

func (*Discord) Close

func (d *Discord) Close() error

func (*Discord) Connect

func (d *Discord) Connect() error

Connect to the gateway

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 (d *Discord) DeleteGuildRole(guildID GuildID, roleID RoleID) error

func (*Discord) DeleteMessage

func (d *Discord) DeleteMessage(channelID ChannelID, messageID MessageID) error

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

func (d *Discord) GetChannel(channelID ChannelID) (*Channel, error)

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

func (s *Discord) GetCurrentUser() (*User, error)

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.

https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands

func (*Discord) GetGuildEmoji

func (s *Discord) GetGuildEmoji(guildID GuildID, emojiID EmojiID) (*Emoji, error)

GetGuildEmoji returns an emoji object for the given guild and emoji ID.

https://discord.com/developers/docs/resources/emoji#get-guild-emoji

func (*Discord) GetGuildRoles

func (d *Discord) GetGuildRoles(guildID GuildID) ([]*Role, error)

func (*Discord) GetUser

func (s *Discord) GetUser(id UserID) (*User, error)

GetUser returns a user object for a given user ID.

https://discord.com/developers/docs/resources/user#get-user

func (*Discord) ListGuildEmojis

func (s *Discord) ListGuildEmojis(guildID GuildID) ([]*Emoji, error)

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 EmojiID

type EmojiID Snowflake

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"`
	Unavailable        bool       `json:"unavailable,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 GuildID

type GuildID Snowflake

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 MessageID

type MessageID Snowflake

type MessageParams

type MessageParams struct {
	Content string `json:"content,omitempty"`
}

type ModifyCurrentUserOption

type ModifyCurrentUserOption interface {
	// contains filtered or unexported methods
}

type Role

type Role struct {
	ID    RoleID `json:"id"`
	Name  string `json:"name"`
	Color int    `json:"color"`
	Hoist bool   `json:"hoist"`
	// Icon TODO
	// UnicodeEmoji TODO
	Position    int    `json:"position"`
	Permissions string `json:"permissions"`
	Managed     bool   `json:"managed"`
	Mentionable bool   `json:"mentable"`
}

type RoleID

type RoleID Snowflake

type Snowflake

type Snowflake string

type UnavailableGuild

type UnavailableGuild struct {
	ID          GuildID `json:"id"`
	Unavailable bool    `json:"unavailable"`
}

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 UserID

type UserID Snowflake

type WithAfter

type WithAfter Snowflake

type WithAvatar

type WithAvatar []byte

type WithBefore

type WithBefore Snowflake

type WithLimit

type WithLimit int

type WithUsername

type WithUsername string

Jump to

Keyboard shortcuts

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