From c051ed94271a7f5e5dec9836571ad4856e28f3b5 Mon Sep 17 00:00:00 2001 From: Kin <120244424+k1iin@users.noreply.github.com> Date: Mon, 6 Nov 2023 01:42:17 +0700 Subject: [PATCH] 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 * add jsdoc for options param * fix formatting * add missed semicolon Co-authored-by: Jaw0r3k * style: prettier --------- Co-authored-by: Jaw0r3k Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/core/src/api/guild.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts index c1b6a9cac..fc5c6e461 100644 --- a/packages/core/src/api/guild.ts +++ b/packages/core/src/api/guild.ts @@ -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 = {}, + ) { + return this.rest.put(Routes.guildMember(guildId, userId), { + body, + signal, + }) as Promise; + } + /** * Fetches all the members of a guild *