From 29269347e820c4011fd277948eb8b13308b61bb9 Mon Sep 17 00:00:00 2001 From: Riley Smith Date: Mon, 27 Dec 2021 18:38:45 -0800 Subject: [PATCH] Add guild member timeouts (#1061) * added guild member timeouts * fix spelling error * Use time.Time, allow timeout removal Co-authored-by: Carson Hoffman --- restapi.go | 14 ++++++++++++++ structs.go | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/restapi.go b/restapi.go index e3817d233..61fcd5fa6 100644 --- a/restapi.go +++ b/restapi.go @@ -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. diff --git a/structs.go b/structs.go index 1435ff6cb..9d7c1fccb 100644 --- a/structs.go +++ b/structs.go @@ -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 @@ -1296,6 +1300,7 @@ const ( PermissionViewAuditLogs = 0x0000000000000080 PermissionViewChannel = 0x0000000000000400 PermissionViewGuildInsights = 0x0000000000080000 + PermissionModerateMembers = 0x0000010000000000 PermissionAllText = PermissionViewChannel | PermissionSendMessages |