Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threads #922

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c88e204
inital work on threads
phenpessoa May 3, 2021
6a16c9e
golint
phenpessoa May 3, 2021
d33dfbf
additional comment to the threads field on the guild structure
phenpessoa May 3, 2021
22f6ffb
add errors codes
phenpessoa May 3, 2021
a23749d
add missing message flags
phenpessoa May 3, 2021
91e8403
add endpoints
phenpessoa May 3, 2021
a4413fe
add restapi functions
phenpessoa May 3, 2021
e96672c
golint
phenpessoa May 3, 2021
c04bd96
update func names to be in sync with updated discord docs
phenpessoa May 4, 2021
c6fabbf
optional threadID for WebhookExecute
phenpessoa May 11, 2021
de9d0aa
fix LeaveThread description
phenpessoa May 16, 2021
331fa57
fix RemoveUserFromThread description
phenpessoa May 16, 2021
c8b6185
Merge remote-tracking branch 'upstream/master' into threads
phenpessoa Aug 2, 2021
000fbde
latest threads updates
phenpessoa Aug 2, 2021
d890873
state and archive duration update
phenpessoa Aug 2, 2021
d01681d
add member on ThreadMembersUpdate
phenpessoa Aug 3, 2021
f209ccc
requested changes
phenpessoa Aug 9, 2021
3ac6a06
fix threadmembersupdate
phenpessoa Aug 9, 2021
1c38a05
Merge remote-tracking branch 'upstream/master' into threads
phenpessoa Aug 18, 2021
adaed53
update webhooks
phenpessoa Aug 18, 2021
dd745c6
updates
phenpessoa Aug 18, 2021
265bbf5
reduce amount of loops
phenpessoa Aug 19, 2021
b319baf
make code more readable
phenpessoa Aug 19, 2021
c00b71f
better write threadmember and threadmembers update
phenpessoa Aug 19, 2021
a352138
requested changes
phenpessoa Aug 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 26 additions & 15 deletions endpoints.go
Expand Up @@ -14,7 +14,7 @@ package discordgo
import "strconv"

// APIVersion is the Discord API version used for the REST and Websocket API.
var APIVersion = "8"
var APIVersion = "9"

