Skip to content

Commit 371806d

Browse files
committed
Merge branch 'master' of https://github.com/verixx/modmail
2 parents 5ce0ddc + 82494ad commit 371806d

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
# 2.15.0
7+
# v2.15.0
88

99
### What's new?
1010

bot.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,9 @@ async def convert_emoji(self, name):
439439

440440
if name not in UNICODE_EMOJI:
441441
try:
442-
return await converter.convert(
443-
ctx, sent_emoji.strip(':')
444-
)
442+
name = await converter.convert(ctx, name.strip(':'))
445443
except commands.BadArgument:
446-
pass
444+
logger.warning(f'{name} is not a valid emoji.')
447445
return name
448446

449447
async def retrieve_emoji(self):
@@ -456,7 +454,6 @@ async def retrieve_emoji(self):
456454
sent_emoji = self.config.get('sent_emoji', '✅')
457455
blocked_emoji = self.config.get('blocked_emoji', '🚫')
458456

459-
460457
if sent_emoji not in UNICODE_EMOJI:
461458
try:
462459
sent_emoji = await converter.convert(
@@ -660,25 +657,28 @@ async def on_raw_reaction_add(self, payload):
660657

661658
channel = self.get_channel(payload.channel_id)
662659

663-
if not channel: # dm channel not in internal cache
660+
if not channel: # dm channel not in internal cache
664661
_thread = await self.threads.find(recipient=user)
665662
if not _thread:
666663
return
667664
channel = await _thread.recipient.create_dm()
668665

669-
message = await channel.get_message(payload.message_id) # TODO: change to fetch_message (breaking change in d.py)
666+
# TODO: change to fetch_message (breaking change in d.py)
667+
message = await channel.get_message(payload.message_id)
670668
reaction = payload.emoji
671669

672670
close_emoji = await self.convert_emoji(self.config.get('close_emoji', '🔒'))
673671

674-
if isinstance(channel, discord.DMChannel) and str(reaction) == str(close_emoji): # closing thread
672+
if isinstance(channel, discord.DMChannel) and str(reaction) == str(close_emoji): # closing thread
675673
thread = await self.threads.find(recipient=user)
676674
ts = message.embeds[0].timestamp if message.embeds else None
677675
if thread and ts == thread.channel.created_at:
678676
# the reacted message is the corresponding thread creation embed
679677
if not self.config.get('disable_recipient_thread_close'):
680678
await thread.close(closer=user)
681679
elif not isinstance(channel, discord.DMChannel):
680+
if not message.embeds:
681+
return
682682
message_id = str(message.embeds[0].author.url).split('/')[-1]
683683
if message_id.isdigit():
684684
thread = await self.threads.find(channel=message.channel)
@@ -689,7 +689,6 @@ async def on_raw_reaction_add(self, payload):
689689
if msg.id == int(message_id):
690690
await msg.add_reaction(reaction)
691691

692-
693692
async def on_guild_channel_delete(self, channel):
694693
if channel.guild != self.modmail_guild:
695694
return

core/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ def main_color(self) -> typing.Union[Color, int]:
140140
async def process_modmail(self, message: Message) -> None:
141141
raise NotImplementedError
142142

143+
@abc.abstractmethod
144+
async def convert_emoji(self, name: str) -> str:
145+
raise NotImplementedError
146+
143147
@staticmethod
144148
@abc.abstractmethod
145149
def overwrites(ctx: commands.Context) -> dict:

core/thread.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,15 @@ async def send_info_embed():
152152
footer = 'Click the lock to close the thread'
153153

154154
footer = self.bot.config.get('thread_creation_footer', footer)
155-
156-
157-
embed.set_footer(text=footer,
158-
icon_url=self.bot.guild.icon_url)
159-
155+
embed.set_footer(text=footer, icon_url=self.bot.guild.icon_url)
160156
embed.title = self.bot.config.get('thread_creation_title', 'Thread Created')
161157

162-
163158
if creator is None:
164159
msg = await recipient.send(embed=embed)
165160
if not self.bot.config.get('disable_recipient_thread_close'):
166161
close_emoji = self.bot.config.get('close_emoji', '🔒')
167162
close_emoji = await self.bot.convert_emoji(close_emoji)
168163
await msg.add_reaction(close_emoji)
169-
170164

171165
def _close_after(self, closer, silent, delete_channel, message):
172166
return self.bot.loop.create_task(
@@ -243,6 +237,7 @@ async def _close(self, closer, silent=False, delete_channel=True,
243237
desc += truncate(sneak_peak, max=75 - 13)
244238
else:
245239
desc = "Could not resolve log url."
240+
log_url = None
246241

247242
embed = discord.Embed(description=desc, color=discord.Color.red())
248243

@@ -276,7 +271,6 @@ async def _close(self, closer, silent=False, delete_channel=True,
276271
color=discord.Color.red(),
277272
timestamp=datetime.utcnow())
278273

279-
280274
if not message:
281275
if self.id == closer.id:
282276
message = self.bot.config.get(
@@ -691,7 +685,7 @@ def _format_info_embed(self, user, log_url, log_count, color):
691685
role_names = ''
692686
if member:
693687
sep_server = self.bot.using_multiple_server_setup
694-
seperator = ', ' if sep_server else ' '
688+
separator = ', ' if sep_server else ' '
695689

696690
roles = []
697691

@@ -702,12 +696,13 @@ def _format_info_embed(self, user, log_url, log_count, color):
702696
fmt = role.name if sep_server else role.mention
703697
roles.append(fmt)
704698

705-
if len(seperator.join(roles)) > 1000:
706-
roles.pop()
699+
if len(separator.join(roles)) > 1024:
707700
roles.append('...')
701+
while len(separator.join(roles)) > 1024:
702+
roles.pop(-2)
708703
break
709-
710-
role_names = seperator.join(roles)
704+
705+
role_names = separator.join(roles)
711706

712707
embed = discord.Embed(color=color,
713708
description=user.mention,

0 commit comments

Comments
 (0)