Skip to content

Commit d3ac723

Browse files
committed
Fixed a one off bug for Raring
1 parent a0249f5 commit d3ac723

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ 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+
#v2.0.4
8+
9+
### Fixed
10+
- Fixed a one off bug where the channel topic dissapears, but modmail operations should still continue
11+
- Fixed linked_message_id issues.
12+
713
# v2.0.3
814

915
Fixed some issues with how data is displayed in the info embed.

bot.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = '2.0.3'
25+
__version__ = '2.0.4'
2626

2727
import asyncio
2828
import textwrap
@@ -120,10 +120,14 @@ def modmail_guild(self):
120120
return self.guild
121121
else:
122122
return discord.utils.get(self.guilds, id=int(modmail_guild_id))
123+
124+
@property
125+
def using_multiple_server_setup(self):
126+
return self.modmail_guild != self.guild
123127

124128
@property
125129
def main_category(self):
126-
if self.guild:
130+
if self.modmail_guild:
127131
return discord.utils.get(self.modmail_guild.categories, name='Mod Mail')
128132

129133
@property
@@ -245,7 +249,7 @@ async def on_message_delete(self, message):
245249
"""Support for deleting linked messages"""
246250
if message.embeds and not isinstance(message.channel, discord.DMChannel):
247251
message_id = str(message.embeds[0].author.url).split('/')[-1]
248-
if matches:
252+
if message_id.isdigit():
249253
thread = await self.threads.find(channel=message.channel)
250254

251255
channel = thread.recipient.dm_channel

core/thread.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ def __init__(self, bot):
135135

136136
async def populate_cache(self):
137137
for channel in self.bot.modmail_guild.text_channels:
138+
if not self.bot.using_multiple_server_setup and channel.category != self.main_category:
139+
continue
138140
await self.find(channel=channel)
139141

142+
140143
def __len__(self):
141144
return len(self.cache)
142145

@@ -177,15 +180,15 @@ async def _find_from_channel(self, channel):
177180
if channel.topic and 'User ID: ' in channel.topic:
178181
user_id = int(re.findall(r'\d+', channel.topic)[0])
179182

180-
# BUG: This wont work with multiple categories.
181-
# elif channel.topic is None:
182-
# async for message in channel.history(limit=50):
183-
# if message.embeds:
184-
# em = message.embeds[0]
185-
# matches = re.findall(r'<@(\d+)>', str(em.description))
186-
# if matches:
187-
# user_id = int(matches[-1])
188-
# break
183+
# BUG: When discord fails to create channel topic. search through message history
184+
elif channel.topic is None:
185+
async for message in channel.history(limit=50):
186+
if message.embeds:
187+
em = message.embeds[0]
188+
matches = re.findall(r'User ID: (\d+)', str(em.footer.text))
189+
if matches:
190+
user_id = int(matches[0])
191+
break
189192

190193
if user_id is not None:
191194
if user_id in self.cache:

0 commit comments

Comments
 (0)