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

Add Guild Scheduled Event Support #1032

Merged
merged 52 commits into from Feb 27, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
2b3d018
Add Guild Scheduled Events support
42atomys Nov 20, 2021
84aaa03
Add missing Indents for Guild Scheduled Events
42atomys Nov 20, 2021
677fcc2
Merge remote-tracking branch 'upstream/master'
42atomys Feb 18, 2022
1bcc001
fix: Do update from new schedules updates and repository updates
42atomys Feb 18, 2022
6554e26
doc: Add missing documentation on const
42atomys Feb 18, 2022
260e8ca
doc: Add missing documentation on events struct
42atomys Feb 18, 2022
d7dc906
tests: Add a Skip condition when dgBot is not set to prevent segfault
42atomys Feb 18, 2022
1359c13
fix: Resolve merge conflicts
42atomys Feb 21, 2022
b08a6e3
fix: Somes changes following the last review steps
42atomys Feb 22, 2022
5fa6423
docs: Add an example to manipulate GuildScheduledEvent
42atomys Feb 22, 2022
90751ec
clean: Remove useless pointers on struct used to retrieve data
42atomys Feb 22, 2022
2aef679
tests: Test extra query params on GuildScheduledEventUsers requests
42atomys Feb 22, 2022
78676f4
clean: Remove unused variables
42atomys Feb 22, 2022
ea5dc9a
feat: Add nullable types to provide null value to Discord API when is…
42atomys Feb 23, 2022
4498cb6
feat: Use NullableString in ScheduledEvents
42atomys Feb 23, 2022
e02240e
docs: Add example for usage of NullableString
42atomys Feb 23, 2022
f5cac02
Merge branch 'bwmarrin:master' into master
42atomys Feb 23, 2022
64f87b7
upstream: Update upstream
42atomys Feb 27, 2022
d15da2a
Update structs.go
42atomys Feb 27, 2022
ad67d7d
Update restapi.go
42atomys Feb 27, 2022
88aa388
fix: Review changes to move back nullable string into a simple Marsha…
42atomys Feb 27, 2022
92e6ce3
Merge branch 'master' of github.com:41Atomys/discordgo
42atomys Feb 27, 2022
e4df643
fix: Remove NullString on tests and examples
42atomys Feb 27, 2022
3a971f7
doc: Add missing doc
42atomys Feb 27, 2022
1fe6066
Update structs.go
42atomys Feb 27, 2022
f52727a
Merge branch 'master' of github.com:42Atomys/discordgo
42atomys Feb 27, 2022
795cd27
fix: misunderstood MarhsalJSON
42atomys Feb 27, 2022
5bbf72e
fix: Follow the convention of discordgo on url.Values
42atomys Feb 27, 2022
d8ab9d9
Update examples/scheduled_events/main.go
42atomys Feb 27, 2022
1176142
changes: use conditional instead on Sprintf
42atomys Feb 27, 2022
a905f17
fix: Add missing status on Params
42atomys Feb 27, 2022
e9a2fe1
Update structs.go
42atomys Feb 27, 2022
fae5682
Update structs.go
42atomys Feb 27, 2022
ee6b0ea
changes: Move flag.Parse inside the init function
42atomys Feb 27, 2022
be01232
fix: remove null statement of test suite
42atomys Feb 27, 2022
6b3074d
fix: Rewrite Marshal of GuildScheduledEventParams to prevent a stack …
42atomys Feb 27, 2022
5f37849
clean: Remove unused Intents
42atomys Feb 27, 2022
b289ecd
Update restapi.go
42atomys Feb 27, 2022
f82eff0
Update restapi.go
42atomys Feb 27, 2022
b542383
Update restapi.go
42atomys Feb 27, 2022
45008f8
doc: polish the documentation
42atomys Feb 27, 2022
35ffaad
Merge branch 'master' of github.com:42Atomys/discordgo
42atomys Feb 27, 2022
0a42322
clean: Final polish code
42atomys Feb 27, 2022
35c4db9
doc: Add information about 1:1 usage
42atomys Feb 27, 2022
4e0be03
Update discord_test.go
42atomys Feb 27, 2022
204b188
doc: remove unnecessary additional infos
42atomys Feb 27, 2022
2b67cfb
Update structs.go
42atomys Feb 27, 2022
675c43b
Update discord_test.go
42atomys Feb 27, 2022
c1dc39a
Update restapi.go
42atomys Feb 27, 2022
b62a67a
chore(examples/scheduled_events): removed NullString comment
FedorLap2006 Feb 27, 2022
dcc7444
fix(structs): grammar in comment to EntityType
FedorLap2006 Feb 27, 2022
a1e0044
fix: run gofmt
42atomys Feb 27, 2022
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
53 changes: 28 additions & 25 deletions endpoints.go
Expand Up @@ -77,31 +77,34 @@ var (
EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" }
EndpointUserNotes = func(uID string) string { return EndpointUsers + "@me/notes/" + uID }

EndpointGuild = func(gID string) string { return EndpointGuilds + gID }
EndpointGuildPreview = func(gID string) string { return EndpointGuilds + gID + "/preview" }
EndpointGuildChannels = func(gID string) string { return EndpointGuilds + gID + "/channels" }
EndpointGuildMembers = func(gID string) string { return EndpointGuilds + gID + "/members" }
EndpointGuildMember = func(gID, uID string) string { return EndpointGuilds + gID + "/members/" + uID }
EndpointGuildMemberRole = func(gID, uID, rID string) string { return EndpointGuilds + gID + "/members/" + uID + "/roles/" + rID }
EndpointGuildBans = func(gID string) string { return EndpointGuilds + gID + "/bans" }
EndpointGuildBan = func(gID, uID string) string { return EndpointGuilds + gID + "/bans/" + uID }
EndpointGuildIntegrations = func(gID string) string { return EndpointGuilds + gID + "/integrations" }
EndpointGuildIntegration = func(gID, iID string) string { return EndpointGuilds + gID + "/integrations/" + iID }
EndpointGuildIntegrationSync = func(gID, iID string) string { return EndpointGuilds + gID + "/integrations/" + iID + "/sync" }
EndpointGuildRoles = func(gID string) string { return EndpointGuilds + gID + "/roles" }
EndpointGuildRole = func(gID, rID string) string { return EndpointGuilds + gID + "/roles/" + rID }
EndpointGuildInvites = func(gID string) string { return EndpointGuilds + gID + "/invites" }
EndpointGuildWidget = func(gID string) string { return EndpointGuilds + gID + "/widget" }
EndpointGuildEmbed = EndpointGuildWidget
EndpointGuildPrune = func(gID string) string { return EndpointGuilds + gID + "/prune" }
EndpointGuildIcon = func(gID, hash string) string { return EndpointCDNIcons + gID + "/" + hash + ".png" }
EndpointGuildIconAnimated = func(gID, hash string) string { return EndpointCDNIcons + gID + "/" + hash + ".gif" }
EndpointGuildSplash = func(gID, hash string) string { return EndpointCDNSplashes + gID + "/" + hash + ".png" }
EndpointGuildWebhooks = func(gID string) string { return EndpointGuilds + gID + "/webhooks" }
EndpointGuildAuditLogs = func(gID string) string { return EndpointGuilds + gID + "/audit-logs" }
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" }
EndpointGuild = func(gID string) string { return EndpointGuilds + gID }
EndpointGuildPreview = func(gID string) string { return EndpointGuilds + gID + "/preview" }
EndpointGuildChannels = func(gID string) string { return EndpointGuilds + gID + "/channels" }
EndpointGuildMembers = func(gID string) string { return EndpointGuilds + gID + "/members" }
EndpointGuildMember = func(gID, uID string) string { return EndpointGuilds + gID + "/members/" + uID }
EndpointGuildMemberRole = func(gID, uID, rID string) string { return EndpointGuilds + gID + "/members/" + uID + "/roles/" + rID }
EndpointGuildBans = func(gID string) string { return EndpointGuilds + gID + "/bans" }
EndpointGuildBan = func(gID, uID string) string { return EndpointGuilds + gID + "/bans/" + uID }
EndpointGuildIntegrations = func(gID string) string { return EndpointGuilds + gID + "/integrations" }
EndpointGuildIntegration = func(gID, iID string) string { return EndpointGuilds + gID + "/integrations/" + iID }
EndpointGuildIntegrationSync = func(gID, iID string) string { return EndpointGuilds + gID + "/integrations/" + iID + "/sync" }
EndpointGuildRoles = func(gID string) string { return EndpointGuilds + gID + "/roles" }
EndpointGuildRole = func(gID, rID string) string { return EndpointGuilds + gID + "/roles/" + rID }
EndpointGuildInvites = func(gID string) string { return EndpointGuilds + gID + "/invites" }
EndpointGuildWidget = func(gID string) string { return EndpointGuilds + gID + "/widget" }
EndpointGuildEmbed = EndpointGuildWidget
EndpointGuildPrune = func(gID string) string { return EndpointGuilds + gID + "/prune" }
EndpointGuildIcon = func(gID, hash string) string { return EndpointCDNIcons + gID + "/" + hash + ".png" }
EndpointGuildIconAnimated = func(gID, hash string) string { return EndpointCDNIcons + gID + "/" + hash + ".gif" }
EndpointGuildSplash = func(gID, hash string) string { return EndpointCDNSplashes + gID + "/" + hash + ".png" }
EndpointGuildWebhooks = func(gID string) string { return EndpointGuilds + gID + "/webhooks" }
EndpointGuildAuditLogs = func(gID string) string { return EndpointGuilds + gID + "/audit-logs" }
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" }
EndpointGuildScheduledEvents = func(gID string) string { return EndpointGuilds + gID + "/scheduled-events" }
EndpointGuildScheduledEvent = func(gID, eID string) string { return EndpointGuilds + gID + "/scheduled-events/" + eID }
EndpointGuildScheduledEventUsers = func(gID, eID string) string { return EndpointGuildScheduledEvent(gID, eID) + "/users" }

EndpointChannel = func(cID string) string { return EndpointChannels + cID }
EndpointChannelPermissions = func(cID string) string { return EndpointChannels + cID + "/permissions" }
Expand Down
162 changes: 117 additions & 45 deletions eventhandlers.go

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

12 changes: 12 additions & 0 deletions events.go
Expand Up @@ -152,6 +152,18 @@ type GuildIntegrationsUpdate struct {
GuildID string `json:"guild_id"`
}

type GuildScheduledEventCreate struct {
*GuildScheduledEvent
}

type GuildScheduledEventUpdate struct {
*GuildScheduledEvent
}

type GuildScheduledEventDelete struct {
*GuildScheduledEvent
}

// MessageAck is the data for a MessageAck event.
type MessageAck struct {
MessageID string `json:"message_id"`
Expand Down
73 changes: 73 additions & 0 deletions scheduled_events.go
@@ -0,0 +1,73 @@
package discordgo
42atomys marked this conversation as resolved.
Show resolved Hide resolved

// GuildScheduledEvents returns an array of GuildScheduledEvent for a guild
// guildID : The ID of a Guild
func (s *Session) GuildScheduledEvents(guildID string) (st []*GuildScheduledEvent, err error) {
42atomys marked this conversation as resolved.
Show resolved Hide resolved
body, err := s.RequestWithBucketID("GET", EndpointGuildScheduledEvents(guildID), nil, EndpointGuildScheduledEvents(guildID))
if err != nil {
return
}

err = unmarshal(body, &st)
return
}

// GuildScheduledEvents returns an array of GuildScheduledEvent for a guild
42atomys marked this conversation as resolved.
Show resolved Hide resolved
// guildID : The ID of a Guild
// eventID : The ID of the event
func (s *Session) GuildScheduledEvent(guildID, eventID string) (st *GuildScheduledEvent, err error) {
42atomys marked this conversation as resolved.
Show resolved Hide resolved
body, err := s.RequestWithBucketID("GET", EndpointGuildScheduledEvent(guildID, eventID), nil, EndpointGuildScheduledEvent(guildID, eventID))
if err != nil {
return
}

err = unmarshal(body, &st)
return
}

// GuildScheduledEvents returns an array of GuildScheduledEvent for a guild
42atomys marked this conversation as resolved.
Show resolved Hide resolved
// guildID : The ID of a Guild
// eventID : The ID of the event
func (s *Session) GuildScheduledEventCreate(guildID string, event *GuildScheduledEvent) (st *GuildScheduledEvent, err error) {
body, err := s.RequestWithBucketID("POST", EndpointGuildScheduledEvents(guildID), event, EndpointGuildScheduledEvents(guildID))
if err != nil {
return
}

err = unmarshal(body, &st)
return
}

// GuildScheduledEvents returns an array of GuildScheduledEvent for a guild
// guildID : The ID of a Guild
// eventID : The ID of the event
func (s *Session) GuildScheduledEventUpdate(guildID, eventID string, event *GuildScheduledEvent) (st *GuildScheduledEvent, err error) {
42atomys marked this conversation as resolved.
Show resolved Hide resolved
42atomys marked this conversation as resolved.
Show resolved Hide resolved
body, err := s.RequestWithBucketID("PATCH", EndpointGuildScheduledEvent(guildID, eventID), event, EndpointGuildScheduledEvent(guildID, eventID))
if err != nil {
return
}

err = unmarshal(body, &st)
return
}

// GuildScheduledEvents returns an array of GuildScheduledEvent for a guild
42atomys marked this conversation as resolved.
Show resolved Hide resolved
// guildID : The ID of a Guild
// eventID : The ID of the event
func (s *Session) GuildScheduledEventDelete(guildID, eventID string) (err error) {
_, err = s.RequestWithBucketID("DELETE", EndpointGuildScheduledEvent(guildID, eventID), nil, EndpointGuildScheduledEvent(guildID, eventID))
return
}

// GuildScheduledEvents returns an array of GuildScheduledEvent for a guild
42atomys marked this conversation as resolved.
Show resolved Hide resolved
// guildID : The ID of a Guild
// eventID : The ID of the event
func (s *Session) GuildScheduledEventUsers(guildID, eventID string) (st []*GuildScheduledEventUser, err error) {
42atomys marked this conversation as resolved.
Show resolved Hide resolved
body, err := s.RequestWithBucketID("GET", EndpointGuildScheduledEventUsers(guildID, eventID), nil, EndpointGuildScheduledEventUsers(guildID, eventID))
if err != nil {
return
}

err = unmarshal(body, &st)
return
}