feat(GuildMember): Add timeouts (#7104)

Co-authored-by: Rodry <38259440+ImRodry@users.noreply.github.com>
Co-authored-by: Tiemen <ThaTiemsz@users.noreply.github.com>
Co-authored-by: Antonio Román <kyradiscord@gmail.com>
This commit is contained in:
Jiralite
2021-12-22 16:54:44 +00:00
committed by GitHub
parent 2ed02f7fc7
commit aa7c1b2081
9 changed files with 138 additions and 21 deletions

View File

@@ -223,6 +223,19 @@ class GuildMemberManager extends CachedManager {
return data.reduce((col, member) => col.set(member.user.id, this._add(member, cache)), new Collection());
}
/**
* The data for editing a guild member.
* @typedef {Object} GuildMemberEditData
* @property {?string} [nick] The nickname to set for the member
* @property {Collection<Snowflake, Role>|RoleResolvable[]} [roles] The roles or role ids to apply
* @property {boolean} [mute] Whether or not the member should be muted
* @property {boolean} [deaf] Whether or not the member should be deafened
* @property {GuildVoiceChannelResolvable|null} [channel] Channel to move the member to
* (if they are connected to voice), or `null` if you want to disconnect them from voice
* @property {DateResolvable|null} [communicationDisabledUntil] The date or timestamp
* for the member's communication to be disabled until. Provide `null` to enable communication again.
*/
/**
* Edits a member of the guild.
* <info>The user must be a member of the guild</info>
@@ -249,6 +262,10 @@ class GuildMemberManager extends CachedManager {
_data.channel = undefined;
}
_data.roles &&= _data.roles.map(role => (role instanceof Role ? role.id : role));
_data.communication_disabled_until =
_data.communicationDisabledUntil && new Date(_data.communicationDisabledUntil).toISOString();
let endpoint = this.client.api.guilds(this.guild.id);
if (id === this.client.user.id) {
const keys = Object.keys(_data);