Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- type ClientState
- type Data
- type Embed
- type EmbedAuthor
- type EmbedField
- type EmbedFooter
- type EmbedProvider
- type Event
- type HandlerFunc
- type Identify
- type Message
- type MessageRoute
- func (rt *MessageRoute) Author(id string) *MessageRoute
- func (rt *MessageRoute) Channel(id string) *MessageRoute
- func (rt *MessageRoute) ContentContains(s string) *MessageRoute
- func (rt *MessageRoute) ContentMatchesExp(exp *regexp.Regexp) *MessageRoute
- func (rt *MessageRoute) EventType(et string) *MessageRoute
- func (rt *MessageRoute) Handler(h func(msg Message))
- func (rt *MessageRoute) HasEmbeds(b bool) *MessageRoute
- func (rt *MessageRoute) Mentions(id string) *MessageRoute
- func (rt *MessageRoute) RespondsTo(id string) *MessageRoute
- type MessageRouter
- type Presence
- type Properties
- type User
- type WSConn
- type WSConnOpts
Constants ¶
View Source
const ( EmbedTypeRich = "rich" EmbedTypeImage = "image" EmbedTypeVideo = "video" EmbedTypeGifVideo = "gifv" EmbedTypeArticle = "article" EmbedTypeLink = "link" )
View Source
const ( MessageTypeDefault = iota MessageTypeRecipientAdd MessageTypeRecipientRemove MessageTypeCall MessageTypeChannelNameChange MessageTypeChannelIconChange MessageTypeChannelPinnedMessage MessageTypeGuildMemberJoin MessageTypeUserPremiumGuildSubscription MessageTypeUserPremiumGuildSubscriptionTier1 MessageTypeUserPremiumGuildSubscriptionTier2 MessageTypeUserPremiumGuildSubscriptionTier3 MessageTypeChannelFollowAdd MessageTypeGuildDiscoveryDisqualified = iota + 1 MessageTypeGuildDiscoveryRequalified MessageTypeReply = iota + 4 MessageTypeApplicationCommand )
View Source
const ( OpcodeDispatch = iota OpcodeHeartbeat OpcodeIdentify OpcodePresenceUpdate OpcodeVoiceStateUpdate OpcodeResume = iota + 1 OpcodeReconnect OpcodeRequestGuildMembers OpcodeInvalidSession OpcodeHello OpcodeHeartbeatACK )
View Source
const ( EventNameMessageCreate = "MESSAGE_CREATE" EventNameMessageUpdate = "MESSAGE_UPDATE" EventNameReady = "READY" EventNameResumed = "RESUMED" )
View Source
const ( IntentGuilds = 1 << iota IntentGuildMembers IntentGuildBans IntentGuildEmojis IntentGuildIntegrations IntentGuildWebhooks IntentGuildInvites IntentGuildVoiceStates IntentGuildPresences IntentGuildMessages IntentGuildMessageReactions IntentGuildMessageTyping IntentDirectMessages IntentDirectMessageReactions IntentDirectMessageTyping )
View Source
const ( UserFlagDiscordEmployee = 1 << iota UserFlagPartneredServerOwner UserFlagHypeSquadEvents UserFlagBugHunterLevel1 UserFlagHouseBravery UserFlagHouseBrilliance UserFlagHouseBalance UserFlagEarlySupporter UserFlagTeamUser UserFlagSystem UserFlagBugHunterLevel2 UserFlagVerifiedBot UserFlagEarlyVerifiedBotDeveloper )
View Source
const ( PremiumTypeNone = iota PremiumTypeNitroClassic PremiumTypeNitro )
Variables ¶
View Source
var ( ErrForbidden = fmt.Errorf("forbidden, you may not have permission to send in the channel (i.e. you aren't in the server or don't have send message permissions in the channel), your account might need verification, or your ip address may have been blocked") ErrTooManyRequests = fmt.Errorf("you are being rate limited, try waiting some time and trying again") ErrNotFound = fmt.Errorf("not found, make sure your channel id is valid") ErrIntervalServer = fmt.Errorf("remote server interval server error") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
func (Client) CurrentUser ¶
CurrentUser sends a http request to Discord and returns a User struct based on the response. This method should only be used if the user information was changed between when you created the client and now. Otherwise, this is also available in the User field of the Client struct.
type ClientState ¶
type Embed ¶
type Embed struct { Title string `json:"title,omitempty"` // The type of embed. Always EmbedTypeRich for webhook embeds. Type string `json:"type,omitempty"` Description string `json:"description,omitempty"` URL string `json:"url,omitempty"` // The time at which the embed was sent. Time time.Time `json:"timestamp,omitempty"` // The color code of the embed. Color int `json:"color,omitempty"` Provider EmbedProvider `json:"provider,omitempty"` Author EmbedAuthor `json:"author,omitempty"` Fields []EmbedField `json:"fields,omitempty"` }
type EmbedAuthor ¶
type EmbedField ¶
type EmbedFooter ¶
type EmbedFooter struct {}
type EmbedProvider ¶
type HandlerFunc ¶
type HandlerFunc func(msg Message)
type Identify ¶
type Identify struct { Token string `json:"token"` Properties Properties `json:"properties"` Capabilities int `json:"capabilities,omitempty"` Compress bool `json:"compress"` Presence Presence `json:"presence"` }
type Message ¶
type Message struct { // The ID of the message. ID string `json:"id,omitempty"` // The ID of the channel the message was sent in. ChannelID string `json:"channel_id,omitempty"` // The ID of the guild the message was sent in. GuildID string `json:"guild_id,omitempty"` // The author of the message. Not guaranteed to be a valid user. // // The author object follows the structure of the User object, but is only a // valid user in the case where the message is generated by a user or bot // user. If the message is generated by a webhook, the author object // corresponds to the webhook's ID, username, and avatar. You can tell if a // message is generated by a webhook by checking for the WebhookID on the // message object. Author User `json:"author,omitempty"` // The contents of the message. Content string `json:"content,omitempty"` // When the message was sent. Time time.Time `json:"timestamp,omitempty"` // When this message was edited (default value if never). EditedTime time.Time `json:"edited_timestamp,omitempty"` // Whether this is a TTS message. TTS bool `json:"tts,omitempty"` // Whether this message mentions everyone. MentionEveryone bool `json:"mention_everyone,omitempty"` // Users specifically mentions in the message. Mentions []User `json:"mentions"` // The type of message. Type int `json:"type,omitempty"` // Whether the message is pinned. Pinned bool `json:"pinned,omitempty"` // Any embedded content. Embeds []Embed `json:"embeds,omitempty"` // If the message is generated by a webhook, this is the webhook's ID. WebhookID string `json:"webhook_id,omitempty"` // The message which this message references. This field is only set for // messages with type MessageTypeReply. // // If the message is a reply but this field is not set, either the Discord // backend did not attempt to fetch the message that was being replied to, // or the referenced message was deleted. ReferencedMessage *Message `json:"referenced_message,omitempty"` }
type MessageRoute ¶
type MessageRoute struct {
// contains filtered or unexported fields
}
func (*MessageRoute) Author ¶
func (rt *MessageRoute) Author(id string) *MessageRoute
func (*MessageRoute) Channel ¶
func (rt *MessageRoute) Channel(id string) *MessageRoute
func (*MessageRoute) ContentContains ¶
func (rt *MessageRoute) ContentContains(s string) *MessageRoute
func (*MessageRoute) ContentMatchesExp ¶
func (rt *MessageRoute) ContentMatchesExp(exp *regexp.Regexp) *MessageRoute
func (*MessageRoute) EventType ¶
func (rt *MessageRoute) EventType(et string) *MessageRoute
func (*MessageRoute) Handler ¶
func (rt *MessageRoute) Handler(h func(msg Message))
func (*MessageRoute) HasEmbeds ¶
func (rt *MessageRoute) HasEmbeds(b bool) *MessageRoute
func (*MessageRoute) Mentions ¶
func (rt *MessageRoute) Mentions(id string) *MessageRoute
func (*MessageRoute) RespondsTo ¶
func (rt *MessageRoute) RespondsTo(id string) *MessageRoute
type MessageRouter ¶
type MessageRouter struct {
// contains filtered or unexported fields
}
func (*MessageRouter) Middleware ¶
func (rtr *MessageRouter) Middleware(mw func(h HandlerFunc) HandlerFunc)
func (*MessageRouter) NewRoute ¶
func (rtr *MessageRouter) NewRoute() *MessageRoute
type Properties ¶
type Properties struct { OS string `json:"os,omitempty"` Browser string `json:"browser,omitempty"` Device string `json:"device,omitempty"` BrowserUserAgent string `json:"browser_user_agent,omitempty"` BrowserVersion string `json:"browser_version,omitempty"` OSVersion string `json:"os_version,omitempty"` Referrer string `json:"referrer,omitempty"` ReferringDomain string `json:"referring_domain,omitempty"` ReferrerCurrent string `json:"referrer_current,omitempty"` ReferringDomainCurrent string `json:"referring_domain_current,omitempty"` ReleaseChannel string `json:"release_channel,omitempty"` ClientBuildNumber int `json:"client_build_number,omitempty"` }
type User ¶
type User struct { // The user's ID. ID string `json:"id"` Username string `json:"username"` // The user's 4-digit Discord-tag. Discriminator string `json:"discriminator"` // Whether the user belongs to an OAuth2 application. Bot bool `json:"bot,omitempty"` // The user's avatar hash. Avatar string `json:"avatar"` // Whether the user is an official Discord system user (part of the urgent // message system). System bool `json:"system,omitempty"` // Whether the user has two factor authentication enabled on their account. MFA bool `json:"mfa_enabled,omitempty"` // The user's chosen language option. Locale string `json:"locale,omitempty"` VerifiedEmail bool `json:"verified,omitempty"` Email string `json:"email,omitempty"` Flags int `json:"flags,omitempty"` // The type of Nitro subscription on a user's account. PremiumType int `json:"premium_type,omitempty"` PublicFlags int `json:"public_flags,omitempty"` }
type WSConnOpts ¶
type WSConnOpts struct { MessageRouter *MessageRouter FatalHandler func(err *websocket.CloseError) }
Click to show internal directories.
Click to hide internal directories.