@@ -13,6 +13,9 @@ def __init__(self, manager, recipient):
13
13
self .channel = None
14
14
self .ready_event = asyncio .Event ()
15
15
16
+ def __repr__ (self ):
17
+ return f'Thread(recipient="{ self .recipient } ", channel={ self .channel .id } )'
18
+
16
19
def wait_until_ready (self ):
17
20
'''Blocks execution until the thread is fully set up.'''
18
21
return self .ready_event .wait ()
@@ -121,6 +124,10 @@ def __iter__(self):
121
124
def __getitem__ (self , item ):
122
125
return self .cache [item ]
123
126
127
+ async def populate_cache (self ):
128
+ for channel in self .bot .guild .text_channels :
129
+ await self .find (channel = channel )
130
+
124
131
async def find (self , * , recipient = None , channel = None ):
125
132
'''Finds a thread from cache or from discord channel topics.'''
126
133
if recipient is None and channel is not None :
@@ -151,7 +158,7 @@ async def _find_from_channel(self, channel):
151
158
152
159
if channel .topic and 'User ID: ' in channel .topic :
153
160
user_id = int (re .findall (r'\d+' , channel .topic )[0 ])
154
- elif channel .topic is None :
161
+ elif channel .topic is None and channel . category . name == 'Mod Mail' :
155
162
async for message in channel .history ():
156
163
if message .embeds :
157
164
em = message .embeds [0 ]
@@ -204,7 +211,7 @@ async def create(self, recipient, *, creator=None):
204
211
info_embed = self .bot .format_info (recipient , creator , log_url , log_count )
205
212
206
213
topic = f'User ID: { recipient .id } '
207
- mention = self .bot .config .get ('MENTION' , '@here' )
214
+ mention = self .bot .config .get ('MENTION' , '@here' ) if not creator else None
208
215
209
216
await asyncio .gather (
210
217
channel .edit (topic = topic ),
0 commit comments