@@ -47,9 +47,6 @@ async def _close_help_post(
47
47
scheduler : scheduling .Scheduler ,
48
48
) -> None :
49
49
"""Close the help post and record stats."""
50
- # Get Thread with updated metadata (such as the title)
51
- closed_post = await get_or_fetch_channel (bot .instance , closed_post .id )
52
-
53
50
embed = discord .Embed (description = CLOSED_POST_MSG )
54
51
close_title = "Python help channel closed"
55
52
if closing_reason == _stats .ClosingReason .CLEANUP :
@@ -192,10 +189,11 @@ async def get_closing_time(post: discord.Thread) -> tuple[arrow.Arrow, _stats.Cl
192
189
return time , _stats .ClosingReason .INACTIVE
193
190
194
191
195
- async def maybe_archive_idle_post (post : discord . Thread , scheduler : scheduling .Scheduler ) -> None :
192
+ async def maybe_archive_idle_post (post_id : int , scheduler : scheduling .Scheduler ) -> None :
196
193
"""Archive the `post` if idle, or schedule the archive for later if still active."""
197
194
try :
198
- await get_or_fetch_channel (bot .instance , post .id )
195
+ # Fetch the post again, to ensure we have the latest info
196
+ post = await get_or_fetch_channel (bot .instance , post_id )
199
197
except discord .HTTPException :
200
198
log .trace (f"Not closing missing post #{ post } ({ post .id } )." )
201
199
return
@@ -223,4 +221,4 @@ async def maybe_archive_idle_post(post: discord.Thread, scheduler: scheduling.Sc
223
221
delay = (closing_time - arrow .utcnow ()).seconds
224
222
log .info (f"#{ post } ({ post .id } ) is still active; scheduling it to be archived after { delay } seconds." )
225
223
226
- scheduler .schedule_later (delay , post .id , maybe_archive_idle_post (post , scheduler ))
224
+ scheduler .schedule_later (delay , post .id , maybe_archive_idle_post (post . id , scheduler ))
0 commit comments