Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjr committed Jan 14, 2021
2 parents bdbebff + 9a8f61e commit efdc606
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 22 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
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.

# v3.8.2

### Fixed

- Retry with `null-discrim` if channel could not be created. ([GH #2934](https://github.com/kyb3r/modmail/issues/2934))
- Fix update notifications.
- 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))
- IDs in `<member>` commands work now.

# v3.8.1

### Fixed

- Additional image uploads now render properly. ([PR #2933](https://github.com/kyb3r/modmail/pull/2933)))
- Additional image uploads now render properly. ([PR #2933](https://github.com/kyb3r/modmail/pull/2933))
- `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))
- Autotriggers no longer sends attachments back. ([GH #2932](https://github.com/kyb3r/modmail/issues/2932))


# v3.8.0

### Added
Expand Down
10 changes: 5 additions & 5 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "3.8.1"
__version__ = "3.8.2"


import asyncio
Expand Down Expand Up @@ -1153,7 +1153,7 @@ async def on_typing(self, channel, user, _):

async def handle_reaction_events(self, payload):
user = self.get_user(payload.user_id)
if user.bot:
if user is None or user.bot:
return

channel = self.get_channel(payload.channel_id)
Expand Down Expand Up @@ -1519,7 +1519,7 @@ async def autoupdate(self):
)
logger.info("Bot has been updated.")
channel = self.log_channel
if self.bot.config["update_notifications"]:
if self.config["update_notifications"]:
await channel.send(embed=embed)
else:
try:
Expand Down Expand Up @@ -1548,7 +1548,7 @@ async def autoupdate(self):
embed.set_footer(
text=f"Updating Modmail v{self.version} " f"-> v{latest.version}"
)
if self.bot.config["update_notifications"]:
if self.config["update_notifications"]:
await channel.send(embed=embed)
else:
embed = discord.Embed(
Expand All @@ -1559,7 +1559,7 @@ async def autoupdate(self):
embed.set_footer(
text=f"Updating Modmail v{self.version} " f"-> v{latest.version}"
)
if self.bot.config["update_notifications"]:
if self.config["update_notifications"]:
await channel.send(embed=embed)
await self.logout()

Expand Down
2 changes: 1 addition & 1 deletion cogs/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ async def logs(self, ctx, *, user: User = None):
thread = ctx.thread
if not thread:
raise commands.MissingRequiredArgument(SimpleNamespace(name="member"))
user = thread.recipient
user = thread.recipient or await self.bot.fetch_user(thread.id)

default_avatar = "https://cdn.discordapp.com/embed/avatars/0.png"
icon_url = getattr(user, "avatar_url", default_avatar)
Expand Down
33 changes: 21 additions & 12 deletions core/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,27 @@ async def setup(self, *, creator=None, category=None, initial_message=None):
overwrites=overwrites,
reason="Creating a thread channel.",
)
except discord.HTTPException as e: # Failed to create due to missing perms.
logger.critical("An error occurred while creating a thread.", exc_info=True)
self.manager.cache.pop(self.id)

embed = discord.Embed(color=self.bot.error_color)
embed.title = "Error while trying to create a thread."
embed.description = str(e)
embed.add_field(name="Recipient", value=recipient.mention)

if self.bot.log_channel is not None:
await self.bot.log_channel.send(embed=embed)
return
except discord.HTTPException as e:
# try again but null-discrim (name could be banned)
try:
channel = await self.bot.modmail_guild.create_text_channel(
name=format_channel_name(recipient, self.bot.modmail_guild, force_null=True),
category=category,
overwrites=overwrites,
reason="Creating a thread channel.",
)
except discord.HTTPException as e: # Failed to create due to missing perms.
logger.critical("An error occurred while creating a thread.", exc_info=True)
self.manager.cache.pop(self.id)

embed = discord.Embed(color=self.bot.error_color)
embed.title = "Error while trying to create a thread."
embed.description = str(e)
embed.add_field(name="Recipient", value=recipient.mention)

if self.bot.log_channel is not None:
await self.bot.log_channel.send(embed=embed)
return

self._channel = channel

Expand Down
7 changes: 5 additions & 2 deletions core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def strtobool(val):
raise


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


def format_channel_name(author, guild, exclude_channel=None):
def format_channel_name(author, guild, exclude_channel=None, force_null=False):
"""Sanitises a username for use with text channel names"""
name = author.name.lower()
if force_null:
name = "null"

name = new_name = (
"".join(l for l in name if l not in string.punctuation and l.isprintable()) or "null"
) + f"-{author.discriminator}"
Expand Down

0 comments on commit efdc606

Please sign in to comment.