Repository: Cog-Creators/Red-DiscordBot

Issue:
[p]announce fails if bot belongs to team
# Command bugs

#### Command name

`announce`

#### What cog is this command from?

`Admin`

#### What were you expecting to happen?

Send announcement to all enabled servers, if failed, send message to the one of owners or all owners (like an `[p]contact`)

#### What actually happened?

announcement failed almost immediately with error in console 

#### How can we reproduce this issue?

1. Set bot with token belonging to team
2. Create environment, where bot cant send announcement to server
3. Announce an message
4. `[p]announce` silently fails with error:
```py
Traceback (most recent call last):
  File "/home/fixator/Red-V3/lib/python3.7/site-packages/redbot/cogs/admin/announcer.py", line 67, in announcer
    await channel.send(self.message)
  File "/home/fixator/Red-V3/lib/python3.7/site-packages/discord/abc.py", line 823, in send
    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, nonce=nonce)
  File "/home/fixator/Red-V3/lib/python3.7/site-packages/discord/http.py", line 218, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 FORBIDDEN (error code: 50001): Missing Access
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/fixator/Red-V3/lib/python3.7/site-packages/redbot/cogs/admin/announcer.py", line 70, in announcer
    _("I could not announce to server: {server.id}").format(server=g)
  File "/home/fixator/Red-V3/lib/python3.7/site-packages/discord/abc.py", line 823, in send
    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, nonce=nonce)
  File "/home/fixator/Red-V3/lib/python3.7/site-packages/discord/http.py", line 218, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 FORBIDDEN (error code: 50007): Cannot send messages to this user
```

Caused by https://github.com/Cog-Creators/Red-DiscordBot/blob/f0836d7182d99239d1fde24cf2231c6ebf206f72/redbot/cogs/admin/announcer.py#L56

*Kinda related to #2781, i guess*


Discussion:

Resolving patch:
diff --git a/redbot/cogs/admin/announcer.py b/redbot/cogs/admin/announcer.py
--- a/redbot/cogs/admin/announcer.py
+++ b/redbot/cogs/admin/announcer.py
@@ -3,6 +3,7 @@
 import discord
 from redbot.core import commands
 from redbot.core.i18n import Translator
+from redbot.core.utils.chat_formatting import humanize_list, inline
 
 _ = Translator("Announcer", __file__)
 
@@ -53,7 +54,7 @@ async def _get_announce_channel(self, guild: discord.Guild) -> discord.TextChann
 
     async def announcer(self):
         guild_list = self.ctx.bot.guilds
-        bot_owner = (await self.ctx.bot.application_info()).owner
+        failed = []
         for g in guild_list:
             if not self.active:
                 return
@@ -66,9 +67,14 @@ async def announcer(self):
             try:
                 await channel.send(self.message)
             except discord.Forbidden:
-                await bot_owner.send(
-                    _("I could not announce to server: {server.id}").format(server=g)
-                )
+                failed.append(str(g.id))
             await asyncio.sleep(0.5)
 
+        msg = (
+            _("I could not announce to the following server: ")
+            if len(failed) == 1
+            else _("I could not announce to the following servers: ")
+        )
+        msg += humanize_list(tuple(map(inline, failed)))
+        await self.ctx.bot.send_to_owners(msg)
         self.active = False


Test patch: