Skip to content

Commit

Permalink
Add guild member timeouts (#1061)
Browse files Browse the repository at this point in the history
* added guild member timeouts

* fix spelling error

* Use time.Time, allow timeout removal

Co-authored-by: Carson Hoffman <c@rsonhoffman.com>
  • Loading branch information
QPixel and CarsonHoffman committed Dec 28, 2021
1 parent 7c455ff commit 2926934
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions restapi.go
Expand Up @@ -903,6 +903,20 @@ func (s *Session) GuildMemberMute(guildID string, userID string, mute bool) (err
return
}

// GuildMemberTimeout times out a guild member
// guildID : The ID of a Guild.
// userID : The ID of a User.
// until : The timestamp for how long a member should be timed out.
// Set to nil to remove timeout.
func (s *Session) GuildMemberTimeout(guildID string, userID string, until *time.Time) (err error) {
data := struct {
CommunicationDisabledUntil *time.Time `json:"communication_disabled_until"`
}{until}

_, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
return
}

// GuildMemberDeafen server deafens a guild member
// guildID : The ID of a Guild.
// userID : The ID of a User.
Expand Down
5 changes: 5 additions & 0 deletions structs.go
Expand Up @@ -808,6 +808,10 @@ type Member struct {

// Total permissions of the member in the channel, including overrides, returned when in the interaction object.
Permissions int64 `json:"permissions,string"`

// The time at which the member's timeout will expire.
// Time in the past or nil if the user is not timed out.
CommunicationDisabledUntil *time.Time `json:"communication_disabled_until"`
}

// Mention creates a member mention
Expand Down Expand Up @@ -1296,6 +1300,7 @@ const (
PermissionViewAuditLogs = 0x0000000000000080
PermissionViewChannel = 0x0000000000000400
PermissionViewGuildInsights = 0x0000000000080000
PermissionModerateMembers = 0x0000010000000000

PermissionAllText = PermissionViewChannel |
PermissionSendMessages |
Expand Down

0 comments on commit 2926934

Please sign in to comment.