Repository: Cog-Creators/Red-DiscordBot

Issue:
[V3 Bank] Checks issue
https://sentry.io/will-tekulve/bot-development/issues/479390712/

```
AttributeError: 'NoneType' object has no attribute 'owner'
(5 additional frame(s) were not displayed)
...
  File "redbot/core/context.py", line 36, in send_help
    embeds = await self.bot.formatter.format_help_for(self, command)
  File "redbot/core/help_formatter.py", line 227, in format_help_for
    emb = await self.format()
  File "redbot/core/help_formatter.py", line 169, in format
    filtered = await self.filter_command_list()
  File "redbot/cogs/bank/bank.py", line 37, in pred
    is_guild_owner = author == ctx.guild.owner

Exception in command 'bank'
```
[V3 Bank] Checks issue
https://sentry.io/will-tekulve/bot-development/issues/479390712/

```
AttributeError: 'NoneType' object has no attribute 'owner'
(5 additional frame(s) were not displayed)
...
  File "redbot/core/context.py", line 36, in send_help
    embeds = await self.bot.formatter.format_help_for(self, command)
  File "redbot/core/help_formatter.py", line 227, in format_help_for
    emb = await self.format()
  File "redbot/core/help_formatter.py", line 169, in format
    filtered = await self.filter_command_list()
  File "redbot/cogs/bank/bank.py", line 37, in pred
    is_guild_owner = author == ctx.guild.owner

Exception in command 'bank'
```


Discussion:

Resolving patch:
diff --git a/redbot/cogs/bank/bank.py b/redbot/cogs/bank/bank.py
--- a/redbot/cogs/bank/bank.py
+++ b/redbot/cogs/bank/bank.py
@@ -1,3 +1,5 @@
+import discord
+
 from redbot.core import checks, bank
 from redbot.core.i18n import CogI18n
 from discord.ext import commands
@@ -17,6 +19,8 @@ async def pred(ctx: commands.Context):
         if await ctx.bot.is_owner(author):
             return True
         if not await bank.is_global():
+            if not isinstance(ctx.channel, discord.abc.GuildChannel):
+                return False
             permissions = ctx.channel.permissions_for(author)
             return author == ctx.guild.owner or permissions.administrator
 
@@ -33,6 +37,8 @@ async def pred(ctx: commands.Context):
         if await ctx.bot.is_owner(author):
             return True
         if not await bank.is_global():
+            if not isinstance(ctx.channel, discord.abc.GuildChannel):
+                return False
             permissions = ctx.channel.permissions_for(author)
             is_guild_owner = author == ctx.guild.owner
             admin_role = await ctx.bot.db.guild(ctx.guild).admin_role()
diff --git a/redbot/cogs/economy/economy.py b/redbot/cogs/economy/economy.py
--- a/redbot/cogs/economy/economy.py
+++ b/redbot/cogs/economy/economy.py
@@ -216,18 +216,9 @@ async def reset(self, ctx, confirmation: bool = False):
                 )
             )
         else:
-            if await bank.is_global():
-                # Bank being global means that the check would cause only
-                # the owner and any co-owners to be able to run the command
-                # so if we're in the function, it's safe to assume that the
-                # author is authorized to use owner-only commands
-                user = ctx.author
-            else:
-                user = ctx.guild.owner
-            success = await bank.wipe_bank()
-            if success:
-                await ctx.send(_("All bank accounts of this guild have been "
-                               "deleted."))
+            await bank.wipe_bank()
+            await ctx.send(_("All bank accounts of this guild have been "
+                             "deleted."))
 
     @commands.command()
     @guild_only_check()


Test patch: