Skip to content

Commit ee665a2

Browse files
authored
Merge pull request #1 from Taaku18/testing
Nothing here
2 parents 5abdbc4 + 561ac20 commit ee665a2

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

core/thread.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ def __init__(self, manager, recipient):
2323
self.recipient = recipient
2424
self.channel = None
2525
self.ready_event = asyncio.Event()
26-
self.close_task = None
27-
self.close_after = 0 # seconds
2826

2927
def __repr__(self):
3028
return f'Thread(recipient="{self.recipient}", channel={self.channel.id})'
@@ -42,21 +40,18 @@ def ready(self, flag):
4240
if flag is True:
4341
self.ready_event.set()
4442

45-
async def _close_after(self, after, **kwargs):
46-
await asyncio.sleep(after)
47-
kwargs['scheduled'] = True
48-
await self.close(**kwargs)
43+
async def _close_after(self, closer, silent, delete_channel, message):
44+
return self.bot.loop.create_task(self._close(closer, silent, delete_channel, message, True))
4945

50-
async def close(self, *, closer, after=0, silent=False, delete_channel=True, message=None, scheduled=False):
46+
async def close(self, *, closer, after=0, silent=False, delete_channel=True, message=None):
5147
'''Close a thread now or after a set time in seconds'''
52-
if self.close_task is not None and not self.close_task.cancelled():
53-
if not scheduled or after > 0:
54-
self.close_task.cancel()
5548

5649
if after > 0:
57-
self.close_task = asyncio.create_task(self._close_after(after, closer=closer, silent=silent, message=message))
58-
return
50+
return await self.bot.loop.call_later(after, silent, delete_channel, message)
51+
52+
return await self._close(closer, silent, delete_channel, message)
5953

54+
async def _close(self, closer, silent=False, delete_channel=True, message=None, scheduled=False):
6055
del self.manager.cache[self.id]
6156
if str(self.id) in self.bot.config.subscriptions:
6257
del self.bot.config.subscriptions[str(self.id)]
@@ -73,7 +68,8 @@ async def close(self, *, closer, after=0, silent=False, delete_channel=True, mes
7368
})
7469

7570
if isinstance(log_data, str):
76-
print(log_data) # errored somehow on server
71+
print(log_data) # errored somehow on server
72+
return
7773

7874
if self.bot.selfhosted:
7975
log_url = f'{self.bot.config.log_url}/logs/{log_data["key"]}'

0 commit comments

Comments
 (0)