diff options
author | 2024-08-14 20:53:17 +0100 | |
---|---|---|
committer | 2024-08-14 20:53:17 +0100 | |
commit | f1c7b0be71b6d10632625d81a6b150bd4d6fc7c5 (patch) | |
tree | e20ac3028f0c26181dc348523aebcdd5e279e0ba | |
parent | Legacy Help Channels Access -> Archived Channels Access (#3141) (diff) | |
parent | Log and retry OT renaming if Discord returns an error (diff) |
Merge pull request #3145 from python-discord/log-failed-OT-name-rename
Log and retry OT renaming if Discord returns an error
-rw-r--r-- | bot/exts/fun/off_topic_names.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/bot/exts/fun/off_topic_names.py b/bot/exts/fun/off_topic_names.py index 21dfaee20..ba7cc2914 100644 --- a/bot/exts/fun/off_topic_names.py +++ b/bot/exts/fun/off_topic_names.py @@ -5,7 +5,7 @@ import json import random from functools import partial -from discord import ButtonStyle, Colour, Embed, Interaction +from discord import ButtonStyle, Colour, Embed, HTTPException, Interaction from discord.ext import tasks from discord.ext.commands import Cog, Context, group, has_any_role from discord.ui import Button, View @@ -61,9 +61,18 @@ class OffTopicNames(Cog): channel_0, channel_1, channel_2 = (self.bot.get_channel(channel_id) for channel_id in CHANNELS) - await channel_0.edit(name=OTN_FORMATTER.format(number=0, name=channel_0_name)) - await channel_1.edit(name=OTN_FORMATTER.format(number=1, name=channel_1_name)) - await channel_2.edit(name=OTN_FORMATTER.format(number=2, name=channel_2_name)) + try: + await channel_0.edit(name=OTN_FORMATTER.format(number=0, name=channel_0_name)) + await channel_1.edit(name=OTN_FORMATTER.format(number=1, name=channel_1_name)) + await channel_2.edit(name=OTN_FORMATTER.format(number=2, name=channel_2_name)) + except HTTPException: + await self.bot.get_channel(Channels.mod_meta).send( + ":exclamation: Got an error trying to update OT names to" + f"{channel_0_name}, {channel_1_name} and {channel_2_name}." + "\nI will retry with new names, but please delete the ones that sound bad." + ) + await self.update_names() + return log.debug( "Updated off-topic channel names to" |