Skip to content

Commit 9eef9a6

Browse files
authored
Merge branch 'master' into auto-close-thread
2 parents dcf6fe6 + fd63972 commit 9eef9a6

File tree

7 files changed

+45
-13
lines changed

7 files changed

+45
-13
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
patreon: kyber

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ matrix:
66
dist: xenial
77

88
install:
9-
- pip install -r requirements.txt
10-
- pip install pylint
9+
- pipenv install
10+
- pipenv install pylint
1111

12-
script: python .lint.py
12+
script: python .lint.py

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ 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
- Threads will close automatically after some time when `thread_auto_close` is set.
13-
- Custom closing message can be set with `thread_auto_close_response`.
14-
14+
- Custom closing message can be set with `thread_auto_close_response`.
1515

1616
### Changed
1717
- Channel names now can contain unicode characters.

cogs/utility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ async def loop_presence(self):
683683
await self.bot.wait_until_ready()
684684
while not self.bot.is_closed():
685685
self.presence = await self.set_presence()
686-
await asyncio.sleep(3600)
686+
await asyncio.sleep(600)
687687

688688
@commands.command()
689689
@checks.has_permissions(PermissionLevel.ADMINISTRATOR)

core/thread.py

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

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

113126
self._channel = channel
114127

core/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def format_preview(messages: typing.List[typing.Dict[str, typing.Any]]):
7979
if message.get("type") in ("note", "internal"):
8080
continue
8181
author = message["author"]
82-
content = message["content"].replace("\n", " ")
82+
content = str(message["content"]).replace("\n", " ")
8383
name = author["name"] + "#" + str(author["discriminator"])
8484
prefix = "[M]" if author["mod"] else "[R]"
8585
out += truncate(f"`{prefix} {name}:` {content}", max=75) + "\n"

plugins/registry.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,23 @@
160160
"title": "Colors!!",
161161
"icon_url": "https://cdn1.iconfinder.com/data/icons/weather-19/32/rainbow-512.png",
162162
"thumbnail_url": "https://i.imgur.com/fSxnc9W.jpg"
163+
},
164+
"fun": {
165+
"repository": "TheKinG2149/modmail-plugins",
166+
"branch": "master",
167+
"description": "Some fun commands like 8ball,dadjokes",
168+
"bot_version": "2.24.1",
169+
"title": "Fun",
170+
"icon_url": "https://cdn.discordapp.com/attachments/584692239893135362/591588754142265354/43880032.png",
171+
"thumbnail_url": "https://cdn.discordapp.com/attachments/584692239893135362/591588754142265354/43880032.png"
172+
},
173+
"stats": {
174+
"repository": "MiTonder/modmail-plugins",
175+
"branch": "master",
176+
"description": "Get useful stats directly in an embed about either the ModMail bot, a user or the server.",
177+
"bot_version": "2.24.1",
178+
"title": "Get Stats",
179+
"icon_url": "https://image.flaticon.com/icons/png/512/117/117761.png",
180+
"thumbnail_url": "http://www.pngmart.com/files/7/Statistics-PNG-Clipart.png"
163181
}
164182
}

0 commit comments

Comments
 (0)