discordgo
discordgo copied to clipboard
REST methods cleanup
We have been thinking on how to improve developer experience with the library and clean up some stuff.
One of the aspects that came to our attention is REST methods. Currently we don't have a consistent naming and signature style.
This PR addresses this problem. It refactors REST methods to use structs where possible and removes some of the unnecessary helper methods.
This only affects older functions , functions that came after v0.24.0
already are following this design.
Here's how the usage will change:
// Change role name.
- s.GuildRoleEdit(guildID, roleID, "new name", 0xFFFFFF, true, 0x0, true)
+ s.GuildRoleEdit(guildID, roleID, &discordgo.RoleData {
+ Name: "new name",
+ })
// Change member's roles and nickname.
- s.GuildMemberEdit(guildID, memberID, roles)
- s.GuildMemberNickname(guildID, memberID, "new nickname")
+ s.GuildMemberEdit(guildID, memberID, &discordgo.GuildMemberParams { ... })
// Add member to the server with the given nickname and roles.
- s.GuildMemberAdd(token, guildID, userID, "member", []string{...}, false, false)
+ s.GuildMemberAdd(token, guildID, userID, &discordgo.GuildMemberParams {
+ Name: "member",
+ Roles: &[]string{...},
+ })
Breaking changes
- [x]
ChannelEdit
— will share same functional asChannelEditComplex
- [x]
GuildMemberEdit
— will share same functional asGuildMemberEditComplex
- [x]
GuildEmojiEdit
—name
androles
will be placed in a struct, to allow for partial edits - [x]
GuildEmojiCreate
— same as forGuildEmojiEdit
- [ ]
GuildMemberAdd
—nick
,roles
,mute
anddeaf
will be placed in a struct - [x]
GuildMemberEdit
— will share same functional asGuildMemberEditComplex
- [x]
GuildRoleEdit
—name
,color
,hoist
,perms
,mention
will be placed in a struct to allow for partial edits - [ ]
GuildTemplateEdit
—name
anddescription
will be placed in a struct to allow for partial edits
Deprecated functions
- [x]
ChannelEditComplex
(renamed toChannelEdit
) - [x]
GuildMemberEditComplex
(renamed toGuildMemberEdit
)
:construction: The changes are still work in progress, therefore the list of functions might change.