Compare commits
3 Commits
f431733940
...
236e24af4a
Author | SHA1 | Date | |
---|---|---|---|
236e24af4a | |||
92303b9a3a | |||
e538b6c23b |
@ -56,25 +56,21 @@ class BotManagement(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
await ctx.send('Rfoo server already stopped')
|
await ctx.send('Rfoo server already stopped')
|
||||||
|
|
||||||
def ct(self, coro: Coroutine, timeout=5):
|
def ct(self, coro: Coroutine):
|
||||||
"""
|
"""
|
||||||
ct - short from create_task
|
ct - short from create_task
|
||||||
execute coroutine and get result
|
execute coroutine and get result
|
||||||
"""
|
"""
|
||||||
|
|
||||||
task = self.bot.loop.create_task(coro)
|
task = self.bot.loop.create_task(coro)
|
||||||
time.sleep(timeout)
|
while not task.done():
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return task.result()
|
return task.result()
|
||||||
|
|
||||||
except asyncio.exceptions.InvalidStateError:
|
except asyncio.exceptions.InvalidStateError:
|
||||||
exp = task.exception()
|
return task.exception()
|
||||||
if exp is None:
|
|
||||||
return task
|
|
||||||
|
|
||||||
else:
|
|
||||||
return exp
|
|
||||||
|
|
||||||
|
|
||||||
async def setup(bot):
|
async def setup(bot):
|
2
main.py
2
main.py
@ -49,7 +49,7 @@ class DiscordTTSBot(commands.Bot, Observ.Subject):
|
|||||||
await self.notify(ctx.message)
|
await self.notify(ctx.message)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise exception
|
logger.opt(exception=exception).warning(f'Global error caught:')
|
||||||
|
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user