// Known Discord API Endpoints.
var (
Expand Down Expand Up @@ -102,20 +102,31 @@ var (
EndpointGuildEmojis = func(gID string) string { return EndpointGuilds + gID + "/emojis" }
EndpointGuildEmoji = func(gID, eID string) string { return EndpointGuilds + gID + "/emojis/" + eID }
EndpointGuildBanner = func(gID, hash string) string { return EndpointCDNBanners + gID + "/" + hash + ".png" }

EndpointChannel = func(cID string) string { return EndpointChannels + cID }
EndpointChannelPermissions = func(cID string) string { return EndpointChannels + cID + "/permissions" }
EndpointChannelPermission = func(cID, tID string) string { return EndpointChannels + cID + "/permissions/" + tID }
EndpointChannelInvites = func(cID string) string { return EndpointChannels + cID + "/invites" }
EndpointChannelTyping = func(cID string) string { return EndpointChannels + cID + "/typing" }
EndpointChannelMessages = func(cID string) string { return EndpointChannels + cID + "/messages" }
EndpointChannelMessage = func(cID, mID string) string { return EndpointChannels + cID + "/messages/" + mID }
EndpointChannelMessageAck = func(cID, mID string) string { return EndpointChannels + cID + "/messages/" + mID + "/ack" }
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" }
EndpointGuildActiveThreads = func(gID string) string { return EndpointGuilds + gID + "/threads/active" }

EndpointChannel = func(cID string) string { return EndpointChannels + cID }
EndpointChannelPermissions = func(cID string) string { return EndpointChannels + cID + "/permissions" }
EndpointChannelPermission = func(cID, tID string) string { return EndpointChannels + cID + "/permissions/" + tID }
EndpointChannelInvites = func(cID string) string { return EndpointChannels + cID + "/invites" }
EndpointChannelTyping = func(cID string) string { return EndpointChannels + cID + "/typing" }
EndpointChannelMessages = func(cID string) string { return EndpointChannels + cID + "/messages" }
EndpointChannelMessage = func(cID, mID string) string { return EndpointChannels + cID + "/messages/" + mID }
EndpointChannelMessageAck = func(cID, mID string) string { return EndpointChannels + cID + "/messages/" + mID + "/ack" }
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" }
EndpointChannelUsers = func(cID string) string { return EndpointChannel(cID) + "/users" }
EndpointThreads = func(cID string) string { return EndpointChannel(cID) + "/threads" }
EndpointThreadMembers = func(cID string) string { return EndpointChannel(cID) + "/thread-members/" }
EndpointArchivedThreads = func(cID string) string { return EndpointThreads(cID) + "/archived" }
EndpointPublicArchivedThreads = func(cID string) string { return EndpointArchivedThreads(cID) + "/public" }
EndpointPrivateArchivedThreads = func(cID string) string { return EndpointArchivedThreads(cID) + "/private" }
EndpointJoinedPrivateArchivedThreads = func(cID string) string { return EndpointChannelUsers(cID) + "/@me/threads/archived/private" }
EndpointChannelMessageThreads = func(cID, mID string) string {
return EndpointChannels + cID + "/messages/" + mID + "/threads"
}
EndpointChannelFollow = func(cID string) string { return EndpointChannel(cID) + "/followers" }

EndpointGroupIcon = func(cID, hash string) string { return EndpointCDNChannelIcons + cID + "/" + hash + ".png" }

Expand Down
144 changes: 144 additions & 0 deletions eventhandlers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions events.go
Expand Up @@ -292,3 +292,40 @@ type InteractionCreate struct {
func (i *InteractionCreate) UnmarshalJSON(b []byte) error {
return json.Unmarshal(b, &i.Interaction)
}

// ThreadCreate is the data for a ThreadCreate event.
type ThreadCreate struct {
*Channel
}

// ThreadUpdate is the data for a ThreadUpdate event.
type ThreadUpdate struct {
*Channel
}

// ThreadDelete is the data for a ThreadDelete event.
type ThreadDelete struct {
*Channel
}

// ThreadListSync is the data for a ThreadListSync event.
type ThreadListSync struct {
GuildID string `json:"guild_id"`
ChannelIDs []string `json:"channel_ids"`
Threads []*Channel `json:"threads"`
Members []*ThreadMember `json:"members"`
}

// ThreadMemberUpdate is the data for a ThreadMemberUpdate event.
type ThreadMemberUpdate struct {
*ThreadMember
}

// ThreadMembersUpdate is the data for a ThreadMembersUpdate event.
type ThreadMembersUpdate struct {
ID string `json:"id"`
GuildID string `json:"guild_id"`
MemberCount int `json:"member_count"`
AddedMembers []*ThreadMember `json:"added_members"`
RemovedMembersIDs []string `json:"removed_members_ids"`
}
47 changes: 29 additions & 18 deletions message.go
Expand Up @@ -22,24 +22,29 @@ type MessageType int

// Block contains the valid known MessageType values
const (
MessageTypeDefault MessageType = 0
MessageTypeRecipientAdd MessageType = 1
MessageTypeRecipientRemove MessageType = 2
MessageTypeCall MessageType = 3
MessageTypeChannelNameChange MessageType = 4
MessageTypeChannelIconChange MessageType = 5
MessageTypeChannelPinnedMessage MessageType = 6
MessageTypeGuildMemberJoin MessageType = 7
MessageTypeUserPremiumGuildSubscription MessageType = 8
MessageTypeUserPremiumGuildSubscriptionTierOne MessageType = 9
MessageTypeUserPremiumGuildSubscriptionTierTwo MessageType = 10
MessageTypeUserPremiumGuildSubscriptionTierThree MessageType = 11
MessageTypeChannelFollowAdd MessageType = 12
MessageTypeGuildDiscoveryDisqualified MessageType = 14
MessageTypeGuildDiscoveryRequalified MessageType = 15
MessageTypeReply MessageType = 19
MessageTypeChatInputCommand MessageType = 20
MessageTypeContextMenuCommand MessageType = 23
MessageTypeDefault MessageType = 0
MessageTypeRecipientAdd MessageType = 1
MessageTypeRecipientRemove MessageType = 2
MessageTypeCall MessageType = 3
MessageTypeChannelNameChange MessageType = 4
MessageTypeChannelIconChange MessageType = 5
MessageTypeChannelPinnedMessage MessageType = 6
MessageTypeGuildMemberJoin MessageType = 7
MessageTypeUserPremiumGuildSubscription MessageType = 8
MessageTypeUserPremiumGuildSubscriptionTierOne MessageType = 9
MessageTypeUserPremiumGuildSubscriptionTierTwo MessageType = 10
MessageTypeUserPremiumGuildSubscriptionTierThree MessageType = 11
MessageTypeChannelFollowAdd MessageType = 12
MessageTypeGuildDiscoveryDisqualified MessageType = 14
MessageTypeGuildDiscoveryRequalified MessageType = 15
MessageTypeGuildDiscoveryGracePeriodInitialWarning MessageType = 16
MessageTypeGuildDiscoveryGracePeriodFinalWarning MessageType = 17
MessageTypeThreadCreated MessageType = 18
MessageTypeReply MessageType = 19
MessageTypeChatInputCommand MessageType = 20
MessageTypeThreadStarterMessage MessageType = 21
MessageTypeInviteReminder MessageType = 22
MessageTypeContextMenuCommand MessageType = 23
)

// A Message stores all data related to a specific Discord message.
Expand Down Expand Up @@ -130,6 +135,9 @@ type Message struct {
// 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 MessageFlags `json:"flags"`

// The thread that was started from this message, includes thread member object
Thread *Channel `json:"thread"`
}

// UnmarshalJSON is a helper function to unmarshal the Message.
Expand Down Expand Up @@ -180,6 +188,9 @@ const (
MessageFlagsSupressEmbeds MessageFlags = 1 << 2
MessageFlagsSourceMessageDeleted MessageFlags = 1 << 3
MessageFlagsUrgent MessageFlags = 1 << 4
MessageFlagsHasThread MessageFlags = 1 << 5
MessageFlagsEphemeral MessageFlags = 1 << 6
MessageFlagsLoading MessageFlags = 1 << 7
)

// File stores info about files you e.g. send in messages.
Expand Down