@@ -97,7 +97,7 @@ async def setup(self, *, creator=None, category=None):
97
97
overwrites = overwrites ,
98
98
reason = "Creating a thread channel." ,
99
99
)
100
- except discord .HTTPException as e : # Failed to create due to 50 channel limit .
100
+ except discord .HTTPException as e : # Failed to create due to missing perms .
101
101
logger .critical ("An error occurred while creating a thread." , exc_info = True )
102
102
self .manager .cache .pop (self .id )
103
103
@@ -860,18 +860,17 @@ async def create(
860
860
861
861
# Schedule thread setup for later
862
862
cat = self .bot .main_category
863
- if len (cat .channels ) == 50 :
863
+ if category is None and len (cat .channels ) == 50 :
864
864
fallback_id = self .bot .config ["fallback_category_id" ]
865
- fallback = discord .utils .get (cat .guild .categories , id = int (fallback_id ))
866
- if fallback and len (fallback .channels ) != 50 :
867
- self .bot .loop .create_task (thread .setup (creator = creator , category = fallback ))
868
- return thread
869
-
870
- fallback = await cat .clone (name = "Fallback Modmail" )
871
- self .bot .config .set ("fallback_category_id" , fallback .id )
872
- await self .bot .config .update ()
873
- self .bot .loop .create_task (thread .setup (creator = creator , category = fallback ))
874
- return thread
865
+ if fallback_id :
866
+ fallback = discord .utils .get (cat .guild .categories , id = int (fallback_id ))
867
+ if fallback and len (fallback .channels ) != 50 :
868
+ category = fallback
869
+
870
+ if not category :
871
+ category = await cat .clone (name = "Fallback Modmail" )
872
+ self .bot .config .set ("fallback_category_id" , category .id )
873
+ await self .bot .config .update ()
875
874
876
875
self .bot .loop .create_task (thread .setup (creator = creator , category = category ))
877
876
return thread
0 commit comments