Skip to content

Commit

Permalink
feat(ChannelsAPI): add permission overwrites (#9651)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
D4isDAVID and kodiakhq[bot] authored Jul 6, 2023
1 parent 6d5840c commit 78381a5
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions packages/core/src/api/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
type RESTPostAPIChannelMessageCrosspostResult,
type RESTPostAPIChannelMessageJSONBody,
type RESTPostAPIChannelMessageResult,
type RESTPutAPIChannelPermissionJSONBody,
type Snowflake,
type RESTPostAPIChannelThreadsJSONBody,
type RESTPostAPIChannelThreadsResult,
Expand Down Expand Up @@ -540,4 +541,45 @@ export class ChannelsAPI {
public async getWebhooks(channelId: Snowflake) {
return this.rest.get(Routes.channelWebhooks(channelId)) as Promise<RESTGetAPIChannelWebhooksResult>;
}

/**
* Edits the permission overwrite for a user or role in a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#edit-channel-permissions}
* @param channelId - The id of the channel to edit the permission overwrite in
* @param overwriteId - The id of the user or role to edit the permission overwrite for
* @param body - The data for editing the permission overwrite
* @param options - The options for editing the permission overwrite
*/
public async editPermissionOverwrite(
channelId: Snowflake,
overwriteId: Snowflake,
body: RESTPutAPIChannelPermissionJSONBody,
{ reason, signal }: Pick<RequestData, 'reason' | 'signal'> = {},
) {
await this.rest.put(Routes.channelPermission(channelId, overwriteId), {
reason,
body,
signal,
});
}

/**
* Deletes the permission overwrite for a user or role in a channel
*
* @see {@link https://discord.com/developers/docs/resources/channel#delete-channel-permission}
* @param channelId - The id of the channel to delete the permission overwrite in
* @param overwriteId - The id of the user or role to delete the permission overwrite for
* @param options - The options for deleting the permission overwrite
*/
public async deletePermissionOverwrite(
channelId: Snowflake,
overwriteId: Snowflake,
{ reason, signal }: Pick<RequestData, 'reason' | 'signal'> = {},
) {
await this.rest.delete(Routes.channelPermission(channelId, overwriteId), {
reason,
signal,
});
}
}

0 comments on commit 78381a5

Please sign in to comment.