Skip to content

Commit d4352ef

Browse files
committed
Fix linked message id finding
1 parent cf68b05 commit d4352ef

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

bot.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,15 @@ async def on_message(self, message):
244244
async def on_message_delete(self, message):
245245
"""Support for deleting linked messages"""
246246
if message.embeds and not isinstance(message.channel, discord.DMChannel):
247-
matches = int(str(message.embeds[0].author.url).split('/')[-1])
247+
message_id = str(message.embeds[0].author.url).split('/')[-1]
248248
if matches:
249249
thread = await self.threads.find(channel=message.channel)
250250

251251
channel = thread.recipient.dm_channel
252-
message_id = matches[0]
253252

254253
async for msg in channel.history():
255254
if msg.embeds and msg.embeds[0].author:
256-
url = msg.embeds[0].author.url
255+
url = str(msg.embeds[0].author.url)
257256
if message_id == url.split('/')[-1]:
258257
return await msg.delete()
259258

@@ -265,8 +264,8 @@ async def on_message_edit(self, before, after):
265264
async for msg in thread.channel.history():
266265
if msg.embeds:
267266
embed = msg.embeds[0]
268-
matches = embed.author.url.split('/')
269-
if matches and int(matches[-1]) == before.id:
267+
matches = str(embed.author.url)split('/')
268+
if matches and matches[-1] == str(before.id):
270269
if ' - (Edited)' not in embed.footer.text:
271270
embed.set_footer(text=embed.footer.text + ' - (Edited)')
272271
embed.description = after.content

cogs/modmail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,11 @@ async def edit(self, ctx, message_id: Optional[int]=None, *, new_message):
254254
em = msg.embeds[0]
255255
if 'Moderator' not in str(em.footer.text):
256256
continue
257-
linked_message_id = int(em.author.url.split('/')[-1])
257+
linked_message_id = str(em.author.url).split('/')[-1]
258258
break
259259
elif message_id and msg.id == message_id:
260260
url = msg.embeds[0].author.url
261-
linked_message_id = int(url.split('/')[-1])
261+
linked_message_id = str(url).split('/')[-1]
262262
break
263263

264264
if not linked_message_id:

core/thread.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ async def _edit_thread_message(self, channel, message_id, message):
4949
if not msg.embeds:
5050
continue
5151
embed = msg.embeds[0]
52-
if embed and embed.author:
53-
if message_id == int(embed.author.url.split('/')[-1]):
52+
if embed and embed.author and embed.author.url:
53+
if str(message_id) == str(embed.author.url).split('/')[-1]:
5454
if ' - (Edited)' not in embed.footer.text:
5555
embed.set_footer(text=embed.footer.text + ' - (Edited)')
5656
embed.description = message

0 commit comments

Comments
 (0)