We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Mod-alerts channel pings when large amounts of emojis are within a code block.
When a user inputs a large amount of emojis in a code block, it seems that the bot does not ignore them and proceeds to mute for emoji spam. All emojis contained within a code block should be looked over, but anything on the outside should still be scanned for amounts of emojis.

An example of what can trigger the filter:
![Untitled](https://user-images.githubusercontent.com/15021300/91444625-de5a8980-e829-11ea-9594-d38246b90651.png)



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `bot/rules/discord_emojis.py`
Content:
```
1 import re
2 from typing import Dict, Iterable, List, Optional, Tuple
3 
4 from discord import Member, Message
5 
6 
7 DISCORD_EMOJI_RE = re.compile(r"<:\w+:\d+>")
8 
9 
10 async def apply(
11     last_message: Message, recent_messages: List[Message], config: Dict[str, int]
12 ) -> Optional[Tuple[str, Iterable[Member], Iterable[Message]]]:
13     """Detects total Discord emojis (excluding Unicode emojis) exceeding the limit sent by a single user."""
14     relevant_messages = tuple(
15         msg
16         for msg in recent_messages
17         if msg.author == last_message.author
18     )
19 
20     total_emojis = sum(
21         len(DISCORD_EMOJI_RE.findall(msg.content))
22         for msg in relevant_messages
23     )
24 
25     if total_emojis > config['max']:
26         return (
27             f"sent {total_emojis} emojis in {config['interval']}s",
28             (last_message.author,),
29             relevant_messages
30         )
31     return None
32
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/bot/rules/discord_emojis.py b/bot/rules/discord_emojis.py
--- a/bot/rules/discord_emojis.py
+++ b/bot/rules/discord_emojis.py
@@ -5,6 +5,7 @@
 
 
 DISCORD_EMOJI_RE = re.compile(r"<:\w+:\d+>")
+CODE_BLOCK_RE = re.compile(r"```.*?```", flags=re.DOTALL)
 
 
 async def apply(
@@ -17,8 +18,9 @@
         if msg.author == last_message.author
     )
 
+    # Get rid of code blocks in the message before searching for emojis.
     total_emojis = sum(
-        len(DISCORD_EMOJI_RE.findall(msg.content))
+        len(DISCORD_EMOJI_RE.findall(CODE_BLOCK_RE.sub("", msg.content)))
         for msg in relevant_messages
     )

{"golden_diff": "diff --git a/bot/rules/discord_emojis.py b/bot/rules/discord_emojis.py\n--- a/bot/rules/discord_emojis.py\n+++ b/bot/rules/discord_emojis.py\n@@ -5,6 +5,7 @@\n \n \n DISCORD_EMOJI_RE = re.compile(r\"<:\\w+:\\d+>\")\n+CODE_BLOCK_RE = re.compile(r\"```.*?```\", flags=re.DOTALL)\n \n \n async def apply(\n@@ -17,8 +18,9 @@\n         if msg.author == last_message.author\n     )\n \n+    # Get rid of code blocks in the message before searching for emojis.\n     total_emojis = sum(\n-        len(DISCORD_EMOJI_RE.findall(msg.content))\n+        len(DISCORD_EMOJI_RE.findall(CODE_BLOCK_RE.sub(\"\", msg.content)))\n         for msg in relevant_messages\n     )\n", "issue": "Mod-alerts channel pings when large amounts of emojis are within a code block.\nWhen a user inputs a large amount of emojis in a code block, it seems that the bot does not ignore them and proceeds to mute for emoji spam. All emojis contained within a code block should be looked over, but anything on the outside should still be scanned for amounts of emojis.\r\n\r\nAn example of what can trigger the filter:\r\n![Untitled](https://user-images.githubusercontent.com/15021300/91444625-de5a8980-e829-11ea-9594-d38246b90651.png)\r\n\r\n\n", "before_files": [{"content": "import re\nfrom typing import Dict, Iterable, List, Optional, Tuple\n\nfrom discord import Member, Message\n\n\nDISCORD_EMOJI_RE = re.compile(r\"<:\\w+:\\d+>\")\n\n\nasync def apply(\n    last_message: Message, recent_messages: List[Message], config: Dict[str, int]\n) -> Optional[Tuple[str, Iterable[Member], Iterable[Message]]]:\n    \"\"\"Detects total Discord emojis (excluding Unicode emojis) exceeding the limit sent by a single user.\"\"\"\n    relevant_messages = tuple(\n        msg\n        for msg in recent_messages\n        if msg.author == last_message.author\n    )\n\n    total_emojis = sum(\n        len(DISCORD_EMOJI_RE.findall(msg.content))\n        for msg in relevant_messages\n    )\n\n    if total_emojis > config['max']:\n        return (\n            f\"sent {total_emojis} emojis in {config['interval']}s\",\n            (last_message.author,),\n            relevant_messages\n        )\n    return None\n", "path": "bot/rules/discord_emojis.py"}], "after_files": [{"content": "import re\nfrom typing import Dict, Iterable, List, Optional, Tuple\n\nfrom discord import Member, Message\n\n\nDISCORD_EMOJI_RE = re.compile(r\"<:\\w+:\\d+>\")\nCODE_BLOCK_RE = re.compile(r\"```.*?```\", flags=re.DOTALL)\n\n\nasync def apply(\n    last_message: Message, recent_messages: List[Message], config: Dict[str, int]\n) -> Optional[Tuple[str, Iterable[Member], Iterable[Message]]]:\n    \"\"\"Detects total Discord emojis (excluding Unicode emojis) exceeding the limit sent by a single user.\"\"\"\n    relevant_messages = tuple(\n        msg\n        for msg in recent_messages\n        if msg.author == last_message.author\n    )\n\n    # Get rid of code blocks in the message before searching for emojis.\n    total_emojis = sum(\n        len(DISCORD_EMOJI_RE.findall(CODE_BLOCK_RE.sub(\"\", msg.content)))\n        for msg in relevant_messages\n    )\n\n    if total_emojis > config['max']:\n        return (\n            f\"sent {total_emojis} emojis in {config['interval']}s\",\n            (last_message.author,),\n            relevant_messages\n        )\n    return None\n", "path": "bot/rules/discord_emojis.py"}]}