Repository: Cog-Creators/Red-DiscordBot

Issue:
[crash] bank balance  - when the bot doesnt have perms to send message
```Traceback (most recent call last):
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/bb8/venv/lib/python3.7/site-packages/redbot/cogs/economy/economy.py", line 174, in balance
    user=user.display_name, num=humanize_number(bal), currency=currency
  File "/home/bb8/venv/lib/python3.7/site-packages/redbot/core/commands/context.py", line 81, in send
    return await super().send(content=content, **kwargs)
  File "/home/bb8/venv/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/bb8/venv/lib/python3.7/site-packages/discord/http.py", line 218, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 FORBIDDEN (error code: 50013): Missing Permissions

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 863, in invoke
    await ctx.command.invoke(ctx)
  File "/home/bb8/venv/lib/python3.7/site-packages/redbot/core/commands/commands.py", line 587, in invoke
    await super().invoke(ctx)
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 1158, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 728, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/bb8/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 88, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 FORBIDDEN (error code: 50013): Missing Permissions```

Trace taken from BB-8


Discussion:

Resolving patch:
diff --git a/redbot/core/global_checks.py b/redbot/core/global_checks.py
--- a/redbot/core/global_checks.py
+++ b/redbot/core/global_checks.py
@@ -4,7 +4,17 @@
 
 def init_global_checks(bot):
     @bot.check_once
-    def actually_up(ctx):
+    def minimum_bot_perms(ctx) -> bool:
+        """
+        Too many 403, 401, and 429 Errors can cause bots to get global'd
+        
+        It's reasonable to assume the below as a minimum amount of perms for
+        commands.
+        """
+        return ctx.channel.permissions_for(ctx.me).send_messages
+
+    @bot.check_once
+    def actually_up(ctx) -> bool:
         """ 
         Uptime is set during the initial startup process.
         If this hasn't been set, we should assume the bot isn't ready yet. 
@@ -12,10 +22,10 @@ def actually_up(ctx):
         return ctx.bot.uptime is not None
 
     @bot.check_once
-    async def whiteblacklist_checks(ctx):
+    async def whiteblacklist_checks(ctx) -> bool:
         return await ctx.bot.allowed_by_whitelist_blacklist(ctx.author)
 
     @bot.check_once
-    def bots(ctx):
+    def bots(ctx) -> bool:
         """Check the user is not another bot."""
         return not ctx.author.bot


Test patch: