feat(api): add getMemberBans() query options and getMemberBan() (#9569)

This commit is contained in:
David Malchin
2023-05-14 10:40:04 +03:00
committed by GitHub
parent 7196fe36e8
commit 590f5bc38e

View File

@@ -11,6 +11,8 @@ import type {
RESTGetAPIAuditLogResult, RESTGetAPIAuditLogResult,
RESTGetAPIAutoModerationRuleResult, RESTGetAPIAutoModerationRuleResult,
RESTGetAPIAutoModerationRulesResult, RESTGetAPIAutoModerationRulesResult,
RESTGetAPIGuildBanResult,
RESTGetAPIGuildBansQuery,
RESTGetAPIGuildBansResult, RESTGetAPIGuildBansResult,
RESTGetAPIGuildChannelsResult, RESTGetAPIGuildChannelsResult,
RESTGetAPIGuildEmojiResult, RESTGetAPIGuildEmojiResult,
@@ -241,12 +243,32 @@ export class GuildsAPI {
/** /**
* Fetches a guild member ban * Fetches a guild member ban
* *
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-bans} * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-ban}
* @param guildId - The id of the guild to fetch the ban from * @param guildId - The id of the guild to fetch the ban from
* @param options - The options for fetching the guild member ban * @param userId - The id of the user to fetch the ban
* @param options - The options for fetching the ban
*/ */
public async getMemberBans(guildId: Snowflake, { signal }: Pick<RequestData, 'signal'> = {}) { public async getMemberBan(guildId: Snowflake, userId: Snowflake, { signal }: Pick<RequestData, 'signal'> = {}) {
return this.rest.get(Routes.guildBans(guildId), { signal }) as Promise<RESTGetAPIGuildBansResult>; return this.rest.get(Routes.guildBan(guildId, userId), { signal }) as Promise<RESTGetAPIGuildBanResult>;
}
/**
* Fetches guild member bans
*
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-bans}
* @param guildId - The id of the guild to fetch the bans from
* @param query - The query options for fetching the bans
* @param options - The options for fetching the bans
*/
public async getMemberBans(
guildId: Snowflake,
query: RESTGetAPIGuildBansQuery = {},
{ signal }: Pick<RequestData, 'signal'> = {},
) {
return this.rest.get(Routes.guildBans(guildId), {
query: makeURLSearchParams(query),
signal,
}) as Promise<RESTGetAPIGuildBansResult>;
} }
/** /**