1
1
import {
2
+ CommandInteraction ,
2
3
MessageReaction ,
3
4
PartialMessageReaction ,
4
5
PartialUser ,
@@ -9,6 +10,7 @@ import {
9
10
bankerRoleId ,
10
11
officerRoleId ,
11
12
bankTransactionsChannelId ,
13
+ modRoleId ,
12
14
} from "../../../config" ;
13
15
import {
14
16
ReactionAction ,
@@ -28,31 +30,44 @@ class BankRequestFinishedReactionAction extends ReactionAction {
28
30
if ( this . message . channel . id !== bankRequestsChannelId ) {
29
31
return ;
30
32
}
31
-
32
- // filter non-finish emoji reactions
33
- if ( this . reaction . emoji . name !== "✅" ) {
34
- return ;
33
+ // mark finished
34
+ if ( this . reaction . emoji . name === "✅" ) {
35
+ const bankTransactionsChannel = await getTextChannel (
36
+ bankTransactionsChannelId
37
+ ) ;
38
+ let transactionContent = this . message . content + ` -- ✅ by ${ this . user } ` ;
39
+ if ( ! this . message . author ?. bot ) {
40
+ transactionContent = this . message . author ?. toString ( ) + ": " + transactionContent ;
41
+ }
42
+ bankTransactionsChannel ?. send ( transactionContent ) ;
43
+ // authorize user
44
+ const reactor = await this . members ?. fetch ( this . user . id ) ;
45
+ if (
46
+ ! (
47
+ reactor ?. roles . cache . has ( bankerRoleId ) ||
48
+ reactor ?. roles . cache . has ( officerRoleId ) ||
49
+ reactor ?. roles . cache . has ( modRoleId )
50
+ )
51
+ ) {
52
+ return ;
53
+ }
54
+ this . message . delete ( ) ;
35
55
}
36
56
37
- // authorize user
38
- const reactor = await this . members ?. fetch ( this . user . id ) ;
39
- if (
40
- ! (
41
- reactor ?. roles . cache . has ( bankerRoleId ) ||
42
- reactor ?. roles . cache . has ( officerRoleId )
43
- )
44
- ) {
45
- return ;
57
+ // delete
58
+ if ( this . reaction . emoji . name === "❌" ) {
59
+ const reactor = await this . members ?. fetch ( this . user . id ) ;
60
+ if (
61
+ ! (
62
+ reactor ?. roles . cache . has ( bankerRoleId ) ||
63
+ reactor ?. roles . cache . has ( officerRoleId ) ||
64
+ reactor ?. roles . cache . has ( modRoleId )
65
+ ) || this . message . mentions ?. parsedUsers . hasAny ( this . user . username ?? "" )
66
+ ) {
67
+ return ;
68
+ }
69
+ this . message . delete ( ) ;
46
70
}
47
71
48
- const bankTransactionsChannel = await getTextChannel (
49
- bankTransactionsChannelId
50
- ) ;
51
- let transactionContent = this . message . content + ` -- ✅ by ${ this . user } ` ;
52
- if ( ! this . message . author ?. bot ) {
53
- transactionContent = this . message . author ?. toString ( ) + ": " + transactionContent ;
54
- }
55
- bankTransactionsChannel ?. send ( transactionContent ) ;
56
- this . message . delete ( ) ;
57
72
}
58
73
}
0 commit comments