summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/matterbridge/discordgo/.travis.yml1
-rw-r--r--vendor/github.com/matterbridge/discordgo/endpoints.go6
-rw-r--r--vendor/github.com/matterbridge/discordgo/events.go2
-rw-r--r--vendor/github.com/matterbridge/discordgo/message.go10
-rw-r--r--vendor/github.com/matterbridge/discordgo/restapi.go94
-rw-r--r--vendor/github.com/matterbridge/discordgo/state.go95
-rw-r--r--vendor/github.com/matterbridge/discordgo/structs.go10
-rw-r--r--vendor/github.com/matterbridge/discordgo/user.go37
-rw-r--r--vendor/github.com/matterbridge/discordgo/voice.go2
-rw-r--r--vendor/modules.txt2
10 files changed, 236 insertions, 23 deletions
diff --git a/vendor/github.com/matterbridge/discordgo/.travis.yml b/vendor/github.com/matterbridge/discordgo/.travis.yml
index 6077b25a..c3cb680c 100644
--- a/vendor/github.com/matterbridge/discordgo/.travis.yml
+++ b/vendor/github.com/matterbridge/discordgo/.travis.yml
@@ -4,6 +4,7 @@ go:
- 1.12.x
- 1.13.x
- 1.14.x
+ - 1.15.x
env:
- GO111MODULE=on
install:
diff --git a/vendor/github.com/matterbridge/discordgo/endpoints.go b/vendor/github.com/matterbridge/discordgo/endpoints.go
index 3d0c614a..88663fe8 100644
--- a/vendor/github.com/matterbridge/discordgo/endpoints.go
+++ b/vendor/github.com/matterbridge/discordgo/endpoints.go
@@ -112,6 +112,8 @@ var (
EndpointChannelMessagesBulkDelete = func(cID string) string { return EndpointChannel(cID) + "/messages/bulk-delete" }
EndpointChannelMessagesPins = func(cID string) string { return EndpointChannel(cID) + "/pins" }
EndpointChannelMessagePin = func(cID, mID string) string { return EndpointChannel(cID) + "/pins/" + mID }
+ EndpointChannelMessageCrosspost = func(cID, mID string) string { return EndpointChannel(cID) + "/messages/" + mID + "/crosspost" }
+ EndpointChannelFollow = func(cID string) string { return EndpointChannel(cID) + "/followers" }
EndpointGroupIcon = func(cID, hash string) string { return EndpointCDNChannelIcons + cID + "/" + hash + ".png" }
@@ -139,8 +141,8 @@ var (
EndpointIntegrationsJoin = func(iID string) string { return EndpointAPI + "integrations/" + iID + "/join" }
- EndpointEmoji = func(eID string) string { return EndpointAPI + "emojis/" + eID + ".png" }
- EndpointEmojiAnimated = func(eID string) string { return EndpointAPI + "emojis/" + eID + ".gif" }
+ EndpointEmoji = func(eID string) string { return EndpointCDN + "emojis/" + eID + ".png" }
+ EndpointEmojiAnimated = func(eID string) string { return EndpointCDN + "emojis/" + eID + ".gif" }
EndpointOauth2 = EndpointAPI + "oauth2/"
EndpointApplications = EndpointOauth2 + "applications"
diff --git a/vendor/github.com/matterbridge/discordgo/events.go b/vendor/github.com/matterbridge/discordgo/events.go
index 99099c90..dd0e3d84 100644
--- a/vendor/github.com/matterbridge/discordgo/events.go
+++ b/vendor/github.com/matterbridge/discordgo/events.go
@@ -252,6 +252,8 @@ type VoiceServerUpdate struct {
// VoiceStateUpdate is the data for a VoiceStateUpdate event.
type VoiceStateUpdate struct {
*VoiceState
+ // BeforeUpdate will be nil if the VoiceState was not previously cached in the state cache.
+ BeforeUpdate *VoiceState `json:"-"`
}
// MessageDeleteBulk is the data for a MessageDeleteBulk event
diff --git a/vendor/github.com/matterbridge/discordgo/message.go b/vendor/github.com/matterbridge/discordgo/message.go
index f4b20fee..48589388 100644
--- a/vendor/github.com/matterbridge/discordgo/message.go
+++ b/vendor/github.com/matterbridge/discordgo/message.go
@@ -150,6 +150,7 @@ type MessageSend struct {
TTS bool `json:"tts"`
Files []*File `json:"-"`
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
+ Reference *MessageReference `json:"message_reference,omitempty"`
// TODO: Remove this when compatibility is not required.
File *File `json:"-"`
@@ -371,6 +372,15 @@ type MessageReference struct {
GuildID string `json:"guild_id"`
}
+// Reference returns MessageReference of given message
+func (m *Message) Reference() *MessageReference {
+ return &MessageReference{
+ GuildID: m.GuildID,
+ ChannelID: m.ChannelID,
+ MessageID: m.ID,
+ }
+}
+
// ContentWithMentionsReplaced will replace all @<id> mentions with the
// username of the mention.
func (m *Message) ContentWithMentionsReplaced() (content string) {
diff --git a/vendor/github.com/matterbridge/discordgo/restapi.go b/vendor/github.com/matterbridge/discordgo/restapi.go
index 6944e9f6..52f5b787 100644
--- a/vendor/github.com/matterbridge/discordgo/restapi.go
+++ b/vendor/github.com/matterbridge/discordgo/restapi.go
@@ -502,14 +502,12 @@ func (s *Session) UserChannelPermissions(userID, channelID string) (apermissions
}
}
- return memberPermissions(guild, channel, member), nil
+ return memberPermissions(guild, channel, userID, member.Roles), nil
}
// Calculates the permissions for a member.
// https://support.discord.com/hc/en-us/articles/206141927-How-is-the-permission-hierarchy-structured-
-func memberPermissions(guild *Guild, channel *Channel, member *Member) (apermissions int) {
- userID := member.User.ID
-
+func memberPermissions(guild *Guild, channel *Channel, userID string, roles []string) (apermissions int) {
if userID == guild.OwnerID {
apermissions = PermissionAll
return
@@ -523,7 +521,7 @@ func memberPermissions(guild *Guild, channel *Channel, member *Member) (apermiss
}
for _, role := range guild.Roles {
- for _, roleID := range member.Roles {
+ for _, roleID := range roles {
if role.ID == roleID {
apermissions |= role.Permissions
break
@@ -549,7 +547,7 @@ func memberPermissions(guild *Guild, channel *Channel, member *Member) (apermiss
// Member overwrites can override role overrides, so do two passes
for _, overwrite := range channel.PermissionOverwrites {
- for _, roleID := range member.Roles {
+ for _, roleID := range roles {
if overwrite.Type == "role" && roleID == overwrite.ID {
denies |= overwrite.Deny
allows |= overwrite.Allow
@@ -834,10 +832,6 @@ func (s *Session) GuildMemberEdit(guildID, userID string, roles []string) (err e
}{roles}
_, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
- if err != nil {
- return
- }
-
return
}
@@ -848,16 +842,11 @@ func (s *Session) GuildMemberEdit(guildID, userID string, roles []string) (err e
// NOTE : I am not entirely set on the name of this function and it may change
// prior to the final 1.0.0 release of Discordgo
func (s *Session) GuildMemberMove(guildID string, userID string, channelID *string) (err error) {
-
data := struct {
ChannelID *string `json:"channel_id"`
}{channelID}
_, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
- if err != nil {
- return
- }
-
return
}
@@ -865,6 +854,7 @@ func (s *Session) GuildMemberMove(guildID string, userID string, channelID *stri
// guildID : The ID of a guild
// userID : The ID of a user
// userID : The ID of a user or "@me" which is a shortcut of the current user ID
+// nickname : The nickname of the member, "" will reset their nickname
func (s *Session) GuildMemberNickname(guildID, userID, nickname string) (err error) {
data := struct {
@@ -879,6 +869,32 @@ func (s *Session) GuildMemberNickname(guildID, userID, nickname string) (err err
return
}
+// GuildMemberMute server mutes a guild member
+// guildID : The ID of a Guild.
+// userID : The ID of a User.
+// mute : boolean value for if the user should be muted
+func (s *Session) GuildMemberMute(guildID string, userID string, mute bool) (err error) {
+ data := struct {
+ Mute bool `json:"mute"`
+ }{mute}
+
+ _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
+ return
+}
+
+// GuildMemberDeafen server deafens a guild member
+// guildID : The ID of a Guild.
+// userID : The ID of a User.
+// deaf : boolean value for if the user should be deafened
+func (s *Session) GuildMemberDeafen(guildID string, userID string, deaf bool) (err error) {
+ data := struct {
+ Deaf bool `json:"deaf"`
+ }{deaf}
+
+ _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
+ return
+}
+
// GuildMemberRoleAdd adds the specified role to a given member
// guildID : The ID of a Guild.
// userID : The ID of a User.
@@ -1613,6 +1629,17 @@ func (s *Session) ChannelMessageSendEmbed(channelID string, embed *MessageEmbed)
})
}
+// ChannelMessageSendReply sends a message to the given channel with reference data.
+// channelID : The ID of a Channel.
+// content : The message to send.
+// reference : The message reference to send.
+func (s *Session) ChannelMessageSendReply(channelID string, content string, reference *MessageReference) (*Message, error) {
+ return s.ChannelMessageSendComplex(channelID, &MessageSend{
+ Content: content,
+ Reference: reference,
+ })
+}
+
// ChannelMessageEdit edits an existing message, replacing it entirely with
// the given content.
// channelID : The ID of a Channel
@@ -1790,6 +1817,43 @@ func (s *Session) ChannelPermissionDelete(channelID, targetID string) (err error
return
}
+// ChannelMessageCrosspost cross posts a message in a news channel to followers
+// of the channel
+// channelID : The ID of a Channel
+// messageID : The ID of a Message
+func (s *Session) ChannelMessageCrosspost(channelID, messageID string) (st *Message, err error) {
+
+ endpoint := EndpointChannelMessageCrosspost(channelID, messageID)
+
+ body, err := s.RequestWithBucketID("POST", endpoint, nil, endpoint)
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+}
+
+// ChannelNewsFollow follows a news channel in the targetID
+// channelID : The ID of a News Channel
+// targetID : The ID of a Channel where the News Channel should post to
+func (s *Session) ChannelNewsFollow(channelID, targetID string) (st *ChannelFollow, err error) {
+
+ endpoint := EndpointChannelFollow(channelID)
+
+ data := struct {
+ WebhookChannelID string `json:"webhook_channel_id"`
+ }{targetID}
+
+ body, err := s.RequestWithBucketID("POST", endpoint, data, endpoint)
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+}
+
// ------------------------------------------------------------------------------------------------
// Functions specific to Discord Invites
// ------------------------------------------------------------------------------------------------
diff --git a/vendor/github.com/matterbridge/discordgo/state.go b/vendor/github.com/matterbridge/discordgo/state.go
index 80bd8dfa..c89f8bb4 100644
--- a/vendor/github.com/matterbridge/discordgo/state.go
+++ b/vendor/github.com/matterbridge/discordgo/state.go
@@ -25,6 +25,11 @@ var ErrNilState = errors.New("state not instantiated, please use discordgo.New()
// requested is not found
var ErrStateNotFound = errors.New("state cache not found")
+// ErrMessageIncompletePermissions is returned when the message
+// requested for permissions does not contain enough data to
+// generate the permissions.
+var ErrMessageIncompletePermissions = errors.New("message incomplete, unable to determine permissions")
+
// A State contains the current known state.
// As discord sends this in a READY blob, it seems reasonable to simply
// use that struct as the data store.
@@ -727,6 +732,26 @@ func (s *State) voiceStateUpdate(update *VoiceStateUpdate) error {
return nil
}
+// VoiceState gets a VoiceState by guild and user ID.
+func (s *State) VoiceState(guildID, userID string) (*VoiceState, error) {
+ if s == nil {
+ return nil, ErrNilState
+ }
+
+ guild, err := s.Guild(guildID)
+ if err != nil {
+ return nil, err
+ }
+
+ for _, state := range guild.VoiceStates {
+ if state.UserID == userID {
+ return state, nil
+ }
+ }
+
+ return nil, ErrStateNotFound
+}
+
// Message gets a message by channel and message ID.
func (s *State) Message(channelID, messageID string) (*Message, error) {
if s == nil {
@@ -916,6 +941,13 @@ func (s *State) OnInterface(se *Session, i interface{}) (err error) {
}
case *VoiceStateUpdate:
if s.TrackVoice {
+ var old *VoiceState
+ old, err = s.VoiceState(t.GuildID, t.UserID)
+ if err == nil {
+ oldCopy := *old
+ t.BeforeUpdate = &oldCopy
+ }
+
err = s.voiceStateUpdate(t)
}
case *PresenceUpdate:
@@ -980,17 +1012,36 @@ func (s *State) UserChannelPermissions(userID, channelID string) (apermissions i
return
}
- if userID == guild.OwnerID {
- apermissions = PermissionAll
+ member, err := s.Member(guild.ID, userID)
+ if err != nil {
return
}
- member, err := s.Member(guild.ID, userID)
+ return memberPermissions(guild, channel, userID, member.Roles), nil
+}
+
+// MessagePermissions returns the permissions of the author of the message
+// in the channel in which it was sent.
+func (s *State) MessagePermissions(message *Message) (apermissions int, err error) {
+ if s == nil {
+ return 0, ErrNilState
+ }
+
+ if message.Author == nil || message.Member == nil {
+ return 0, ErrMessageIncompletePermissions
+ }
+
+ channel, err := s.Channel(message.ChannelID)
+ if err != nil {
+ return
+ }
+
+ guild, err := s.Guild(channel.GuildID)
if err != nil {
return
}
- return memberPermissions(guild, channel, member), nil
+ return memberPermissions(guild, channel, message.Author.ID, message.Member.Roles), nil
}
// UserColor returns the color of a user in a channel.
@@ -1018,11 +1069,39 @@ func (s *State) UserColor(userID, channelID string) int {
return 0
}
+ return firstRoleColorColor(guild, member.Roles)
+}
+
+// MessageColor returns the color of the author's name as displayed
+// in the client associated with this message.
+func (s *State) MessageColor(message *Message) int {
+ if s == nil {
+ return 0
+ }
+
+ if message.Member == nil || message.Member.Roles == nil {
+ return 0
+ }
+
+ channel, err := s.Channel(message.ChannelID)
+ if err != nil {
+ return 0
+ }
+
+ guild, err := s.Guild(channel.GuildID)
+ if err != nil {
+ return 0
+ }
+
+ return firstRoleColorColor(guild, message.Member.Roles)
+}
+
+func firstRoleColorColor(guild *Guild, memberRoles []string) int {
roles := Roles(guild.Roles)
sort.Sort(roles)
for _, role := range roles {
- for _, roleID := range member.Roles {
+ for _, roleID := range memberRoles {
if role.ID == roleID {
if role.Color != 0 {
return role.Color
@@ -1031,5 +1110,11 @@ func (s *State) UserColor(userID, channelID string) int {
}
}
+ for _, role := range roles {
+ if role.ID == guild.ID {
+ return role.Color
+ }
+ }
+
return 0
}
diff --git a/vendor/github.com/matterbridge/discordgo/structs.go b/vendor/github.com/matterbridge/discordgo/structs.go
index d7425e0b..c1a63788 100644
--- a/vendor/github.com/matterbridge/discordgo/structs.go
+++ b/vendor/github.com/matterbridge/discordgo/structs.go
@@ -316,6 +316,12 @@ type ChannelEdit struct {
RateLimitPerUser int `json:"rate_limit_per_user,omitempty"`
}
+// A ChannelFollow holds data returned after following a news channel
+type ChannelFollow struct {
+ ChannelID string `json:"channel_id"`
+ WebhookID string `json:"webhook_id"`
+}
+
// A PermissionOverwrite holds permission overwrite data for a Channel
type PermissionOverwrite struct {
ID string `json:"id"`
@@ -614,6 +620,7 @@ type GuildParams struct {
Icon string `json:"icon,omitempty"`
OwnerID string `json:"owner_id,omitempty"`
Splash string `json:"splash,omitempty"`
+ Banner string `json:"banner,omitempty"`
}
// A Role stores information about Discord guild member roles.
@@ -1057,6 +1064,9 @@ type Webhook struct {
Name string `json:"name"`
Avatar string `json:"avatar"`
Token string `json:"token"`
+
+ // ApplicationID is the bot/OAuth2 application that created this webhook
+ ApplicationID string `json:"application_id,omitempty"`
}
// WebhookType is the type of Webhook (see WebhookType* consts) in the Webhook struct
diff --git a/vendor/github.com/matterbridge/discordgo/user.go b/vendor/github.com/matterbridge/discordgo/user.go
index a9af31a9..b2894d5d 100644
--- a/vendor/github.com/matterbridge/discordgo/user.go
+++ b/vendor/github.com/matterbridge/discordgo/user.go
@@ -2,6 +2,27 @@ package discordgo
import "strings"
+// UserFlags is the flags of "user" (see UserFlags* consts)
+// https://discord.com/developers/docs/resources/user#user-object-user-flags
+type UserFlags int
+
+// Valid UserFlags values
+const (
+ UserFlagDiscordEmployee UserFlags = 1 << 0
+ UserFlagDiscordPartner = 1 << 1
+ UserFlagHypeSquadEvents = 1 << 2
+ UserFlagBugHunterLevel1 = 1 << 3
+ UserFlagHouseBravery = 1 << 6
+ UserFlagHouseBrilliance = 1 << 7
+ UserFlagHouseBalance = 1 << 8
+ UserFlagEarlySupporter = 1 << 9
+ UserFlagTeamUser = 1 << 10
+ UserFlagSystem = 1 << 12
+ UserFlagBugHunterLevel2 = 1 << 14
+ UserFlagVerifiedBot = 1 << 16
+ UserFlagVerifiedBotDeveloper = 1 << 17
+)
+
// A User stores all data for an individual Discord user.
type User struct {
// The ID of the user.
@@ -36,6 +57,22 @@ type User struct {
// Whether the user is a bot.
Bot bool `json:"bot"`
+
+ // The public flags on a user's account.
+ // This is a combination of bit masks; the presence of a certain flag can
+ // be checked by performing a bitwise AND between this int and the flag.
+ PublicFlags UserFlags `json:"public_flags"`
+
+ // The type of Nitro subscription on a user's account.
+ // Only available when the request is authorized via a Bearer token.
+ PremiumType int `json:"premium_type"`
+
+ // Whether the user is an Official Discord System user (part of the urgent message system).
+ System bool `json:"system"`
+
+ // The flags on a user's account.
+ // Only available when the request is authorized via a Bearer token.
+ Flags int `json:"flags"`
}
// String returns a unique identifier of the form username#discriminator
diff --git a/vendor/github.com/matterbridge/discordgo/voice.go b/vendor/github.com/matterbridge/discordgo/voice.go
index 586b783f..dbafd837 100644
--- a/vendor/github.com/matterbridge/discordgo/voice.go
+++ b/vendor/github.com/matterbridge/discordgo/voice.go
@@ -139,6 +139,7 @@ func (v *VoiceConnection) ChangeChannel(channelID string, mute, deaf bool) (err
func (v *VoiceConnection) Disconnect() (err error) {
// Send a OP4 with a nil channel to disconnect
+ v.Lock()
if v.sessionID != "" {
data := voiceChannelJoinOp{4, voiceChannelJoinData{&v.GuildID, nil, true, true}}
v.session.wsMutex.Lock()
@@ -146,6 +147,7 @@ func (v *VoiceConnection) Disconnect() (err error) {
v.session.wsMutex.Unlock()
v.sessionID = ""
}
+ v.Unlock()
// Close websocket and udp connections
v.Close()
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 50b97b74..6f60a023 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -130,7 +130,7 @@ github.com/matrix-org/gomatrix
github.com/matterbridge/Rocket.Chat.Go.SDK/models
github.com/matterbridge/Rocket.Chat.Go.SDK/realtime
github.com/matterbridge/Rocket.Chat.Go.SDK/rest
-# github.com/matterbridge/discordgo v0.22.0
+# github.com/matterbridge/discordgo v0.22.1
## explicit
github.com/matterbridge/discordgo
# github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible