API: fix id field getting sent on EditChannelPermission

This commit is contained in:
mavolin 2020-05-25 02:20:34 +02:00 committed by diamondburned
parent 52bec08cc6
commit a07f343b39
1 changed files with 12 additions and 4 deletions

View File

@ -167,17 +167,25 @@ func (c *Client) DeleteChannel(channelID discord.Snowflake) error {
return c.FastRequest("DELETE", EndpointChannels+channelID.String())
}
type EditChannelPermissionData struct {
// Type is either "role" or "member".
Type discord.OverwriteType `json:"type"`
// Allow is a permission bit set for granted permissions.
Allow discord.Permissions `json:"allow"`
// Deny is a permission bit set for denied permissions.
Deny discord.Permissions `json:"deny"`
}
// EditChannelPermission edits the channel's permission overwrites for a user
// or role in a channel. Only usable for guild channels.
//
// Requires the MANAGE_ROLES permission.
func (c *Client) EditChannelPermission(
channelID discord.Snowflake, overwrite discord.Overwrite) error {
channelID, overwriteID discord.Snowflake, data EditChannelPermissionData) error {
url := EndpointChannels + channelID.String() + "/permissions/" + overwrite.ID.String()
overwrite.ID = 0
url := EndpointChannels + channelID.String() + "/permissions/" + overwriteID.String()
return c.FastRequest("PUT", url, httputil.WithJSONBody(overwrite))
return c.FastRequest("PUT", url, httputil.WithJSONBody(data))
}
// DeleteChannelPermission deletes a channel permission overwrite for a user or