mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat: add guild member (#9877)
* feat: add guild member * slightly change the description for the guildId and userId parameters in the addMember function * fix description syntax * Update packages/core/src/api/guild.ts Co-authored-by: Jaw0r3k <jaworekwiadomosci@gmail.com> * add jsdoc for options param * fix formatting * add missed semicolon Co-authored-by: Jaw0r3k <jaworekwiadomosci@gmail.com> * style: prettier --------- Co-authored-by: Jaw0r3k <jaworekwiadomosci@gmail.com> Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -92,6 +92,8 @@ import {
|
||||
type RESTPostAPIGuildsMFAResult,
|
||||
type RESTPostAPIGuildsResult,
|
||||
type RESTPutAPIGuildBanJSONBody,
|
||||
type RESTPutAPIGuildMemberJSONBody,
|
||||
type RESTPutAPIGuildMemberResult,
|
||||
type RESTPutAPIGuildOnboardingJSONBody,
|
||||
type RESTPutAPIGuildOnboardingResult,
|
||||
type RESTPutAPIGuildTemplateSyncResult,
|
||||
@@ -167,6 +169,27 @@ export class GuildsAPI {
|
||||
await this.rest.delete(Routes.guild(guildId), { reason, signal });
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds user to the guild
|
||||
*
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild#add-guild-member}
|
||||
* @param guildId - The id of the guild to add the user to
|
||||
* @param userId - The id of the user to add
|
||||
* @param body - The data for adding users to the guild
|
||||
* @param options - The options for adding users to the guild
|
||||
*/
|
||||
public async addMember(
|
||||
guildId: Snowflake,
|
||||
userId: Snowflake,
|
||||
body: RESTPutAPIGuildMemberJSONBody,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
return this.rest.put(Routes.guildMember(guildId, userId), {
|
||||
body,
|
||||
signal,
|
||||
}) as Promise<RESTPutAPIGuildMemberResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches all the members of a guild
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user