@@ -39,19 +39,40 @@ public async void Emit(LogEvent logEvent)
39
39
return ;
40
40
}
41
41
42
- if ( dummyWriter . ToString ( ) . Length > 1984 && dummyWriter . ToString ( ) . Length < 4096 )
42
+ string extraText = "" ;
43
+
44
+ if (
45
+ Program . cfgjson . PingBotOwnersOnBadErrors &&
46
+ logEvent . Level >= LogEventLevel . Error &&
47
+ logEvent . Exception is not null &&
48
+ (
49
+ logEvent . Exception . GetType ( ) == typeof ( NullReferenceException ) ||
50
+ logEvent . Exception . GetType ( ) == typeof ( RedisTimeoutException )
51
+ )
52
+ )
53
+ {
54
+ var pingList = Program . cfgjson . BotOwners . Select ( x => $ "<@{ x } >") . ToList ( ) ;
55
+ extraText = string . Join ( ", " , pingList ) ;
56
+ }
57
+
58
+ if ( dummyWriter . ToString ( ) . Length > ( 1984 - extraText . Length ) && dummyWriter . ToString ( ) . Length < ( 4096 - extraText . Length ) )
43
59
{
44
- LogChannelHelper . LogMessageAsync ( "errors" , new DiscordEmbedBuilder ( ) . WithDescription ( $ "```cs\n { dummyWriter } \n ```") ) ;
60
+ LogChannelHelper . LogMessageAsync ( "errors" , new DiscordMessageBuilder ( ) . AddEmbed ( new DiscordEmbedBuilder ( ) . WithDescription ( $ "{ extraText } \n ```cs\n { dummyWriter } \n ```") ) . WithAllowedMentions ( Mentions . All ) ) ;
45
61
46
62
}
47
- else if ( dummyWriter . ToString ( ) . Length < 1984 )
63
+ else if ( dummyWriter . ToString ( ) . Length < ( 1984 - extraText . Length ) )
48
64
{
49
- LogChannelHelper . LogMessageAsync ( "errors" , $ " ```cs\n { dummyWriter } \n ```") ;
65
+ LogChannelHelper . LogMessageAsync ( "errors" , new DiscordMessageBuilder ( ) . WithContent ( $ " { extraText } \n ```cs\n { dummyWriter } \n ```") . WithAllowedMentions ( Mentions . All ) ) ;
50
66
}
51
67
else
52
68
{
53
69
var stream = new MemoryStream ( Encoding . UTF8 . GetBytes ( dummyWriter . ToString ( ) ) ) ;
54
- LogChannelHelper . LogMessageAsync ( "errors" , new DiscordMessageBuilder ( ) . AddFile ( "error.txt" , stream ) ) ;
70
+ var resp = new DiscordMessageBuilder ( ) . AddFile ( "error.txt" , stream ) . WithAllowedMentions ( Mentions . All ) ;
71
+ if ( extraText . Length > 0 )
72
+ {
73
+ resp . WithContent ( extraText ) ;
74
+ }
75
+ LogChannelHelper . LogMessageAsync ( "errors" , resp ) ;
55
76
}
56
77
}
57
78
catch
0 commit comments