Merge pull request #216 from jonas747/userguildsettings
Added UserGuildSettingsEdit
This commit is contained in:
commit
79d49f86fb
3 changed files with 32 additions and 8 deletions
17
endpoints.go
17
endpoints.go
|
@ -46,14 +46,15 @@ var (
|
||||||
EndpointReport = EndpointAPI + "report"
|
EndpointReport = EndpointAPI + "report"
|
||||||
EndpointIntegrations = EndpointAPI + "integrations"
|
EndpointIntegrations = EndpointAPI + "integrations"
|
||||||
|
|
||||||
EndpointUser = func(uID string) string { return EndpointUsers + uID }
|
EndpointUser = func(uID string) string { return EndpointUsers + uID }
|
||||||
EndpointUserAvatar = func(uID, aID string) string { return EndpointUsers + uID + "/avatars/" + aID + ".jpg" }
|
EndpointUserAvatar = func(uID, aID string) string { return EndpointUsers + uID + "/avatars/" + aID + ".jpg" }
|
||||||
EndpointUserSettings = func(uID string) string { return EndpointUsers + uID + "/settings" }
|
EndpointUserSettings = func(uID string) string { return EndpointUsers + uID + "/settings" }
|
||||||
EndpointUserGuilds = func(uID string) string { return EndpointUsers + uID + "/guilds" }
|
EndpointUserGuilds = func(uID string) string { return EndpointUsers + uID + "/guilds" }
|
||||||
EndpointUserGuild = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID }
|
EndpointUserGuild = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID }
|
||||||
EndpointUserChannels = func(uID string) string { return EndpointUsers + uID + "/channels" }
|
EndpointUserGuildSettings = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID + "/settings" }
|
||||||
EndpointUserDevices = func(uID string) string { return EndpointUsers + uID + "/devices" }
|
EndpointUserChannels = func(uID string) string { return EndpointUsers + uID + "/channels" }
|
||||||
EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" }
|
EndpointUserDevices = func(uID string) string { return EndpointUsers + uID + "/devices" }
|
||||||
|
EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" }
|
||||||
|
|
||||||
EndpointGuild = func(gID string) string { return EndpointGuilds + gID }
|
EndpointGuild = func(gID string) string { return EndpointGuilds + gID }
|
||||||
EndpointGuildInivtes = func(gID string) string { return EndpointGuilds + gID + "/invites" }
|
EndpointGuildInivtes = func(gID string) string { return EndpointGuilds + gID + "/invites" }
|
||||||
|
|
14
restapi.go
14
restapi.go
|
@ -362,6 +362,20 @@ func (s *Session) UserGuilds() (st []*Guild, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UserGuildSettingsEdit Edits the users notification settings for a guild
|
||||||
|
// guildID : The ID of the guild to edit the settings on
|
||||||
|
// settings : The settings to update
|
||||||
|
func (s *Session) UserGuildSettingsEdit(guildID string, settings *UserGuildSettingsEdit) (st *UserGuildSettings, err error) {
|
||||||
|
|
||||||
|
body, err := s.Request("PATCH", EndpointUserGuildSettings("@me", guildID), settings)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = unmarshal(body, &st)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// UserChannelPermissions returns the permission of a user in a channel.
|
// UserChannelPermissions returns the permission of a user in a channel.
|
||||||
// userID : The ID of the user to calculate permissions for.
|
// userID : The ID of the user to calculate permissions for.
|
||||||
// channelID : The ID of the channel to calculate permission for.
|
// channelID : The ID of the channel to calculate permission for.
|
||||||
|
|
|
@ -450,6 +450,15 @@ type UserGuildSettings struct {
|
||||||
ChannelOverrides []*UserGuildSettingsChannelOverride `json:"channel_overrides"`
|
ChannelOverrides []*UserGuildSettingsChannelOverride `json:"channel_overrides"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A UserGuildSettingsEdit stores data for editing UserGuildSettings
|
||||||
|
type UserGuildSettingsEdit struct {
|
||||||
|
SupressEveryone bool `json:"suppress_everyone"`
|
||||||
|
Muted bool `json:"muted"`
|
||||||
|
MobilePush bool `json:"mobile_push"`
|
||||||
|
MessageNotifications int `json:"message_notifications"`
|
||||||
|
ChannelOverrides map[string]*UserGuildSettingsChannelOverride `json:"channel_overrides"`
|
||||||
|
}
|
||||||
|
|
||||||
// Constants for the different bit offsets of text channel permissions
|
// Constants for the different bit offsets of text channel permissions
|
||||||
const (
|
const (
|
||||||
PermissionReadMessages = 1 << (iota + 10)
|
PermissionReadMessages = 1 << (iota + 10)
|
||||||
|
|
Loading…
Reference in a new issue