Skip to content

Commit 602a185

Browse files
committed
Fix thread duplication bug
1 parent 1f61d98 commit 602a185

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ 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+
8+
# v2.8.1
9+
### Fixed
10+
- Fixed bug where thread logs were getting duplicated when using the contact command.
11+
712
# v2.8.0
813
### Changed
914
- Major improvement in thread log viewing.

bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = '2.8.0'
25+
__version__ = '2.8.1'
2626

2727
import asyncio
2828
import textwrap

core/thread.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ async def reply(self, message):
189189
# to user
190190
self.send(message, self.recipient, from_mod=True)
191191
]
192+
193+
self.bot.loop.create_task(
194+
self.bot.modmail_api.append_log(message, self.channel.id)
195+
)
192196

193197
if self.close_task is not None:
194198
# cancel closing if a thread message is sent.
@@ -207,17 +211,16 @@ async def send(self, message, destination=None, from_mod=False):
207211
await self.channel.send(embed=discord.Embed(
208212
color=discord.Color.red(),
209213
description='Scheduled close has been cancelled.'))
214+
215+
if not from_mod:
216+
self.bot.loop.create_task(
217+
self.bot.modmail_api.append_log(message, self.channel.id)
218+
)
210219

211220
if not self.ready:
212221
await self.wait_until_ready()
213222

214223
destination = destination or self.channel
215-
if from_mod and not isinstance(destination, discord.User):
216-
self.bot.loop.create_task(
217-
self.bot.modmail_api.append_log(message))
218-
elif not from_mod:
219-
self.bot.loop.create_task(
220-
self.bot.modmail_api.append_log(message, destination.id))
221224

222225
author = message.author
223226

@@ -431,8 +434,7 @@ async def create(self, recipient, *, creator=None, category=None):
431434
thread.channel = channel
432435

433436
log_url, log_data = await asyncio.gather(
434-
self.bot.modmail_api.get_log_url(recipient, channel,
435-
creator or recipient),
437+
self.bot.modmail_api.get_log_url(recipient, channel, creator or recipient),
436438
self.bot.modmail_api.get_user_logs(recipient.id)
437439
# self.get_dominant_color(recipient.avatar_url)
438440
)

0 commit comments

Comments
 (0)