9
9
10
10
from core .models import Bot , ThreadManagerABC , ThreadABC
11
11
from core .utils import is_image_url , days , match_user_id , truncate
12
- from core .decorators import ignore , queued
12
+ from core .decorators import ignore
13
13
14
14
15
15
class Thread (ThreadABC ):
@@ -32,9 +32,7 @@ def __init__(self, manager: 'ThreadManager',
32
32
self ._recipient = recipient
33
33
self ._channel = channel
34
34
self ._ready_event = asyncio .Event ()
35
- self ._message_queue = asyncio .Queue ()
36
35
self ._close_task = None
37
- self .bot .loop .create_task (self .process_messages ())
38
36
39
37
def __repr__ (self ):
40
38
return (f'Thread(recipient="{ self .recipient or self .id } ", '
@@ -75,12 +73,6 @@ def ready(self, flag):
75
73
else :
76
74
self ._ready_event .clear ()
77
75
78
- async def process_messages (self ):
79
- """Guarantees order of thread messages sent"""
80
- while True :
81
- task = await self ._message_queue .get ()
82
- await task
83
-
84
76
async def setup (self , * , creator = None , category = None ):
85
77
"""Create the thread channel and other io related initilisation tasks"""
86
78
@@ -362,7 +354,6 @@ async def reply(self, message, anonymous=False):
362
354
363
355
await asyncio .gather (* tasks )
364
356
365
- @queued ()
366
357
async def send (self , message , destination = None ,
367
358
from_mod = False , note = False , anonymous = False ):
368
359
if self .close_task is not None :
@@ -380,6 +371,9 @@ async def send(self, message, destination=None,
380
371
self .bot .api .append_log (message , self .channel .id )
381
372
)
382
373
374
+ if not self .ready :
375
+ self .wait_until_ready ()
376
+
383
377
destination = destination or self .channel
384
378
385
379
author = message .author
@@ -500,7 +494,9 @@ async def send(self, message, destination=None,
500
494
501
495
await destination .send (mentions , embed = embed )
502
496
if additional_images :
497
+ self .ready = True
503
498
await asyncio .gather (* additional_images )
499
+ self .ready = False
504
500
505
501
if delete_message :
506
502
self .bot .loop .create_task (ignore (message .delete ()))
0 commit comments