File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2664,14 +2664,27 @@ async def create(
26642664 self .bot .config ["confirm_thread_creation_deny" ],
26652665 )
26662666 )
2667- confirm = await destination .send (
2668- embed = discord .Embed (
2669- title = self .bot .config ["confirm_thread_creation_title" ],
2670- description = self .bot .config ["confirm_thread_response" ],
2671- color = self .bot .main_color ,
2672- ),
2673- view = view ,
2674- )
2667+ try :
2668+ confirm = await destination .send (
2669+ embed = discord .Embed (
2670+ title = self .bot .config ["confirm_thread_creation_title" ],
2671+ description = self .bot .config ["confirm_thread_response" ],
2672+ color = self .bot .main_color ,
2673+ ),
2674+ view = view ,
2675+ )
2676+ except discord .Forbidden :
2677+ # Recipient has DMs disabled (or otherwise unreachable). Without this,
2678+ # the thread would stay stuck in cache in a "not ready" state until a
2679+ # bot restart, since view.wait() below would never run.
2680+ logger .warning (
2681+ "Could not send confirm-thread-creation message to %s, DMs are likely disabled." ,
2682+ recipient ,
2683+ )
2684+ thread .cancelled = True
2685+ del self .cache [recipient .id ]
2686+ return thread
2687+
26752688 await view .wait ()
26762689 if view .value is None :
26772690 thread .cancelled = True
You can’t perform that action at this time.
0 commit comments