[V3] DM usage fixes (#1919)

* DM usage fixes

* ...

* ...

* ...

* ok, formatting...
This commit is contained in:
Michael H 2018-07-11 20:46:14 -04:00 committed by Kowlin
parent c0d01f32a6
commit 35149f8837
5 changed files with 15 additions and 8 deletions

View File

@ -291,6 +291,7 @@ class Admin:
# noinspection PyTypeChecker
return valid_roles
@commands.guild_only()
@commands.group(invoke_without_command=True)
async def selfrole(self, ctx: commands.Context, *, selfrole: SelfRole):
"""

View File

@ -17,13 +17,15 @@ def check_global_setting_guildowner():
async def pred(ctx: commands.Context):
author = ctx.author
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
if await ctx.bot.is_owner(author):
return True
permissions = ctx.channel.permissions_for(author)
return author == ctx.guild.owner or permissions.administrator
else:
return await ctx.bot.is_owner(author)
return commands.check(pred)
@ -36,15 +38,17 @@ def check_global_setting_admin():
async def pred(ctx: commands.Context):
author = ctx.author
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
if await ctx.bot.is_owner(author):
return True
permissions = ctx.channel.permissions_for(author)
is_guild_owner = author == ctx.guild.owner
admin_role = await ctx.bot.db.guild(ctx.guild).admin_role()
return admin_role in author.roles or is_guild_owner or permissions.manage_guild
else:
return await ctx.bot.is_owner(author)
return commands.check(pred)
@ -58,8 +62,9 @@ class Bank:
# SECTION commands
@commands.group()
@check_global_setting_guildowner()
@checks.guildowner_or_permissions(administrator=True)
@commands.group(autohelp=True)
async def bankset(self, ctx: commands.Context):
"""Base command for bank settings"""
if ctx.invoked_subcommand is None:

View File

@ -423,7 +423,7 @@ class Cleanup:
if author == self.bot.user:
to_delete.append(ctx.message)
if channel.name:
if ctx.guild:
channel_name = "channel " + channel.name
else:
channel_name = str(channel)

View File

@ -137,6 +137,7 @@ class Economy:
self.config.register_role(**self.default_role_settings)
self.slot_register = defaultdict(dict)
@guild_only_check()
@commands.group(name="bank")
async def _bank(self, ctx: commands.Context):
"""Bank operations"""
@ -209,7 +210,6 @@ class Economy:
)
@_bank.command()
@guild_only_check()
@check_global_setting_guildowner()
async def reset(self, ctx, confirmation: bool = False):
"""Deletes bank accounts"""
@ -230,8 +230,8 @@ class Economy:
)
)
@commands.command()
@guild_only_check()
@commands.command()
async def payday(self, ctx: commands.Context):
"""Get some free currency"""
author = ctx.author

View File

@ -360,6 +360,7 @@ class Core(CoreLogic):
@embedset.command(name="guild")
@checks.guildowner_or_permissions(administrator=True)
@commands.guild_only()
async def embedset_guild(self, ctx: commands.Context, enabled: bool = None):
"""
Toggle the guild's embed setting.