Skip to content

Commit efdc606

Browse files
committed
Merge branch 'development'
2 parents bdbebff + 9a8f61e commit efdc606

File tree

5 files changed

+42
-22
lines changed

5 files changed

+42
-22
lines changed

CHANGELOG.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
77
however, insignificant breaking changes do not guarantee a major version bump, see the reasoning [here](https://github.com/kyb3r/modmail/issues/319). If you're a plugin developer, note the "BREAKING" section.
88

9+
# v3.8.2
10+
11+
### Fixed
12+
13+
- Retry with `null-discrim` if channel could not be created. ([GH #2934](https://github.com/kyb3r/modmail/issues/2934))
14+
- Fix update notifications.
15+
- Retrieve user from Discord API if user has left the server, resolving issues in `?block`. ([GH #2935](https://github.com/kyb3r/modmail/issues/2935), [PR #2936](https://github.com/kyb3r/modmail/pull/2936))
16+
- IDs in `<member>` commands work now.
17+
918
# v3.8.1
1019

1120
### Fixed
1221

13-
- Additional image uploads now render properly. ([PR #2933](https://github.com/kyb3r/modmail/pull/2933)))
22+
- Additional image uploads now render properly. ([PR #2933](https://github.com/kyb3r/modmail/pull/2933))
1423
- `confirm_thread_creation` no longer raises unnecessary errors. ([GH #2931](https://github.com/kyb3r/modmail/issues/2931), [PR #2933](https://github.com/kyb3r/modmail/pull/2933))
1524
- Autotriggers no longer sends attachments back. ([GH #2932](https://github.com/kyb3r/modmail/issues/2932))
1625

17-
1826
# v3.8.0
1927

2028
### Added

bot.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "3.8.1"
1+
__version__ = "3.8.2"
22

33

44
import asyncio
@@ -1153,7 +1153,7 @@ async def on_typing(self, channel, user, _):
11531153

11541154
async def handle_reaction_events(self, payload):
11551155
user = self.get_user(payload.user_id)
1156-
if user.bot:
1156+
if user is None or user.bot:
11571157
return
11581158

11591159
channel = self.get_channel(payload.channel_id)
@@ -1519,7 +1519,7 @@ async def autoupdate(self):
15191519
)
15201520
logger.info("Bot has been updated.")
15211521
channel = self.log_channel
1522-
if self.bot.config["update_notifications"]:
1522+
if self.config["update_notifications"]:
15231523
await channel.send(embed=embed)
15241524
else:
15251525
try:
@@ -1548,7 +1548,7 @@ async def autoupdate(self):
15481548
embed.set_footer(
15491549
text=f"Updating Modmail v{self.version} " f"-> v{latest.version}"
15501550
)
1551-
if self.bot.config["update_notifications"]:
1551+
if self.config["update_notifications"]:
15521552
await channel.send(embed=embed)
15531553
else:
15541554
embed = discord.Embed(
@@ -1559,7 +1559,7 @@ async def autoupdate(self):
15591559
embed.set_footer(
15601560
text=f"Updating Modmail v{self.version} " f"-> v{latest.version}"
15611561
)
1562-
if self.bot.config["update_notifications"]:
1562+
if self.config["update_notifications"]:
15631563
await channel.send(embed=embed)
15641564
await self.logout()
15651565

cogs/modmail.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ async def logs(self, ctx, *, user: User = None):
680680
thread = ctx.thread
681681
if not thread:
682682
raise commands.MissingRequiredArgument(SimpleNamespace(name="member"))
683-
user = thread.recipient
683+
user = thread.recipient or await self.bot.fetch_user(thread.id)
684684

685685
default_avatar = "https://cdn.discordapp.com/embed/avatars/0.png"
686686
icon_url = getattr(user, "avatar_url", default_avatar)

core/thread.py

+21-12
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,27 @@ async def setup(self, *, creator=None, category=None, initial_message=None):
125125
overwrites=overwrites,
126126
reason="Creating a thread channel.",
127127
)
128-
except discord.HTTPException as e: # Failed to create due to missing perms.
129-
logger.critical("An error occurred while creating a thread.", exc_info=True)
130-
self.manager.cache.pop(self.id)
131-
132-
embed = discord.Embed(color=self.bot.error_color)
133-
embed.title = "Error while trying to create a thread."
134-
embed.description = str(e)
135-
embed.add_field(name="Recipient", value=recipient.mention)
136-
137-
if self.bot.log_channel is not None:
138-
await self.bot.log_channel.send(embed=embed)
139-
return
128+
except discord.HTTPException as e:
129+
# try again but null-discrim (name could be banned)
130+
try:
131+
channel = await self.bot.modmail_guild.create_text_channel(
132+
name=format_channel_name(recipient, self.bot.modmail_guild, force_null=True),
133+
category=category,
134+
overwrites=overwrites,
135+
reason="Creating a thread channel.",
136+
)
137+
except discord.HTTPException as e: # Failed to create due to missing perms.
138+
logger.critical("An error occurred while creating a thread.", exc_info=True)
139+
self.manager.cache.pop(self.id)
140+
141+
embed = discord.Embed(color=self.bot.error_color)
142+
embed.title = "Error while trying to create a thread."
143+
embed.description = str(e)
144+
embed.add_field(name="Recipient", value=recipient.mention)
145+
146+
if self.bot.log_channel is not None:
147+
await self.bot.log_channel.send(embed=embed)
148+
return
140149

141150
self._channel = channel
142151

core/utils.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def strtobool(val):
4747
raise
4848

4949

50-
class User(commands.IDConverter):
50+
class User(commands.MemberConverter):
5151
"""
5252
A custom discord.py `Converter` that
5353
supports `Member`, `User`, and string ID's.
@@ -339,9 +339,12 @@ def escape_code_block(text):
339339
return re.sub(r"```", "`\u200b``", text)
340340

341341

342-
def format_channel_name(author, guild, exclude_channel=None):
342+
def format_channel_name(author, guild, exclude_channel=None, force_null=False):
343343
"""Sanitises a username for use with text channel names"""
344344
name = author.name.lower()
345+
if force_null:
346+
name = "null"
347+
345348
name = new_name = (
346349
"".join(l for l in name if l not in string.punctuation and l.isprintable()) or "null"
347350
) + f"-{author.discriminator}"

0 commit comments

Comments
 (0)