prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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*
  
  </issue>
  <code>
  [start of redbot/cogs/admin/announcer.py]
  1 import asyncio
  2 
  3 import discord
  4 from redbot.core import commands
  5 from redbot.core.i18n import Translator
  6 
  7 _ = Translator("Announcer", __file__)
  8 
  9 
  10 class Announcer:
  11     def __init__(self, ctx: commands.Context, message: str, config=None):
  12         """
  13         :param ctx:
  14         :param message:
  15         :param config: Used to determine channel overrides
  16         """
  17         self.ctx = ctx
  18         self.message = message
  19         self.config = config
  20 
  21         self.active = None
  22 
  23     def start(self):
  24         """
  25         Starts an announcement.
  26         :return:
  27         """
  28         if self.active is None:
  29             self.active = True
  30             self.ctx.bot.loop.create_task(self.announcer())
  31 
  32     def cancel(self):
  33         """
  34         Cancels a running announcement.
  35         :return:
  36         """
  37         self.active = False
  38 
  39     async def _get_announce_channel(self, guild: discord.Guild) -> discord.TextChannel:
  40         channel_id = await self.config.guild(guild).announce_channel()
  41         channel = None
  42 
  43         if channel_id is not None:
  44             channel = guild.get_channel(channel_id)
  45 
  46         if channel is None:
  47             channel = guild.system_channel
  48 
  49         if channel is None:
  50             channel = guild.text_channels[0]
  51 
  52         return channel
  53 
  54     async def announcer(self):
  55         guild_list = self.ctx.bot.guilds
  56         bot_owner = (await self.ctx.bot.application_info()).owner
  57         for g in guild_list:
  58             if not self.active:
  59                 return
  60 
  61             if await self.config.guild(g).announce_ignore():
  62                 continue
  63 
  64             channel = await self._get_announce_channel(g)
  65 
  66             try:
  67                 await channel.send(self.message)
  68             except discord.Forbidden:
  69                 await bot_owner.send(
  70                     _("I could not announce to server: {server.id}").format(server=g)
  71                 )
  72             await asyncio.sleep(0.5)
  73 
  74         self.active = False
  75
  [end of redbot/cogs/admin/announcer.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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 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 @@
               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
  
verification_info: {"golden_diff": "diff --git a/redbot/cogs/admin/announcer.py b/redbot/cogs/admin/announcer.py\n--- a/redbot/cogs/admin/announcer.py\n+++ b/redbot/cogs/admin/announcer.py\n@@ -3,6 +3,7 @@\n import discord\n from redbot.core import commands\n from redbot.core.i18n import Translator\n+from redbot.core.utils.chat_formatting import humanize_list, inline\n \n _ = Translator(\"Announcer\", __file__)\n \n@@ -53,7 +54,7 @@\n \n     async def announcer(self):\n         guild_list = self.ctx.bot.guilds\n-        bot_owner = (await self.ctx.bot.application_info()).owner\n+        failed = []\n         for g in guild_list:\n             if not self.active:\n                 return\n@@ -66,9 +67,14 @@\n             try:\n                 await channel.send(self.message)\n             except discord.Forbidden:\n-                await bot_owner.send(\n-                    _(\"I could not announce to server: {server.id}\").format(server=g)\n-                )\n+                failed.append(str(g.id))\n             await asyncio.sleep(0.5)\n \n+        msg = (\n+            _(\"I could not announce to the following server: \")\n+            if len(failed) == 1\n+            else _(\"I could not announce to the following servers: \")\n+        )\n+        msg += humanize_list(tuple(map(inline, failed)))\n+        await self.ctx.bot.send_to_owners(msg)\n         self.active = False\n", "issue": "[p]announce fails if bot belongs to team\n# Command bugs\r\n\r\n#### Command name\r\n\r\n`announce`\r\n\r\n#### What cog is this command from?\r\n\r\n`Admin`\r\n\r\n#### What were you expecting to happen?\r\n\r\nSend announcement to all enabled servers, if failed, send message to the one of owners or all owners (like an `[p]contact`)\r\n\r\n#### What actually happened?\r\n\r\nannouncement failed almost immediately with error in console \r\n\r\n#### How can we reproduce this issue?\r\n\r\n1. Set bot with token belonging to team\r\n2. Create environment, where bot cant send announcement to server\r\n3. Announce an message\r\n4. `[p]announce` silently fails with error:\r\n```py\r\nTraceback (most recent call last):\r\n  File \"/home/fixator/Red-V3/lib/python3.7/site-packages/redbot/cogs/admin/announcer.py\", line 67, in announcer\r\n    await channel.send(self.message)\r\n  File \"/home/fixator/Red-V3/lib/python3.7/site-packages/discord/abc.py\", line 823, in send\r\n    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, nonce=nonce)\r\n  File \"/home/fixator/Red-V3/lib/python3.7/site-packages/discord/http.py\", line 218, in request\r\n    raise Forbidden(r, data)\r\ndiscord.errors.Forbidden: 403 FORBIDDEN (error code: 50001): Missing Access\r\nDuring handling of the above exception, another exception occurred:\r\nTraceback (most recent call last):\r\n  File \"/home/fixator/Red-V3/lib/python3.7/site-packages/redbot/cogs/admin/announcer.py\", line 70, in announcer\r\n    _(\"I could not announce to server: {server.id}\").format(server=g)\r\n  File \"/home/fixator/Red-V3/lib/python3.7/site-packages/discord/abc.py\", line 823, in send\r\n    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, nonce=nonce)\r\n  File \"/home/fixator/Red-V3/lib/python3.7/site-packages/discord/http.py\", line 218, in request\r\n    raise Forbidden(r, data)\r\ndiscord.errors.Forbidden: 403 FORBIDDEN (error code: 50007): Cannot send messages to this user\r\n```\r\n\r\nCaused by https://github.com/Cog-Creators/Red-DiscordBot/blob/f0836d7182d99239d1fde24cf2231c6ebf206f72/redbot/cogs/admin/announcer.py#L56\r\n\r\n*Kinda related to #2781, i guess*\n", "before_files": [{"content": "import asyncio\n\nimport discord\nfrom redbot.core import commands\nfrom redbot.core.i18n import Translator\n\n_ = Translator(\"Announcer\", __file__)\n\n\nclass Announcer:\n    def __init__(self, ctx: commands.Context, message: str, config=None):\n        \"\"\"\n        :param ctx:\n        :param message:\n        :param config: Used to determine channel overrides\n        \"\"\"\n        self.ctx = ctx\n        self.message = message\n        self.config = config\n\n        self.active = None\n\n    def start(self):\n        \"\"\"\n        Starts an announcement.\n        :return:\n        \"\"\"\n        if self.active is None:\n            self.active = True\n            self.ctx.bot.loop.create_task(self.announcer())\n\n    def cancel(self):\n        \"\"\"\n        Cancels a running announcement.\n        :return:\n        \"\"\"\n        self.active = False\n\n    async def _get_announce_channel(self, guild: discord.Guild) -> discord.TextChannel:\n        channel_id = await self.config.guild(guild).announce_channel()\n        channel = None\n\n        if channel_id is not None:\n            channel = guild.get_channel(channel_id)\n\n        if channel is None:\n            channel = guild.system_channel\n\n        if channel is None:\n            channel = guild.text_channels[0]\n\n        return channel\n\n    async def announcer(self):\n        guild_list = self.ctx.bot.guilds\n        bot_owner = (await self.ctx.bot.application_info()).owner\n        for g in guild_list:\n            if not self.active:\n                return\n\n            if await self.config.guild(g).announce_ignore():\n                continue\n\n            channel = await self._get_announce_channel(g)\n\n            try:\n                await channel.send(self.message)\n            except discord.Forbidden:\n                await bot_owner.send(\n                    _(\"I could not announce to server: {server.id}\").format(server=g)\n                )\n            await asyncio.sleep(0.5)\n\n        self.active = False\n", "path": "redbot/cogs/admin/announcer.py"}]}