@@ -58,26 +58,26 @@ public static async Task<bool> CheckMutesAsync()
58
58
}
59
59
}
60
60
61
- public static async Task < bool > CheckAutomaticWarningsAsync ( )
61
+ // Cleans up public messages for automatic warnings & bans for compromised accounts
62
+ public static async Task < bool > CleanUpPunishmentMessagesAsync ( )
62
63
{
63
- if ( Program . cfgjson . AutoWarnMsgAutoDeleteDays == 0 )
64
+ if ( Program . cfgjson . AutoWarnMsgAutoDeleteDays == 0 && Program . cfgjson . CompromisedAccountBanMsgAutoDeleteDays == 0 )
64
65
return false ;
65
-
66
- Dictionary < string , UserWarning > warnList = Program . db . HashGetAll ( "automaticWarnings" ) . ToDictionary (
67
- x => x . Name . ToString ( ) ,
68
- x => JsonConvert . DeserializeObject < UserWarning > ( x . Value )
69
- ) ;
70
-
71
- if ( warnList is null | warnList . Keys . Count == 0 )
72
- return false ;
73
- else
66
+
67
+ // The success value will be changed later if any of the message deletes are successful.
68
+ bool success = false ;
69
+
70
+ if ( Program . cfgjson . AutoWarnMsgAutoDeleteDays > 0 )
74
71
{
75
- // The success value will be changed later if any of the message deletes are successful.
76
- bool success = false ;
72
+ Dictionary < string , UserWarning > warnList = Program . db . HashGetAll ( "automaticWarnings" ) . ToDictionary (
73
+ x => x . Name . ToString ( ) ,
74
+ x => JsonConvert . DeserializeObject < UserWarning > ( x . Value )
75
+ ) ;
76
+
77
77
foreach ( KeyValuePair < string , UserWarning > entry in warnList )
78
78
{
79
79
UserWarning warn = entry . Value ;
80
- if ( DateTime . Now > warn . WarnTimestamp . AddDays ( Program . cfgjson . AutoWarnMsgAutoDeleteDays ) )
80
+ if ( DateTime . Now > warn . WarnTimestamp . AddSeconds ( Program . cfgjson . AutoWarnMsgAutoDeleteDays ) )
81
81
{
82
82
try
83
83
{
@@ -94,32 +94,20 @@ public static async Task<bool> CheckAutomaticWarningsAsync()
94
94
}
95
95
}
96
96
}
97
- Program . discord . Logger . LogDebug ( Program . CliptokEventID , "Checked automatic warnings at {time} with result: {result}" , DateTime . Now , success ) ;
98
- return success ;
99
97
}
100
- }
101
-
102
- public static async Task < bool > CheckCompromisedAccountBansAsync ( )
103
- {
104
- if ( Program . cfgjson . CompromisedAccountBanMsgAutoDeleteDays == 0 )
105
- return false ;
106
-
107
- Dictionary < string , MemberPunishment > banList = Program . db . HashGetAll ( "compromisedAccountBans" ) . ToDictionary (
108
- x => x . Name . ToString ( ) ,
109
- x => JsonConvert . DeserializeObject < MemberPunishment > ( x . Value )
110
- ) ;
111
-
112
- if ( banList . Keys . Count == 0 )
113
- return false ;
114
- else
98
+
99
+ if ( Program . cfgjson . CompromisedAccountBanMsgAutoDeleteDays > 0 )
115
100
{
116
- // The success value will be changed later if any of the message deletes are successful.
117
- bool success = false ;
101
+ Dictionary < string , MemberPunishment > banList = Program . db . HashGetAll ( "compromisedAccountBans" ) . ToDictionary (
102
+ x => x . Name . ToString ( ) ,
103
+ x => JsonConvert . DeserializeObject < MemberPunishment > ( x . Value )
104
+ ) ;
105
+
118
106
foreach ( KeyValuePair < string , MemberPunishment > entry in banList )
119
107
{
120
108
MemberPunishment ban = entry . Value ;
121
-
122
- if ( DateTime . Now > ban . ActionTime . Value . AddDays ( Program . cfgjson . CompromisedAccountBanMsgAutoDeleteDays ) )
109
+
110
+ if ( DateTime . Now > ban . ActionTime . Value . AddSeconds ( Program . cfgjson . CompromisedAccountBanMsgAutoDeleteDays ) )
123
111
{
124
112
try
125
113
{
@@ -136,9 +124,10 @@ public static async Task<bool> CheckCompromisedAccountBansAsync()
136
124
}
137
125
}
138
126
}
139
- Program . discord . Logger . LogDebug ( Program . CliptokEventID , "Checked compromised account bans at {time} with result: {result}" , DateTime . Now , success ) ;
140
- return success ;
141
127
}
128
+
129
+ Program . discord . Logger . LogDebug ( Program . CliptokEventID , "Checked for auto-warn and compromised account ban messages at {time} with result: {result}" , DateTime . Now , success ) ;
130
+ return success ;
142
131
}
143
132
}
144
133
0 commit comments