Skip to content

Commit 48e801d

Browse files
DAzViseDAzVise
DAzVise
authored and
DAzVise
committed
better logic
1 parent b41acc7 commit 48e801d

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

cogs/modmail.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ async def contact(
900900
await ctx.channel.send(embed=embed)
901901

902902
else:
903-
thread = self.bot.threads.create(user, creator=ctx.author, category=category)
903+
thread = await self.bot.threads.create(user, creator=ctx.author, category=category)
904904
if self.bot.config["dm_disabled"] >= 1:
905905
logger.info("Contacting user %s when Modmail DM is disabled.", user)
906906

core/thread.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async def setup(self, *, creator=None, category=None):
9797
overwrites=overwrites,
9898
reason="Creating a thread channel.",
9999
)
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.
101101
logger.critical("An error occurred while creating a thread.", exc_info=True)
102102
self.manager.cache.pop(self.id)
103103

@@ -860,18 +860,17 @@ async def create(
860860

861861
# Schedule thread setup for later
862862
cat = self.bot.main_category
863-
if len(cat.channels) == 50:
863+
if category is None and len(cat.channels) == 50:
864864
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()
875874

876875
self.bot.loop.create_task(thread.setup(creator=creator, category=category))
877876
return thread

0 commit comments

Comments
 (0)