diff options
author | Wim <wim@42.be> | 2018-02-14 22:22:35 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-02-14 22:22:35 +0100 |
commit | fd0fe3390b3c57da329aeda014e87f9a0a6f7fc0 (patch) | |
tree | f3c4e5eca8b16d27c6def1d17053b6a6db1d79c0 /vendor/github.com/bwmarrin/discordgo/structs.go | |
parent | 2522158127d2d55c992ddd2201e19de1907b0f67 (diff) | |
download | matterbridge-msglm-fd0fe3390b3c57da329aeda014e87f9a0a6f7fc0.tar.gz matterbridge-msglm-fd0fe3390b3c57da329aeda014e87f9a0a6f7fc0.tar.bz2 matterbridge-msglm-fd0fe3390b3c57da329aeda014e87f9a0a6f7fc0.zip |
Update vendor bwmarrin/discordgo
Diffstat (limited to 'vendor/github.com/bwmarrin/discordgo/structs.go')
-rw-r--r-- | vendor/github.com/bwmarrin/discordgo/structs.go | 102 |
1 files changed, 64 insertions, 38 deletions
diff --git a/vendor/github.com/bwmarrin/discordgo/structs.go b/vendor/github.com/bwmarrin/discordgo/structs.go index c3e39566..19d2bad7 100644 --- a/vendor/github.com/bwmarrin/discordgo/structs.go +++ b/vendor/github.com/bwmarrin/discordgo/structs.go @@ -14,7 +14,6 @@ package discordgo import ( "encoding/json" "net/http" - "strconv" "sync" "time" @@ -85,6 +84,9 @@ type Session struct { // Stores the last HeartbeatAck that was recieved (in UTC) LastHeartbeatAck time.Time + // used to deal with rate limits + Ratelimiter *RateLimiter + // Event handlers handlersMu sync.RWMutex handlers map[string][]*eventHandlerInstance @@ -96,9 +98,6 @@ type Session struct { // When nil, the session is not listening. listening chan interface{} - // used to deal with rate limits - ratelimiter *RateLimiter - // sequence tracks the current gateway api websocket sequence number sequence *int64 @@ -143,9 +142,9 @@ type Invite struct { MaxAge int `json:"max_age"` Uses int `json:"uses"` MaxUses int `json:"max_uses"` - XkcdPass string `json:"xkcdpass"` Revoked bool `json:"revoked"` Temporary bool `json:"temporary"` + Unique bool `json:"unique"` } // ChannelType is the type of a Channel @@ -171,9 +170,22 @@ type Channel struct { NSFW bool `json:"nsfw"` Position int `json:"position"` Bitrate int `json:"bitrate"` - Recipients []*User `json:"recipient"` + Recipients []*User `json:"recipients"` Messages []*Message `json:"-"` PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites"` + ParentID string `json:"parent_id"` +} + +// A ChannelEdit holds Channel Feild data for a channel edit. +type ChannelEdit struct { + Name string `json:"name,omitempty"` + Topic string `json:"topic,omitempty"` + NSFW bool `json:"nsfw,omitempty"` + Position int `json:"position"` + Bitrate int `json:"bitrate,omitempty"` + UserLimit int `json:"user_limit,omitempty"` + PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"` + ParentID string `json:"parent_id,omitempty"` } // A PermissionOverwrite holds permission overwrite data for a Channel @@ -191,6 +203,7 @@ type Emoji struct { Roles []string `json:"roles"` Managed bool `json:"managed"` RequireColons bool `json:"require_colons"` + Animated bool `json:"animated"` } // APIName returns an correctly formatted API name for use in the MessageReactions endpoints. @@ -204,7 +217,7 @@ func (e *Emoji) APIName() string { return e.ID } -// VerificationLevel type defination +// VerificationLevel type definition type VerificationLevel int // Constants for VerificationLevel levels from 0 to 3 inclusive @@ -314,45 +327,58 @@ type Presence struct { Since *int `json:"since"` } +// GameType is the type of "game" (see GameType* consts) in the Game struct +type GameType int + +// Valid GameType values +const ( + GameTypeGame GameType = iota + GameTypeStreaming +) + // A Game struct holds the name of the "playing .." game for a user type Game struct { - Name string `json:"name"` - Type int `json:"type"` - URL string `json:"url,omitempty"` -} - -// UnmarshalJSON unmarshals json to Game struct -func (g *Game) UnmarshalJSON(bytes []byte) error { - temp := &struct { - Name json.Number `json:"name"` - Type json.RawMessage `json:"type"` - URL string `json:"url"` + Name string `json:"name"` + Type GameType `json:"type"` + URL string `json:"url,omitempty"` + Details string `json:"details,omitempty"` + State string `json:"state,omitempty"` + TimeStamps TimeStamps `json:"timestamps,omitempty"` + Assets Assets `json:"assets,omitempty"` + ApplicationID string `json:"application_id,omitempty"` + Instance int8 `json:"instance,omitempty"` + // TODO: Party and Secrets (unknown structure) +} + +// A TimeStamps struct contains start and end times used in the rich presence "playing .." Game +type TimeStamps struct { + EndTimestamp int64 `json:"end,omitempty"` + StartTimestamp int64 `json:"start,omitempty"` +} + +// UnmarshalJSON unmarshals JSON into TimeStamps struct +func (t *TimeStamps) UnmarshalJSON(b []byte) error { + temp := struct { + End float64 `json:"end,omitempty"` + Start float64 `json:"start,omitempty"` }{} - err := json.Unmarshal(bytes, temp) + err := json.Unmarshal(b, &temp) if err != nil { return err } - g.URL = temp.URL - g.Name = temp.Name.String() - - if temp.Type != nil { - err = json.Unmarshal(temp.Type, &g.Type) - if err == nil { - return nil - } - - s := "" - err = json.Unmarshal(temp.Type, &s) - if err == nil { - g.Type, err = strconv.Atoi(s) - } - - return err - } - + t.EndTimestamp = int64(temp.End) + t.StartTimestamp = int64(temp.Start) return nil } +// An Assets struct contains assets and labels used in the rich presence "playing .." Game +type Assets struct { + LargeImageID string `json:"large_image,omitempty"` + SmallImageID string `json:"small_image,omitempty"` + LargeText string `json:"large_text,omitempty"` + SmallText string `json:"small_text,omitempty"` +} + // A Member stores user information for Guild members. type Member struct { GuildID string `json:"guild_id"` @@ -383,7 +409,7 @@ type Settings struct { DeveloperMode bool `json:"developer_mode"` } -// Status type defination +// Status type definition type Status string // Constants for Status with the different current available status |