Skip to content

Commit c20d6d4

Browse files
committed
Make internals more robust?
1 parent 3450ea2 commit c20d6d4

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

core/thread.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,18 @@ async def setup(self, *, creator=None, category=None):
101101

102102
self._channel = channel
103103

104-
log_url, log_data = await asyncio.gather(
105-
self.bot.api.create_log_entry(recipient, channel,
106-
creator or recipient),
107-
self.bot.api.get_user_logs(recipient.id)
108-
)
104+
try:
105+
log_url, log_data = await asyncio.gather(
106+
self.bot.api.create_log_entry(recipient, channel,
107+
creator or recipient),
108+
self.bot.api.get_user_logs(recipient.id)
109+
)
110+
111+
log_count = sum(1 for log in log_data if not log['open'])
112+
except: # Something went wrong with database?
113+
log_url = log_count = None
114+
# ensure core functionality still works
109115

110-
log_count = sum(1 for log in log_data if not log['open'])
111116
info_embed = self.manager._format_info_embed(recipient, log_url,
112117
log_count,
113118
discord.Color.green())
@@ -118,12 +123,16 @@ async def setup(self, *, creator=None, category=None):
118123
else:
119124
mention = self.bot.config.get('mention', '@here')
120125

121-
_, msg = await asyncio.gather(
122-
channel.edit(topic=topic),
123-
channel.send(mention, embed=info_embed)
124-
)
126+
async def send_info_embed():
127+
try:
128+
msg = await channel.send(mention, embed=info_embed)
129+
await msg.pin()
130+
except:
131+
pass
132+
133+
await channel.edit(topic=topic)
134+
self.bot.loop.create_task(send_info_embed())
125135

126-
self.bot.loop.create_task(msg.pin()) # pin message
127136
self.ready = True
128137

129138
# Once thread is ready, tell the recipient.

0 commit comments

Comments
 (0)