mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
fix(GuildMemberManager): add() method throws an error (#8539)
* fix(GuildMemberManager): `add()` method throws an error * chore: update comment
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Buffer } = require('node:buffer');
|
|
||||||
const { setTimeout, clearTimeout } = require('node:timers');
|
const { setTimeout, clearTimeout } = require('node:timers');
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
const { makeURLSearchParams } = require('@discordjs/rest');
|
const { makeURLSearchParams } = require('@discordjs/rest');
|
||||||
@@ -128,8 +127,12 @@ class GuildMemberManager extends CachedManager {
|
|||||||
resolvedOptions.roles = resolvedRoles;
|
resolvedOptions.roles = resolvedRoles;
|
||||||
}
|
}
|
||||||
const data = await this.client.rest.put(Routes.guildMember(this.guild.id, userId), { body: resolvedOptions });
|
const data = await this.client.rest.put(Routes.guildMember(this.guild.id, userId), { body: resolvedOptions });
|
||||||
// Data is an empty buffer if the member is already part of the guild.
|
// Data is an empty Uint8Array if the member is already part of the guild.
|
||||||
return data instanceof Buffer ? (options.fetchWhenExisting === false ? null : this.fetch(userId)) : this._add(data);
|
return data instanceof Uint8Array
|
||||||
|
? options.fetchWhenExisting === false
|
||||||
|
? null
|
||||||
|
: this.fetch(userId)
|
||||||
|
: this._add(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user