diff options
| author | 2019-09-23 19:50:21 +0200 | |
|---|---|---|
| committer | 2019-09-23 19:50:21 +0200 | |
| commit | 60d5352f157de897a4e472a1adf8d241188f60f6 (patch) | |
| tree | b63a5c15e24968088a5dc63949e721b22647cf92 | |
| parent | Make DEFCON days subcommand enable DEFCON (#405) (diff) | |
Catch error in case of non successfull API call for new ot-names
This allows to keep the task running even if the call fail.
| -rw-r--r-- | bot/cogs/off_topic_names.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/bot/cogs/off_topic_names.py b/bot/cogs/off_topic_names.py index 8f1af347a..cd3d78403 100644 --- a/bot/cogs/off_topic_names.py +++ b/bot/cogs/off_topic_names.py @@ -49,9 +49,12 @@ async def update_names(bot: Bot) -> None: seconds_to_sleep = (next_midnight - datetime.utcnow()).seconds + 1 await asyncio.sleep(seconds_to_sleep) - channel_0_name, channel_1_name, channel_2_name = await bot.api_client.get( - 'bot/off-topic-channel-names', params={'random_items': 3} - ) + try: + channel_0_name, channel_1_name, channel_2_name = await bot.api_client.get( + 'bot/off-topic-channel-names', params={'random_items': 3} + ) + except bot.api.ResponseCodeError as e: + log.error(f"Failed to get new off topic channel names: code {e.response.status}") channel_0, channel_1, channel_2 = (bot.get_channel(channel_id) for channel_id in CHANNELS) await channel_0.edit(name=f'ot0-{channel_0_name}') |