Repository: Cog-Creators/Red-DiscordBot

Issue:
[V3] Mod - Unmute still not working
# Command bugs
Did you find a bug with a command? Fill out the following:
-->unmute server

#### Command name

unmute

#### What cog is this command from?

mod

#### What were you expecting to happen?

server unmute a user

#### What actually happened?

fails to unmute,  
```py
Exception in command 'unmute server'
Traceback (most recent call last):
  File "/home/ramimqr/Red-V3/venv/lib/python3.6/site-packages/discord/ext/commands/core.py", line 62, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "/home/ramimqr/Red-V3/venv/lib/python3.6/site-packages/redbot/cogs/mod/mod.py", line 988, in guild_unmute
    success, message = await self.unmute_user(guild, channel, author, user)
  File "/home/ramimqr/Red-V3/venv/lib/python3.6/site-packages/redbot/cogs/mod/mod.py", line 1018, in unmute_user
    overwrites.send_messages = old_values["send_messages"]
TypeError: 'NoneType' object is not subscriptable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ramimqr/Red-V3/venv/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 886, in invoke
    yield from ctx.command.invoke(ctx)
  File "/home/ramimqr/Red-V3/venv/lib/python3.6/site-packages/discord/ext/commands/core.py", line 927, in invoke
    yield from ctx.invoked_subcommand.invoke(ctx)
  File "/home/ramimqr/Red-V3/venv/lib/python3.6/site-packages/discord/ext/commands/core.py", line 514, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "/home/ramimqr/Red-V3/venv/lib/python3.6/site-packages/discord/ext/commands/core.py", line 71, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'NoneType' object is not subscriptable
```
![image](https://user-images.githubusercontent.com/10146271/39638254-8f37f0f6-4fbd-11e8-9634-d0b32c62cccc.png)


#### How can we reproduce this issue?

attempt an unmute server on a user



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
@@ -581,7 +581,7 @@ async def softban(self, ctx: RedContext, user: discord.Member, *, reason: str =
     @commands.bot_has_permissions(ban_members=True)
     async def unban(self, ctx: RedContext, user_id: int, *, reason: str = None):
         """Unbans the target user.
-        
+
         Requires specifying the target user's ID. To find this, you may either:
          1. Copy it from the mod log case (if one was created), or
          2. enable developer mode, go to Bans in this server's settings, right-
@@ -886,11 +886,11 @@ async def mute_user(self, guild: discord.Guild,
             return False, mute_unmute_issues["hierarchy_problem"]
 
         perms_cache[str(channel.id)] = {
-            "send_messages": overwrites.send_messages, 
+            "send_messages": overwrites.send_messages,
             "add_reactions": overwrites.add_reactions
         }
-        overwrites.send_messages = False
-        overwrites.add_reactions = False
+        overwrites.update(send_messages=False,
+                          add_reactions=False)
         try:
             await channel.set_permissions(user, overwrite=overwrites, reason=reason)
         except discord.Forbidden:
@@ -1014,9 +1014,9 @@ async def unmute_user(self, guild: discord.Guild,
         if channel.id in perms_cache:
             old_values = perms_cache[channel.id]
         else:
-            old_values = None
-        overwrites.send_messages = old_values["send_messages"]
-        overwrites.add_reactions = old_values["add_reactions"]
+            old_values = {"send_messages": None, "add_reactions": None}
+        overwrites.update(send_messages=old_values["send_messages"],
+                          add_reactions=old_values["add_reactions"])
         is_empty = self.are_overwrites_empty(overwrites)
 
         try:
@@ -1254,7 +1254,7 @@ async def on_message(self, message):
         valid_user = isinstance(author, discord.Member) and not author.bot
         if not valid_user:
             return
-        
+
         #  Bots and mods or superior are ignored from the filter
         mod_or_superior = await is_mod_or_superior(self.bot, obj=author)
         if mod_or_superior:


Test patch: