File tree Expand file tree Collapse file tree
backend/src/plugins/Automod/triggers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ interface HasAttachmentsMatchResult {
99}
1010
1111const configSchema = z . strictObject ( {
12- has : z . boolean ( ) ,
12+ min_count : z . number ( ) . int ( ) . min ( 0 ) . nullable ( ) . default ( 1 ) ,
13+ max_count : z . number ( ) . int ( ) . nullable ( ) . default ( null ) ,
1314} ) ;
1415
1516export const HasAttachmentsTrigger = automodTrigger < HasAttachmentsMatchResult > ( ) ( {
@@ -19,12 +20,17 @@ export const HasAttachmentsTrigger = automodTrigger<HasAttachmentsMatchResult>()
1920 if ( ! context . message ) {
2021 return ;
2122 }
23+ if ( triggerConfig . min_count == null && triggerConfig . max_count == null ) {
24+ return ;
25+ }
2226
2327 const attachments = context . message . data . attachments ;
2428 const attachmentCount = attachments ?. length ?? 0 ;
2529 const hasAttachments = attachmentCount > 0 ;
30+ const matchesMinCount = triggerConfig . min_count != null ? attachmentCount >= triggerConfig . min_count : true ;
31+ const matchesMaxCount = triggerConfig . max_count != null ? attachmentCount <= triggerConfig . max_count : true ;
2632
27- if ( hasAttachments === triggerConfig . has ) {
33+ if ( matchesMinCount && matchesMaxCount ) {
2834 return {
2935 extra : {
3036 hasAttachments,
You can’t perform that action at this time.
0 commit comments