Repository: Cog-Creators/Red-DiscordBot

Issue:
Defaultdisablecog Error when used on Economy
# Command bugs

<!-- 
Did you find a bug with a command? Fill out the following:
-->

#### Command name

`command defaultdisablecog` and `command defaultenablecog`

#### What cog is this command from?

General

#### What were you expecting to happen?

Successfully set the disabled state for the Economy cog

#### What actually happened?

`[p]comman defaultdisablecog Economy`
```
Exception in command 'command defaultdisablecog'
Traceback (most recent call last):
  File "C:\Users\Bobloy\Documents\GitHub\Red-DiscordBot\.venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\Bobloy\Documents\GitHub\Red-DiscordBot\redbot\core\core_commands.py", line 3732, in command_default_disable_cog
    await self.bot._disabled_cog_cache.default_disable(cogname)
  File "C:\Users\Bobloy\Documents\GitHub\Red-DiscordBot\redbot\core\settings_caches.py", line 440, in default_disable
    del self._disable_map[cog_name]
KeyError: 'Economy'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Bobloy\Documents\GitHub\Red-DiscordBot\.venv\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Bobloy\Documents\GitHub\Red-DiscordBot\redbot\core\commands\commands.py", line 825, in invoke
    await super().invoke(ctx)
  File "C:\Users\Bobloy\Documents\GitHub\Red-DiscordBot\.venv\lib\site-packages\discord\ext\commands\core.py", line 1329, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "C:\Users\Bobloy\Documents\GitHub\Red-DiscordBot\.venv\lib\site-packages\discord\ext\commands\core.py", line 859, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Bobloy\Documents\GitHub\Red-DiscordBot\.venv\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'Economy'
```

#### How can we reproduce this issue?

1. Load economy
2. Use `[p]command defaultdisablecog Economy` and/or `[p]command defaultenablecog Economy` until Error

See: https://discord.com/channels/133049272517001216/133251234164375552/804379898034257931



Discussion:
Red version:
![image](https://user-images.githubusercontent.com/955640/106165028-a3ea7500-6158-11eb-9d52-c79113b618a8.png)


Resolving patch:
diff --git a/redbot/core/settings_caches.py b/redbot/core/settings_caches.py
--- a/redbot/core/settings_caches.py
+++ b/redbot/core/settings_caches.py
@@ -437,7 +437,7 @@ async def default_disable(self, cog_name: str):
             This should be the cog's qualified name, not necessarily the classname
         """
         await self._config.custom("COG_DISABLE_SETTINGS", cog_name, 0).disabled.set(True)
-        del self._disable_map[cog_name]
+        self._disable_map.pop(cog_name, None)
 
     async def default_enable(self, cog_name: str):
         """
@@ -449,7 +449,7 @@ async def default_enable(self, cog_name: str):
             This should be the cog's qualified name, not necessarily the classname
         """
         await self._config.custom("COG_DISABLE_SETTINGS", cog_name, 0).disabled.clear()
-        del self._disable_map[cog_name]
+        self._disable_map.pop(cog_name, None)
 
     async def disable_cog_in_guild(self, cog_name: str, guild_id: int) -> bool:
         """


Test patch: