@@ -39,7 +39,7 @@ export class AutoModManager {
39
39
}
40
40
41
41
private addToLastReports ( mods : IModWithFlags [ ] ) {
42
- this . lastReports = [ mods , ...this . lastReports ] . filter ( ( v , i ) => i <= 9 ) ;
42
+ this . lastReports = [ mods , ...this . lastReports . filter ( ( v , i ) => i <= 9 ) ] ;
43
43
}
44
44
45
45
private constructor ( client : ClientExt ) {
@@ -102,16 +102,17 @@ export class AutoModManager {
102
102
results . push ( await analyseMod ( mod , this . AutoModRules , user ) )
103
103
}
104
104
this . addToLastReports ( results ) ;
105
- const concerns = results . filter ( m => ( m . flags . high . length ) !== 0 ) ;
106
- if ( ! concerns . length ) {
105
+ // const concerns = results.filter(m => (m.flags.high.length) !== 0);
106
+ // if (!concerns.length) {
107
+ if ( ! results . length ) {
107
108
logMessage ( 'No mods with concerns found.' )
108
109
return ;
109
110
}
110
111
else {
111
112
try {
112
- logMessage ( 'Reporting mods:' , concerns . map ( c => `${ c . mod . name } - ${ c . flags . high . join ( ', ' ) } - ${ c . flags . low . join ( ', ' ) } ` ) ) ;
113
- await PublishToSlack ( flagsToSlackMessage ( concerns ) ) ;
114
- await PublishToDiscord ( flagsToDiscordEmbeds ( concerns ) )
113
+ logMessage ( 'Reporting mods:' , results . map ( c => `${ c . mod . name } - ${ c . flags . high . join ( ', ' ) } - ${ c . flags . low . join ( ', ' ) } ` ) ) ;
114
+ await PublishToSlack ( flagsToSlackMessage ( results ) ) ;
115
+ await PublishToDiscord ( flagsToDiscordEmbeds ( results ) ) ;
115
116
}
116
117
catch ( err ) {
117
118
logMessage ( 'Error posting automod to Discord or Slack' , err , true )
@@ -159,6 +160,7 @@ function flagsToSlackMessage(data: IModWithFlags[]): ISlackMessage {
159
160
text : `<${ modLink } |${ input . mod . name } > uploaded by <${ userLink } |${ input . mod . uploader ?. name } >\n` +
160
161
`<!date^${ uploadTime } ^Posted {time_secs} {date_short_pretty}|${ input . mod . createdAt } >\n\n` +
161
162
`<!date^${ joinTime } ^User Joined {time_secs} {date_short_pretty}|${ input . mod . uploader ?. joined } >\n\n` +
163
+ `*Game:* ${ input . mod . game ?. name ?? 'Unknown Game' } ` +
162
164
`*Flags:*\n${ [ ...input . flags . high . map ( f => `- ${ f } [HIGH]` ) , ...input . flags . low . map ( f => `- ${ f } [LOW]` ) ] . join ( '\n' ) } \n` +
163
165
`<https://www.nexusmods.com/admin/members/ban?ban_action=1&user_id=${ userId } |Ban> | <https://www.nexusmods.com/admin/members/ipuse?uid=${ userId } |IP History>`
164
166
} ,
@@ -170,13 +172,16 @@ function flagsToSlackMessage(data: IModWithFlags[]): ISlackMessage {
170
172
}
171
173
} )
172
174
175
+ // Are there any concerns that require a ping?
176
+ const pingable : boolean = data . filter ( m => ( m . flags . high . length ) > 0 ) . length > 0 ;
177
+
173
178
return {
174
179
blocks : [
175
180
{
176
181
type : 'header' ,
177
182
text : {
178
183
type : 'plain_text' ,
179
- text : 'Mod spam detected'
184
+ text : pingable ? 'Mod spam detected' : 'Automod report '
180
185
}
181
186
} ,
182
187
{
@@ -186,13 +191,13 @@ function flagsToSlackMessage(data: IModWithFlags[]): ISlackMessage {
186
191
{
187
192
type : 'divider'
188
193
} ,
189
- {
194
+ pingable ? {
190
195
type : 'section' ,
191
196
text : {
192
197
type : 'mrkdwn' ,
193
198
text : 'FAO <!subteam^SC2Q2J1DF>'
194
199
}
195
- }
200
+ } : { type : 'divider' }
196
201
]
197
202
}
198
203
}
@@ -226,9 +231,12 @@ function flagsToDiscordEmbeds(data: IModWithFlags[]): RESTPostAPIWebhookWithToke
226
231
227
232
return embed . toJSON ( )
228
233
}
234
+
235
+ // Are there any concerns that require a ping?
236
+ const pingable : boolean = data . filter ( m => ( m . flags . high . length ) > 0 ) . length > 0 ;
229
237
230
238
return {
231
- content : "# Mod Spam Detected\n@here" , //role pings <@&1308814010602487839> <@&520360132631199744>
239
+ content : pingable ? "# Mod Spam Detected\n@here" : "# Automod Detections ", //role pings <@&1308814010602487839> <@&520360132631199744>
232
240
username : "Automod" ,
233
241
embeds : data . map ( modEmbeds )
234
242
}
0 commit comments