Skip to content

Commit f90548c

Browse files
feat: move management roles to seperate permissions
1 parent 4dd5b52 commit f90548c

File tree

17 files changed

+581
-532
lines changed

17 files changed

+581
-532
lines changed

package-lock.json

Lines changed: 97 additions & 92 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `managementRoleIds` on the `Guild` table. All the data in the column will be lost.
5+
- You are about to drop the column `tags` on the `Message` table. All the data in the column will be lost.
6+
7+
*/
8+
-- AlterTable
9+
ALTER TABLE "Guild" DROP COLUMN "managementRoleIds";
10+
11+
-- AlterTable
12+
ALTER TABLE "Message" DROP COLUMN "tags";

prisma/schema.prisma

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ model Guild {
2626
permissions Json?
2727
beforeMigration Boolean @default(false) // This indicates if the guild existed before the migration to storing message content.
2828
// If it was it gains access to adding any previous bot sent message to the database.
29-
managementRoleIds BigInt[]
3029
messages Message[]
3130
channels Channel[]
3231
}

src/discord_commands/global.json

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,44 +35,7 @@
3535
}
3636
]
3737
},
38-
{
39-
"name": "management-roles",
40-
"type": 2,
41-
"description": "Manage who can manage permissions, and other configuration. Require administrator permissions.",
42-
"options": [
43-
{
44-
"name": "add",
45-
"type": 1,
46-
"description": "Make a role a bot management role.",
47-
"options": [
48-
{
49-
"type": 8,
50-
"name": "role",
51-
"required": true,
52-
"description": "The role to make a bot management role."
53-
}
54-
]
55-
},
56-
{
57-
"name": "remove",
58-
"type": 1,
59-
"description": "Remove a role from being a bot management role",
60-
"options": [
61-
{
62-
"type": 8,
63-
"name": "role",
64-
"required": true,
65-
"description": "The role to set the permission for"
66-
}
67-
]
68-
},
69-
{
70-
"name": "list",
71-
"type": 1,
72-
"description": "List all bot management roles"
73-
}
74-
]
75-
},
38+
7639
{
7740
"name": "permissions",
7841
"type": 2,
@@ -110,6 +73,14 @@
11073
{
11174
"name": "Delete Messages",
11275
"value": 4
76+
},
77+
{
78+
"name": "Manage Permissions",
79+
"value": 5
80+
},
81+
{
82+
"name": "Manage Config",
83+
"value": 6
11384
}
11485
]
11586
},

src/errors.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ enum InteractionOrRequestFinalStatus {
2525
REPORT_ALREADY_SUBMITTED,
2626
BOT_FOUND_WHEN_USER_EXPECTED,
2727
NO_PERMISSION_TO_REMOVE,
28-
NO_MANAGEMENT_ROLE_TO_REMOVE,
2928
TAG_NOT_FOUND,
29+
MANAGE_CONFIG_PERMISSION_CANNOT_BE_SET_ON_CHANNEL_LEVEL,
3030
GENERIC_EXPECTED_PERMISSIONS_FAILURE = 3000,
3131
USER_MISSING_DISCORD_PERMISSION,
3232
BOT_MISSING_DISCORD_PERMISSION,
3333
USER_MISSING_INTERNAL_BOT_PERMISSION,
3434
BOT_MISSING_DISCORD_SCOPE,
35-
USER_MISSING_INTERNAL_BOT_MANAGEMENT_PERMISSION,
35+
USER_ROLES_NOT_HIGH_ENOUGH,
36+
USER_ATTEMPTED_TO_EDIT_PERMISSION_ABOVE_THEIR_PERMISSION,
3637
GENERIC_EXPECTED_OAUTH_FAILURE = 4000,
3738
OATUH_TOKEN_EXPIRED,
3839
GENERIC_EXPECTED_LIMIT_FAILURE = 5000,
39-
MAX_MANAGEMENT_ROLES,
4040
MAX_ROLE_PERMISSIONS,
4141
MAX_USER_PERMISSIONS,
4242
MAX_ROLE_CHANNEL_PERMISSIONS,
@@ -59,6 +59,7 @@ enum InteractionOrRequestFinalStatus {
5959
GUILD_COMPONENT_IN_DM_INTERACTION,
6060
OAUTH_REQUEST_FAILED,
6161
CREATE_WEBHOOK_RESULT_MISSING_TOKEN,
62+
ROLE_NOT_IN_CACHE,
6263
}
6364

6465
class CustomError extends Error {

0 commit comments

Comments
 (0)