Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add guild member #9877

Merged
merged 12 commits into from
Nov 5, 2023
22 changes: 22 additions & 0 deletions packages/core/src/api/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ import {
type RESTPostAPIGuildsMFAResult,
type RESTPostAPIGuildsResult,
type RESTPutAPIGuildBanJSONBody,
type RESTPutAPIGuildMemberJSONBody,
type RESTPutAPIGuildMemberResult,
type RESTPutAPIGuildTemplateSyncResult,
type Snowflake,
} from 'discord-api-types/v10';
Expand Down Expand Up @@ -164,6 +166,26 @@ export class GuildsAPI {
public async delete(guildId: Snowflake, { signal, reason }: Pick<RequestData, 'reason' | 'signal'> = {}) {
await this.rest.delete(Routes.guild(guildId), { reason, signal });
}

/**
* Add user to the guild
heyk1n marked this conversation as resolved.
Show resolved Hide resolved
*
* @see {@link https://discord.com/developers/docs/resources/guild#add-guild-member}
* @param guildId - Id of the guild that will be added to the user's guilds
heyk1n marked this conversation as resolved.
Show resolved Hide resolved
* @param userId - Id of the user that will be added to guild
heyk1n marked this conversation as resolved.
Show resolved Hide resolved
* @param body - The options for adding user to guild
heyk1n marked this conversation as resolved.
Show resolved Hide resolved
*/
public async addMember(
Jiralite marked this conversation as resolved.
Show resolved Hide resolved
guildId: Snowflake,
userId: Snowflake,
body: RESTPutAPIGuildMemberJSONBody,
{ signal }: Pick<RequestData, 'signal'> = {}
) {
return this.rest.put(Routes.guildMember(guildId, userId), {
body,
signal
}) as Promise<RESTPutAPIGuildMemberResult>
heyk1n marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Fetches all the members of a guild
Expand Down