diff --git a/status/commands/statusdev_com.py b/status/commands/statusdev_com.py index 989092cf..a90dcc6f 100644 --- a/status/commands/statusdev_com.py +++ b/status/commands/statusdev_com.py @@ -213,3 +213,21 @@ async def devenvvars(self, ctx: commands.Context): except Exception: _log.exception("Unable to add dev env vars.") await ctx.send("I was unable to add them. Check the logs.") + + @commands.before_invoke(unsupported) + @statusdev.command(aliases=["cl"], hidden=True) + async def clearchannels(self, ctx: commands.Context): + """Clear channels from Config that no longer exists.""" + data = await self.config.all_channels() + count = 0 + for channel_id in data.keys(): + channel = self.bot.get_channel(channel_id) + if channel is None: + await self.config.channel_from_id(channel_id).clear() + count += 1 + + await ctx.send( + f"Successfully cleared out {count:,} channels." + if count + else "There was no channels to clear." + ) diff --git a/status/updateloop/utils.py b/status/updateloop/utils.py index 4004e90b..9b69f3d0 100644 --- a/status/updateloop/utils.py +++ b/status/updateloop/utils.py @@ -60,7 +60,11 @@ async def get_channel_data(bot: Red, c_id: int, settings: ConfChannelSettings) - channel = bot.get_channel(c_id) if channel is None: # TODO: maybe remove from config - _log.info(f"I can't find the channel with id {c_id} - skipping") + _log.info( + f"I can't find the channel with id {c_id} - skipping. " + "You can use the [p]statusdev clearchannels in order to " + "remove all no longer existing channels" + ) raise NotFound if TYPE_CHECKING: