diff options
| author | 2019-09-24 15:16:26 -0400 | |
|---|---|---|
| committer | 2019-09-24 15:16:26 -0400 | |
| commit | d6ab11ebb4811d2fc5390f90d605eab88b565480 (patch) | |
| tree | ca4fbdca201e915791adcadb4648f98494754048 | |
| parent | Merge pull request #451 from python-discord/all-the-shields (diff) | |
| parent | Merge branch 'master' into ot-fix (diff) | |
Merge pull request #448 from Akarys42/ot-fix
Catch error in case of non successfull API call for new ot-names
| -rw-r--r-- | bot/cogs/off_topic_names.py | 11 | 
1 files changed, 8 insertions, 3 deletions
diff --git a/bot/cogs/off_topic_names.py b/bot/cogs/off_topic_names.py index 8f1af347a..16717d523 100644 --- a/bot/cogs/off_topic_names.py +++ b/bot/cogs/off_topic_names.py @@ -6,6 +6,7 @@ from datetime import datetime, timedelta  from discord import Colour, Embed  from discord.ext.commands import BadArgument, Bot, Cog, Context, Converter, group +from bot.api import ResponseCodeError  from bot.constants import Channels, MODERATION_ROLES  from bot.decorators import with_role  from bot.pagination import LinePaginator @@ -49,9 +50,13 @@ 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 ResponseCodeError as e: +            log.error(f"Failed to get new off topic channel names: code {e.response.status}") +            continue          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}')  |