From 1946077ded1a6d9c0fda29fa9fd3890ae985d0dc Mon Sep 17 00:00:00 2001 From: JetRaidz Date: Tue, 19 Sep 2023 18:32:29 +1200 Subject: [PATCH] Fix help command not working in DMs The `help` application command now functions as expected in DMs. This shows both member-level and admin-level commands. - Fixed `shop open` appearing in the DM slash command list - Fixed `support_guild` not being included in `example-bot.conf` - The following wards now require the `Guild` context to be passed to them: - `low_management` - `high_management` --- config/example-bot.conf | 2 ++ src/modules/meta/cog.py | 2 +- src/modules/shop/cog.py | 2 ++ src/wards.py | 18 +++++++++++------- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/config/example-bot.conf b/config/example-bot.conf index a5195d74..343752b0 100644 --- a/config/example-bot.conf +++ b/config/example-bot.conf @@ -11,6 +11,8 @@ ALSO_READ = config/emojis.conf, config/secrets.conf, config/gui.conf asset_path = assets +support_guild = + [ENDPOINTS] guild_log = gem_transaction = diff --git a/src/modules/meta/cog.py b/src/modules/meta/cog.py index e5cc5f4f..b865148d 100644 --- a/src/modules/meta/cog.py +++ b/src/modules/meta/cog.py @@ -32,6 +32,6 @@ class MetaCog(LionCog): ctx.bot, ctx.author, ctx.guild, - show_admin=await low_management(ctx.bot, ctx.author), + show_admin=await low_management(ctx.bot, ctx.author, ctx.guild), ) await ui.run(ctx.interaction) diff --git a/src/modules/shop/cog.py b/src/modules/shop/cog.py index 4892c2f2..a6885751 100644 --- a/src/modules/shop/cog.py +++ b/src/modules/shop/cog.py @@ -117,6 +117,7 @@ class Shopping(LionCog): name=_p('cmd:shop', 'shop'), description=_p('cmd:shop|desc', "Purchase coloures, roles, and other goodies with LionCoins.") ) + @appcmds.guild_only async def shop_group(self, ctx: LionContext): return @@ -124,6 +125,7 @@ class Shopping(LionCog): name=_p('cmd:shop_open', 'open'), description=_p('cmd:shop_open|desc', "Open the server shop.") ) + @appcmds.guild_only async def shop_open_cmd(self, ctx: LionContext): """ Opens the shop UI for the current guild. diff --git a/src/wards.py b/src/wards.py index 6198436b..e66683a0 100644 --- a/src/wards.py +++ b/src/wards.py @@ -21,13 +21,17 @@ async def sys_admin(bot: LionBot, userid: int): return userid in admins -async def high_management(bot: LionBot, member: discord.Member): +async def high_management(bot: LionBot, member: discord.Member, guild=discord.Guild): + if not guild: + return True if await sys_admin(bot, member.id): return True return member.guild_permissions.administrator -async def low_management(bot: LionBot, member: discord.Member): +async def low_management(bot: LionBot, member: discord.Member, guild: discord.Guild): + if not guild: + return True if await high_management(bot, member): return True return member.guild_permissions.manage_guild @@ -42,20 +46,20 @@ async def sys_admin_iward(interaction: discord.Interaction) -> bool: async def high_management_iward(interaction: discord.Interaction) -> bool: if not interaction.guild: return False - return await high_management(interaction.client, interaction.user) + return await high_management(interaction.client, interaction.user, interaction.guild) async def low_management_iward(interaction: discord.Interaction) -> bool: if not interaction.guild: return False - return await low_management(interaction.client, interaction.user) + return await low_management(interaction.client, interaction.user, interaction.guild) # High level ctx wards async def moderator_ctxward(ctx: LionContext) -> bool: if not ctx.guild: return False - passed = await low_management(ctx.bot, ctx.author) + passed = await low_management(ctx.bot, ctx.author, ctx.guild) if passed: return True modrole = ctx.lguild.data.mod_role @@ -85,7 +89,7 @@ async def sys_admin_ward(ctx: LionContext) -> bool: async def high_management_ward(ctx: LionContext) -> bool: if not ctx.guild: return False - passed = await high_management(ctx.bot, ctx.author) + passed = await high_management(ctx.bot, ctx.author, ctx.guild) if passed: return True else: @@ -101,7 +105,7 @@ async def high_management_ward(ctx: LionContext) -> bool: async def low_management_ward(ctx: LionContext) -> bool: if not ctx.guild: return False - passed = await low_management(ctx.bot, ctx.author) + passed = await low_management(ctx.bot, ctx.author, ctx.guild) if passed: return True else: