Repository: Cog-Creators/Red-DiscordBot

Issue:
Mod cog sends owner notifications on fresh install.
# Other bugs

I got reminded about it when I saw a fix for #3587. Mod cog sends owner notifications about `[p]moveignoredchannels` and `[p]movedeletedelay` on fresh Red installs. Only viable solution seems to be looping through all guild settings and only send the message if `delete_delay` has been changed from the default in at least one of them though I'm basing that on my comment [here](https://github.com/Cog-Creators/Red-DiscordBot/pull/3638#discussion_r392119234).



Discussion:

Resolving patch:
diff --git a/redbot/cogs/mod/mod.py b/redbot/cogs/mod/mod.py
--- a/redbot/cogs/mod/mod.py
+++ b/redbot/cogs/mod/mod.py
@@ -6,6 +6,8 @@
 from typing import List, Tuple
 
 import discord
+from redbot.core.utils import AsyncIter
+
 from redbot.core import Config, modlog, commands
 from redbot.core.bot import Red
 from redbot.core.i18n import Translator, cog_i18n
@@ -95,7 +97,7 @@ async def _maybe_update_config(self):
         """Maybe update `delete_delay` value set by Config prior to Mod 1.0.0."""
         if not await self.config.version():
             guild_dict = await self.config.all_guilds()
-            for guild_id, info in guild_dict.items():
+            async for guild_id, info in AsyncIter(guild_dict.items(), steps=25):
                 delete_repeats = info.get("delete_repeats", False)
                 if delete_repeats:
                     val = 3
@@ -104,20 +106,37 @@ async def _maybe_update_config(self):
                 await self.config.guild(discord.Object(id=guild_id)).delete_repeats.set(val)
             await self.config.version.set("1.0.0")  # set version of last update
         if await self.config.version() < "1.1.0":
-            msg = _(
-                "Ignored guilds and channels have been moved. "
-                "Please use `[p]moveignoredchannels` if "
-                "you were previously using these functions."
-            )
-            self.bot.loop.create_task(send_to_owners_with_prefix_replaced(self.bot, msg))
+            message_sent = False
+            async for e in AsyncIter((await self.config.all_channels()).values(), steps=25):
+                if e["ignored"] is not False:
+                    msg = _(
+                        "Ignored guilds and channels have been moved. "
+                        "Please use `[p]moveignoredchannels` to migrate the old settings."
+                    )
+                    self.bot.loop.create_task(send_to_owners_with_prefix_replaced(self.bot, msg))
+                    message_sent = True
+                    break
+            if message_sent is False:
+                async for e in AsyncIter((await self.config.all_guilds()).values(), steps=25):
+                    if e["ignored"] is not False:
+                        msg = _(
+                            "Ignored guilds and channels have been moved. "
+                            "Please use `[p]moveignoredchannels` to migrate the old settings."
+                        )
+                        self.bot.loop.create_task(
+                            send_to_owners_with_prefix_replaced(self.bot, msg)
+                        )
+                        break
             await self.config.version.set("1.1.0")
         if await self.config.version() < "1.2.0":
-            msg = _(
-                "Delete delay settings have been moved. "
-                "Please use `[p]movedeletedelay` if "
-                "you were previously using these functions."
-            )
-            self.bot.loop.create_task(send_to_owners_with_prefix_replaced(self.bot, msg))
+            async for e in AsyncIter((await self.config.all_guilds()).values(), steps=25):
+                if e["delete_delay"] != -1:
+                    msg = _(
+                        "Delete delay settings have been moved. "
+                        "Please use `[p]movedeletedelay` to migrate the old settings."
+                    )
+                    self.bot.loop.create_task(send_to_owners_with_prefix_replaced(self.bot, msg))
+                    break
             await self.config.version.set("1.2.0")
 
     @commands.command()


Test patch: