Skip to content

Commit

Permalink
Merge branch 'develop' (for the last time!)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonHoffman committed Jul 26, 2020
2 parents 56905d9 + c8139cc commit f7cb976
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 109 deletions.
2 changes: 1 addition & 1 deletion discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

// VERSION of DiscordGo, follows Semantic Versioning. (http://semver.org/)
const VERSION = "0.21.1"
const VERSION = "0.21.1-develop"

// ErrMFA will be risen by New when the user has 2FA.
var ErrMFA = errors.New("account has 2FA enabled")
Expand Down
45 changes: 37 additions & 8 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
)

// MessageType is the type of Message
// https://discord.com/developers/docs/resources/channel#message-object-message-types
type MessageType int

// Block contains the valid known MessageType values
Expand All @@ -33,6 +34,8 @@ const (
MessageTypeUserPremiumGuildSubscriptionTierTwo
MessageTypeUserPremiumGuildSubscriptionTierThree
MessageTypeChannelFollowAdd
MessageTypeGuildDiscoveryDisqualified
MessageTypeGuildDiscoveryRequalified
)

// A Message stores all data related to a specific Discord message.
Expand Down Expand Up @@ -117,9 +120,22 @@ type Message struct {
// The flags of the message, which describe extra features of a message.
// This is a combination of bit masks; the presence of a certain permission can
// be checked by performing a bitwise AND between this int and the flag.
Flags int `json:"flags"`
Flags MessageFlags `json:"flags"`
}

// MessageFlags is the flags of "message" (see MessageFlags* consts)
// https://discord.com/developers/docs/resources/channel#message-object-message-flags
type MessageFlags int

// Valid MessageFlags values
const (
MessageFlagsCrossPosted MessageFlags = 1 << iota
MessageFlagsIsCrossPosted
MessageFlagsSupressEmbeds
MessageFlagsSourceMessageDeleted
MessageFlagsUrgent
)

// File stores info about files you e.g. send in messages.
type File struct {
Name string
Expand Down Expand Up @@ -245,10 +261,9 @@ type MessageEmbedThumbnail struct {

// MessageEmbedVideo is a part of a MessageEmbed struct.
type MessageEmbedVideo struct {
URL string `json:"url,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
URL string `json:"url,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
}

// MessageEmbedProvider is a part of a MessageEmbed struct.
Expand All @@ -275,7 +290,7 @@ type MessageEmbedField struct {
// An MessageEmbed stores data for message embeds.
type MessageEmbed struct {
URL string `json:"url,omitempty"`
Type string `json:"type,omitempty"`
Type EmbedType `json:"type,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Expand All @@ -289,6 +304,20 @@ type MessageEmbed struct {
Fields []*MessageEmbedField `json:"fields,omitempty"`
}

// EmbedType is the type of embed
// https://discord.com/developers/docs/resources/channel#embed-object-embed-types
type EmbedType string

// Block of valid EmbedTypes
const (
EmbedTypeRich EmbedType = "rich"
EmbedTypeImage EmbedType = "image"
EmbedTypeVideo EmbedType = "video"
EmbedTypeGifv EmbedType = "gifv"
EmbedTypeArticle EmbedType = "article"
EmbedTypeLink EmbedType = "link"
)

// MessageReactions holds a reactions object for a message.
type MessageReactions struct {
Count int `json:"count"`
Expand All @@ -307,7 +336,7 @@ type MessageActivityType int

// Constants for the different types of Message Activity
const (
MessageActivityTypeJoin = iota + 1
MessageActivityTypeJoin MessageActivityType = iota + 1
MessageActivityTypeSpectate
MessageActivityTypeListen
MessageActivityTypeJoinRequest
Expand All @@ -319,7 +348,7 @@ type MessageFlag int
// Constants for the different bit offsets of Message Flags
const (
// This message has been published to subscribed channels (via Channel Following)
MessageFlagCrossposted = 1 << iota
MessageFlagCrossposted MessageFlag = 1 << iota
// This message originated from a message in another channel (via Channel Following)
MessageFlagIsCrosspost
// Do not include any embeds when serializing this message
Expand Down
28 changes: 28 additions & 0 deletions oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,33 @@ package discordgo
// Code specific to Discord OAuth2 Applications
// ------------------------------------------------------------------------------------------------

// The MembershipState represents whether the user is in the team or has been invited into it
type MembershipState int

// Constants for the different stages of the MembershipState
const (
MembershipStateInvited MembershipState = iota + 1
MembershipStateAccepted
)

// A TeamMember struct stores values for a single Team Member, extending the normal User data - note that the user field is partial
type TeamMember struct {
User *User `json:"user"`
TeamID string `json:"team_id"`
MembershipState MembershipState `json:"membership_state"`
Permissions []string `json:"permissions"`
}

// A Team struct stores the members of a Discord Developer Team as well as some metadata about it
type Team struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Icon string `json:"icon"`
OwnerID string `json:"owner_user_id"`
Members []*TeamMember `json:"members"`
}

// An Application struct stores values for a Discord OAuth2 Application
type Application struct {
ID string `json:"id,omitempty"`
Expand All @@ -27,6 +54,7 @@ type Application struct {
Flags int `json:"flags,omitempty"`
Owner *User `json:"owner"`
Bot *User `json:"bot"`
Team *Team `json:"team"`
}

// Application returns an Application structure of a specific Application
Expand Down
19 changes: 16 additions & 3 deletions restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,13 +844,13 @@ func (s *Session) GuildMemberEdit(guildID, userID string, roles []string) (err e
// GuildMemberMove moves a guild member from one voice channel to another/none
// guildID : The ID of a Guild.
// userID : The ID of a User.
// channelID : The ID of a channel to move user to, or null?
// channelID : The ID of a channel to move user to or nil to remove from voice channel
// 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, userID, channelID string) (err error) {
func (s *Session) GuildMemberMove(guildID string, userID string, channelID *string) (err error) {

data := struct {
ChannelID string `json:"channel_id"`
ChannelID *string `json:"channel_id"`
}{channelID}

_, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
Expand Down Expand Up @@ -1309,6 +1309,19 @@ func (s *Session) GuildAuditLog(guildID, userID, beforeID string, actionType, li
return
}

// GuildEmojis returns all emoji
// guildID : The ID of a Guild.
func (s *Session) GuildEmojis(guildID string) (emoji []*Emoji, err error) {

body, err := s.RequestWithBucketID("GET", EndpointGuildEmojis(guildID), nil, EndpointGuildEmojis(guildID))
if err != nil {
return
}

err = unmarshal(body, &emoji)
return
}

// GuildEmojiCreate creates a new emoji
// guildID : The ID of a Guild.
// name : The Name of the Emoji.
Expand Down
Loading

0 comments on commit f7cb976

Please sign in to comment.