File tree Expand file tree Collapse file tree 19 files changed +140
-129
lines changed Expand file tree Collapse file tree 19 files changed +140
-129
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,12 @@ const fs = require("fs");
7
7
const yaml = require ( "yaml" ) ;
8
8
const configFile = fs . readFileSync ( "./config.yml" , "utf8" ) ;
9
9
const config = yaml . parse ( configFile ) ;
10
- const { ticketsDB, sanitizeInput, logMessage } = require ( "../../index.js" ) ;
10
+ const {
11
+ ticketsDB,
12
+ sanitizeInput,
13
+ logMessage,
14
+ checkSupportRole,
15
+ } = require ( "../../index.js" ) ;
11
16
12
17
module . exports = {
13
18
enabled : config . commands . add . enabled ,
@@ -32,11 +37,8 @@ module.exports = {
32
37
} ) ;
33
38
}
34
39
35
- if (
36
- ! interaction . member . roles . cache . some ( ( role ) =>
37
- config . support_role_ids . includes ( role . id ) ,
38
- )
39
- ) {
40
+ const hasSupportRole = await checkSupportRole ( interaction ) ;
41
+ if ( ! hasSupportRole ) {
40
42
return interaction . reply ( {
41
43
content : config . errors . not_allowed ,
42
44
ephemeral : true ,
Original file line number Diff line number Diff line change @@ -10,7 +10,12 @@ const fs = require("fs");
10
10
const yaml = require ( "yaml" ) ;
11
11
const configFile = fs . readFileSync ( "./config.yml" , "utf8" ) ;
12
12
const config = yaml . parse ( configFile ) ;
13
- const { ticketsDB, logMessage, client } = require ( "../../index.js" ) ;
13
+ const {
14
+ ticketsDB,
15
+ logMessage,
16
+ client,
17
+ checkSupportRole,
18
+ } = require ( "../../index.js" ) ;
14
19
15
20
module . exports = {
16
21
enabled : config . commands . alert . enabled ,
@@ -29,11 +34,8 @@ module.exports = {
29
34
} ) ;
30
35
}
31
36
32
- if (
33
- ! interaction . member . roles . cache . some ( ( role ) =>
34
- config . support_role_ids . includes ( role . id ) ,
35
- )
36
- ) {
37
+ const hasSupportRole = await checkSupportRole ( interaction ) ;
38
+ if ( ! hasSupportRole ) {
37
39
return interaction . reply ( {
38
40
content : config . errors . not_allowed ,
39
41
ephemeral : true ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const {
16
16
logMessage,
17
17
ticketCategories,
18
18
mainDB,
19
+ checkSupportRole,
19
20
} = require ( "../../index.js" ) ;
20
21
21
22
module . exports = {
@@ -35,11 +36,8 @@ module.exports = {
35
36
} ) ;
36
37
}
37
38
38
- if (
39
- ! interaction . member . roles . cache . some ( ( role ) =>
40
- config . support_role_ids . includes ( role . id ) ,
41
- )
42
- ) {
39
+ const hasSupportRole = await checkSupportRole ( interaction ) ;
40
+ if ( ! hasSupportRole ) {
43
41
return interaction . reply ( {
44
42
content : config . errors . not_allowed ,
45
43
ephemeral : true ,
@@ -124,7 +122,7 @@ module.exports = {
124
122
125
123
Object . keys ( ticketCategories ) . forEach ( async ( id ) => {
126
124
if ( ticketButton === id ) {
127
- config . support_role_ids . forEach ( async ( roleId ) => {
125
+ ticketCategories [ id ] . support_role_ids . forEach ( async ( roleId ) => {
128
126
await interaction . channel . permissionOverwrites
129
127
. edit ( roleId , {
130
128
SendMessages : true ,
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ const {
17
17
ticketCategories,
18
18
sanitizeInput,
19
19
logMessage,
20
+ checkSupportRole,
20
21
} = require ( "../../index.js" ) ;
21
22
22
23
module . exports = {
@@ -45,11 +46,8 @@ module.exports = {
45
46
} ) ;
46
47
}
47
48
48
- if (
49
- ! interaction . member . roles . cache . some ( ( role ) =>
50
- config . support_role_ids . includes ( role . id ) ,
51
- )
52
- ) {
49
+ const hasSupportRole = await checkSupportRole ( interaction ) ;
50
+ if ( ! hasSupportRole ) {
53
51
return interaction . reply ( {
54
52
content : config . errors . not_allowed ,
55
53
ephemeral : true ,
@@ -177,7 +175,7 @@ module.exports = {
177
175
lockPermissions : false ,
178
176
} ) ;
179
177
180
- config . support_role_ids . forEach ( async ( roleId ) => {
178
+ category . support_role_ids . forEach ( async ( roleId ) => {
181
179
await interaction . channel . permissionOverwrites
182
180
. edit ( roleId , {
183
181
SendMessages : false ,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ const {
18
18
sanitizeInput,
19
19
logMessage,
20
20
saveTranscriptTxt,
21
+ checkSupportRole,
21
22
} = require ( "../../index.js" ) ;
22
23
23
24
module . exports = {
@@ -37,11 +38,8 @@ module.exports = {
37
38
} ) ;
38
39
}
39
40
40
- if (
41
- ! interaction . member . roles . cache . some ( ( role ) =>
42
- config . support_role_ids . includes ( role . id ) ,
43
- )
44
- ) {
41
+ const hasSupportRole = await checkSupportRole ( interaction ) ;
42
+ if ( ! hasSupportRole ) {
45
43
return interaction . reply ( {
46
44
content : config . errors . not_allowed ,
47
45
ephemeral : true ,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const {
12
12
sanitizeInput,
13
13
logMessage,
14
14
ticketCategories,
15
+ checkSupportRole,
15
16
} = require ( "../../index.js" ) ;
16
17
const customIds = Object . keys ( ticketCategories ) ;
17
18
const choices = customIds . map ( ( customId ) => {
@@ -42,11 +43,8 @@ module.exports = {
42
43
} ) ;
43
44
}
44
45
45
- if (
46
- ! interaction . member . roles . cache . some ( ( role ) =>
47
- config . support_role_ids . includes ( role . id ) ,
48
- )
49
- ) {
46
+ const hasSupportRole = await checkSupportRole ( interaction ) ;
47
+ if ( ! hasSupportRole ) {
50
48
return interaction . reply ( {
51
49
content : config . errors . not_allowed ,
52
50
ephemeral : true ,
Original file line number Diff line number Diff line change @@ -12,7 +12,12 @@ const fs = require("fs");
12
12
const yaml = require ( "yaml" ) ;
13
13
const configFile = fs . readFileSync ( "./config.yml" , "utf8" ) ;
14
14
const config = yaml . parse ( configFile ) ;
15
- const { ticketCategories, logMessage, mainDB } = require ( "../../index.js" ) ;
15
+ const {
16
+ ticketCategories,
17
+ logMessage,
18
+ mainDB,
19
+ checkSupportRole,
20
+ } = require ( "../../index.js" ) ;
16
21
17
22
module . exports = {
18
23
enabled : config . commands . panel . enabled ,
@@ -24,11 +29,8 @@ module.exports = {
24
29
)
25
30
. setDMPermission ( false ) ,
26
31
async execute ( interaction ) {
27
- if (
28
- ! interaction . member . roles . cache . some ( ( role ) =>
29
- config . support_role_ids . includes ( role . id ) ,
30
- )
31
- ) {
32
+ const hasSupportRole = await checkSupportRole ( interaction ) ;
33
+ if ( ! hasSupportRole ) {
32
34
return interaction . reply ( {
33
35
content : config . errors . not_allowed ,
34
36
ephemeral : true ,
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const fs = require("fs");
7
7
const yaml = require ( "yaml" ) ;
8
8
const configFile = fs . readFileSync ( "./config.yml" , "utf8" ) ;
9
9
const config = yaml . parse ( configFile ) ;
10
- const { ticketsDB, logMessage } = require ( "../../index.js" ) ;
10
+ const { ticketsDB, logMessage, checkSupportRole } = require ( "../../index.js" ) ;
11
11
12
12
module . exports = {
13
13
enabled : config . commands . pin . enabled ,
@@ -26,11 +26,8 @@ module.exports = {
26
26
} ) ;
27
27
}
28
28
29
- if (
30
- ! interaction . member . roles . cache . some ( ( role ) =>
31
- config . support_role_ids . includes ( role . id ) ,
32
- )
33
- ) {
29
+ const hasSupportRole = await checkSupportRole ( interaction ) ;
30
+ if ( ! hasSupportRole ) {
34
31
return interaction . reply ( {
35
32
content : config . errors . not_allowed ,
36
33
ephemeral : true ,
Original file line number Diff line number Diff line change @@ -7,7 +7,12 @@ const fs = require("fs");
7
7
const yaml = require ( "yaml" ) ;
8
8
const configFile = fs . readFileSync ( "./config.yml" , "utf8" ) ;
9
9
const config = yaml . parse ( configFile ) ;
10
- const { ticketsDB, sanitizeInput, logMessage } = require ( "../../index.js" ) ;
10
+ const {
11
+ ticketsDB,
12
+ sanitizeInput,
13
+ logMessage,
14
+ checkSupportRole,
15
+ } = require ( "../../index.js" ) ;
11
16
12
17
module . exports = {
13
18
enabled : config . commands . remove . enabled ,
@@ -32,11 +37,8 @@ module.exports = {
32
37
} ) ;
33
38
}
34
39
35
- if (
36
- ! interaction . member . roles . cache . some ( ( role ) =>
37
- config . support_role_ids . includes ( role . id ) ,
38
- )
39
- ) {
40
+ const hasSupportRole = await checkSupportRole ( interaction ) ;
41
+ if ( ! hasSupportRole ) {
40
42
return interaction . reply ( {
41
43
content : config . errors . not_allowed ,
42
44
ephemeral : true ,
Original file line number Diff line number Diff line change @@ -7,7 +7,12 @@ const fs = require("fs");
7
7
const yaml = require ( "yaml" ) ;
8
8
const configFile = fs . readFileSync ( "./config.yml" , "utf8" ) ;
9
9
const config = yaml . parse ( configFile ) ;
10
- const { ticketsDB, sanitizeInput, logMessage } = require ( "../../index.js" ) ;
10
+ const {
11
+ ticketsDB,
12
+ sanitizeInput,
13
+ logMessage,
14
+ checkSupportRole,
15
+ } = require ( "../../index.js" ) ;
11
16
12
17
module . exports = {
13
18
enabled : config . commands . rename . enabled ,
@@ -29,11 +34,8 @@ module.exports = {
29
34
} ) ;
30
35
}
31
36
32
- if (
33
- ! interaction . member . roles . cache . some ( ( role ) =>
34
- config . support_role_ids . includes ( role . id ) ,
35
- )
36
- ) {
37
+ const hasSupportRole = await checkSupportRole ( interaction ) ;
38
+ if ( ! hasSupportRole ) {
37
39
return interaction . reply ( {
38
40
content : config . errors . not_allowed ,
39
41
ephemeral : true ,
You can’t perform that action at this time.
0 commit comments