File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -204,18 +204,26 @@ async def on_ready(self):
204
204
await self .threads .populate_cache ()
205
205
await self .config .update ()
206
206
207
- closures = self .config .get ('closures' , {})
207
+ closures = self .config .get ('closures' , {}). copy ()
208
208
print (closures ) # for debugging
209
209
for recipient_id , items in closures .items ():
210
210
after = (datetime .datetime .fromisoformat (items ['time' ]) -
211
211
datetime .datetime .utcnow ()).total_seconds ()
212
212
if after < 0 :
213
213
after = 0
214
214
recipient = self .get_user (int (recipient_id ))
215
- print ( recipient )
215
+
216
216
thread = await self .threads .find (
217
217
recipient = recipient )
218
- print (thread )
218
+
219
+ if not thread :
220
+ # If the recipient is gone or channel is deleted
221
+ closures = self .config .get ('closures' , {})
222
+ closures .pop (str (recipient_id ))
223
+ self .config ['closures' ] = closures
224
+ await self .config .update ()
225
+ continue
226
+
219
227
# TODO: Retrieve messages/replies when bot is down, from history?
220
228
await thread .close (closer = self .get_user (items ['closer_id' ]),
221
229
after = after ,
You can’t perform that action at this time.
0 commit comments