Skip to content

Commit 6e05449

Browse files
committed
Send channel creation error to log channel - closes #303
1 parent 6138285 commit 6e05449

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010

1111
- Sponsors command that will list sponsors.
12+
- An alert will now be sent to the log channel if a thread channel fails to create. This could be due to a variety of problems such as insufficient permissions or the category channel limit is met.
1213

1314
### Changed
1415
- Channel names now can contain unicode characters.

core/thread.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,25 @@ async def setup(self, *, creator=None, category=None):
100100
if category is not None:
101101
overwrites = None
102102

103-
channel = await self.bot.modmail_guild.create_text_channel(
104-
name=self.manager.format_channel_name(recipient),
105-
category=category,
106-
overwrites=overwrites,
107-
reason="Creating a thread channel",
108-
)
103+
try:
104+
channel = await self.bot.modmail_guild.create_text_channel(
105+
name=self.manager.format_channel_name(recipient),
106+
category=category,
107+
overwrites=overwrites,
108+
reason="Creating a thread channel",
109+
)
110+
except discord.HTTPException as e: # Failed to create due to 50 channel limit.
111+
del self.manager.cache[self.id]
112+
log_channel = self.bot.log_channel
113+
114+
em = discord.Embed(color=discord.Color.red())
115+
em.title = 'Error while trying to create a thread'
116+
em.description = e.message
117+
em.add_field(name='Recipient', value=recipient.mention)
118+
119+
if log_channel is not None:
120+
return await log_channel.send(embed=em)
121+
109122

110123
self._channel = channel
111124

0 commit comments

Comments
 (0)