|
@@ -15,6 +15,7 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"net/http"
|
|
|
+ "strings"
|
|
|
"sync"
|
|
|
"time"
|
|
|
|
|
@@ -82,6 +83,9 @@ type Session struct {
|
|
|
// The http client used for REST requests
|
|
|
Client *http.Client
|
|
|
|
|
|
+ // The user agent used for REST APIs
|
|
|
+ UserAgent string
|
|
|
+
|
|
|
// Stores the last HeartbeatAck that was recieved (in UTC)
|
|
|
LastHeartbeatAck time.Time
|
|
|
|
|
@@ -196,6 +200,8 @@ const (
|
|
|
ChannelTypeGuildVoice
|
|
|
ChannelTypeGroupDM
|
|
|
ChannelTypeGuildCategory
|
|
|
+ ChannelTypeGuildNews
|
|
|
+ ChannelTypeGuildStore
|
|
|
)
|
|
|
|
|
|
// A Channel holds all data related to an individual Discord channel.
|
|
@@ -220,6 +226,10 @@ type Channel struct {
|
|
|
// guaranteed to be an ID of a valid message.
|
|
|
LastMessageID string `json:"last_message_id"`
|
|
|
|
|
|
+ // The timestamp of the last pinned message in the channel.
|
|
|
+ // Empty if the channel has no pinned messages.
|
|
|
+ LastPinTimestamp Timestamp `json:"last_pin_timestamp"`
|
|
|
+
|
|
|
// Whether the channel is marked as NSFW.
|
|
|
NSFW bool `json:"nsfw"`
|
|
|
|
|
@@ -247,6 +257,10 @@ type Channel struct {
|
|
|
|
|
|
// The ID of the parent channel, if the channel is under a category
|
|
|
ParentID string `json:"parent_id"`
|
|
|
+
|
|
|
+ // Amount of seconds a user has to wait before sending another message (0-21600)
|
|
|
+ // bots, as well as users with the permission manage_messages or manage_channel, are unaffected
|
|
|
+ RateLimitPerUser int `json:"rate_limit_per_user"`
|
|
|
}
|
|
|
|
|
|
// Mention returns a string which mentions the channel
|
|
@@ -283,6 +297,7 @@ type Emoji struct {
|
|
|
Managed bool `json:"managed"`
|
|
|
RequireColons bool `json:"require_colons"`
|
|
|
Animated bool `json:"animated"`
|
|
|
+ Available bool `json:"available"`
|
|
|
}
|
|
|
|
|
|
// MessageFormat returns a correctly formatted Emoji for use in Message content and embeds
|
|
@@ -339,6 +354,17 @@ const (
|
|
|
MfaLevelElevated
|
|
|
)
|
|
|
|
|
|
+// PremiumTier type definition
|
|
|
+type PremiumTier int
|
|
|
+
|
|
|
+// Constants for PremiumTier levels from 0 to 3 inclusive
|
|
|
+const (
|
|
|
+ PremiumTierNone PremiumTier = iota
|
|
|
+ PremiumTier1
|
|
|
+ PremiumTier2
|
|
|
+ PremiumTier3
|
|
|
+)
|
|
|
+
|
|
|
// A Guild holds all data related to a specific Discord Guild. Guilds are also
|
|
|
// sometimes referred to as Servers in the Discord client.
|
|
|
type Guild struct {
|
|
@@ -443,6 +469,34 @@ type Guild struct {
|
|
|
|
|
|
// The Channel ID to which system messages are sent (eg join and leave messages)
|
|
|
SystemChannelID string `json:"system_channel_id"`
|
|
|
+
|
|
|
+ // the vanity url code for the guild
|
|
|
+ VanityURLCode string `json:"vanity_url_code"`
|
|
|
+
|
|
|
+ // the description for the guild
|
|
|
+ Description string `json:"description"`
|
|
|
+
|
|
|
+ // The hash of the guild's banner
|
|
|
+ Banner string `json:"banner"`
|
|
|
+
|
|
|
+ // The premium tier of the guild
|
|
|
+ PremiumTier PremiumTier `json:"premium_tier"`
|
|
|
+
|
|
|
+ // The total number of users currently boosting this server
|
|
|
+ PremiumSubscriptionCount int `json:"premium_subscription_count"`
|
|
|
+}
|
|
|
+
|
|
|
+// IconURL returns a URL to the guild's icon.
|
|
|
+func (g *Guild) IconURL() string {
|
|
|
+ if g.Icon == "" {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+
|
|
|
+ if strings.HasPrefix(g.Icon, "a_") {
|
|
|
+ return EndpointGuildIconAnimated(g.ID, g.Icon)
|
|
|
+ }
|
|
|
+
|
|
|
+ return EndpointGuildIcon(g.ID, g.Icon)
|
|
|
}
|
|
|
|
|
|
// A UserGuild holds a brief version of a Guild
|
|
@@ -617,6 +671,9 @@ type Member struct {
|
|
|
|
|
|
// A list of IDs of the roles which are possessed by the member.
|
|
|
Roles []string `json:"roles"`
|
|
|
+
|
|
|
+ // When the user used their Nitro boost on the server
|
|
|
+ PremiumSince Timestamp `json:"premium_since"`
|
|
|
}
|
|
|
|
|
|
// Mention creates a member mention
|
|
@@ -872,6 +929,7 @@ const (
|
|
|
PermissionVoiceDeafenMembers
|
|
|
PermissionVoiceMoveMembers
|
|
|
PermissionVoiceUseVAD
|
|
|
+ PermissionVoicePrioritySpeaker = 1 << (iota + 2)
|
|
|
)
|
|
|
|
|
|
// Constants for general management.
|
|
@@ -907,7 +965,8 @@ const (
|
|
|
PermissionVoiceMuteMembers |
|
|
|
PermissionVoiceDeafenMembers |
|
|
|
PermissionVoiceMoveMembers |
|
|
|
- PermissionVoiceUseVAD
|
|
|
+ PermissionVoiceUseVAD |
|
|
|
+ PermissionVoicePrioritySpeaker
|
|
|
PermissionAllChannel = PermissionAllText |
|
|
|
PermissionAllVoice |
|
|
|
PermissionCreateInstantInvite |
|