forked from pothtonswer/discordmuffin
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
|
@ -51,6 +51,7 @@ var (
|
|||
EndpointUserSettings = func(uID string) string { return EndpointUsers + uID + "/settings" }
|
||||
EndpointUserGuilds = func(uID string) string { return EndpointUsers + uID + "/guilds" }
|
||||
EndpointUserGuild = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID }
|
||||
EndpointUserGuildSettings = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID + "/settings" }
|
||||
EndpointUserChannels = func(uID string) string { return EndpointUsers + uID + "/channels" }
|
||||
EndpointUserDevices = func(uID string) string { return EndpointUsers + uID + "/devices" }
|
||||
EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" }
|
||||
|
|
14
restapi.go
14
restapi.go
|
@ -362,6 +362,20 @@ func (s *Session) UserGuilds() (st []*Guild, err error) {
|
|||
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.
|
||||
// userID : The ID of the user to calculate permissions for.
|
||||
// channelID : The ID of the channel to calculate permission for.
|
||||
|
|
|
@ -450,6 +450,15 @@ type UserGuildSettings struct {
|
|||
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
|
||||
const (
|
||||
PermissionReadMessages = 1 << (iota + 10)
|
||||
|
|
Loading…
Reference in a new issue