-
-
Notifications
You must be signed in to change notification settings - Fork 100
/
editChannelOverwrite.ts
42 lines (39 loc) · 1.14 KB
/
editChannelOverwrite.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import type { Bot } from "../../bot.ts";
import { OverwriteTypes, PermissionStrings } from "../../types/shared.ts";
/** Edit the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */
export async function editChannelOverwrite(
bot: Bot,
channelId: bigint,
overwrite: OverwriteReadable,
) {
await bot.rest.runMethod<undefined>(
bot.rest,
"PUT",
bot.constants.routes.CHANNEL_OVERWRITE(channelId, overwrite.id),
{
allow: overwrite.allow ? bot.utils.calculateBits(overwrite.allow) : "0",
deny: overwrite.deny ? bot.utils.calculateBits(overwrite.deny) : "0",
type: overwrite.type,
},
);
}
export interface OverwriteReadable {
/** Role or user id */
id: bigint;
/** Either 0 (role) or 1 (member) */
type: OverwriteTypes;
/** Permission bit set */
allow?: PermissionStrings[];
/** Permission bit set */
deny?: PermissionStrings[];
}
export interface Overwrite {
/** Role or user id */
id: bigint;
/** Either 0 (role) or 1 (member) */
type: OverwriteTypes;
/** Permission bit set */
allow?: bigint;
/** Permission bit set */
deny?: bigint;
}