mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
feat(ChannelsAPI): add permission overwrites (#9651)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -27,6 +27,7 @@ import {
|
|||||||
type RESTPostAPIChannelMessageCrosspostResult,
|
type RESTPostAPIChannelMessageCrosspostResult,
|
||||||
type RESTPostAPIChannelMessageJSONBody,
|
type RESTPostAPIChannelMessageJSONBody,
|
||||||
type RESTPostAPIChannelMessageResult,
|
type RESTPostAPIChannelMessageResult,
|
||||||
|
type RESTPutAPIChannelPermissionJSONBody,
|
||||||
type Snowflake,
|
type Snowflake,
|
||||||
type RESTPostAPIChannelThreadsJSONBody,
|
type RESTPostAPIChannelThreadsJSONBody,
|
||||||
type RESTPostAPIChannelThreadsResult,
|
type RESTPostAPIChannelThreadsResult,
|
||||||
@@ -540,4 +541,45 @@ export class ChannelsAPI {
|
|||||||
public async getWebhooks(channelId: Snowflake) {
|
public async getWebhooks(channelId: Snowflake) {
|
||||||
return this.rest.get(Routes.channelWebhooks(channelId)) as Promise<RESTGetAPIChannelWebhooksResult>;
|
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,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user