/[sudobot]/branches/6.x/src/utils/PermissionLevels.ts
ViewVC logotype

Contents of /branches/6.x/src/utils/PermissionLevels.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (show annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 2337 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 /*
2 * This file is part of SudoBot.
3 *
4 * Copyright (C) 2021-2023 OSN Developers.
5 *
6 * SudoBot is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * SudoBot is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with SudoBot. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 import { PermissionsString } from "discord.js";
21
22 export type PermissionLevelsRecord = Record<number, readonly PermissionsString[]>;
23
24 export const RawDefaultPermissionLevels: readonly (readonly PermissionsString[])[] = [
25 ["CreatePublicThreads"],
26 ["CreatePrivateThreads"],
27 [],
28 [],
29 ["MoveMembers"],
30 ["MuteMembers"],
31 ["DeafenMembers"],
32 ["ManageEmojisAndStickers"],
33 ["ManageGuildExpressions"],
34 ["ManageMessages"],
35 ["ModerateMembers"],
36 ["ManageNicknames"],
37 ["KickMembers"],
38 ["BanMembers"],
39 ["ViewAuditLog"],
40 ["ViewGuildInsights"],
41 ["ViewCreatorMonetizationAnalytics"],
42 ["MentionEveryone"],
43 ["ManageThreads"],
44 ["ManageEvents"],
45 ["ManageChannels"],
46 ["ManageRoles"],
47 ["ManageGuild"],
48 ["ManageWebhooks"],
49 ["Administrator"]
50 ] as const;
51
52 export function getDefaultPermissionLevelArray() {
53 const permissionLevels = [];
54 let lastPermissionLevel = [];
55
56 for (const level of RawDefaultPermissionLevels) {
57 lastPermissionLevel.push(...level);
58 permissionLevels.push([...lastPermissionLevel]);
59 }
60
61 return permissionLevels;
62 }
63
64 export function getDefaultPermissionLevels() {
65 const record: PermissionLevelsRecord = {};
66
67 let lastPermissionLevel: PermissionsString[] = [];
68 let level = 0;
69
70 for (const rawPermissionlevel of RawDefaultPermissionLevels) {
71 const array = [...lastPermissionLevel];
72
73 for (let i = 0; i < 4; i++) {
74 record[level++] = array;
75 }
76
77 lastPermissionLevel.push(...rawPermissionlevel);
78 }
79
80 return record;
81 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26