[V3 Permissions] UX #1877

Closed
opened 2018-06-20 04:26:34 +02:00 by mikeshardmind · 4 comments
mikeshardmind commented 2018-06-20 04:26:34 +02:00 (Migrated from github.com)

I'll be going through and improving permissions UX a bit later. There are a couple of things which were pointed out by @retke which can be improved. Namely:

  • Consistent Argument ordering
  • Consistent way to remove settings
I'll be going through and improving permissions UX a bit later. There are a couple of things which were pointed out by @retke which can be improved. Namely: - [x] Consistent Argument ordering - [x] Consistent way to remove settings
laggron42 commented 2018-06-20 08:29:45 +02:00 (Migrated from github.com)

Also, I don't know how this should be done, but maybe we could add something so we can print a message when the rules doesn't allow the execution of a command.

For example, if we aren't in an authorised voice channel and we try to use the Audio cog, the bot should output something like "I cannot join that voice channel".

Also, I don't know how this should be done, but maybe we could add something so we can print a message when the rules doesn't allow the execution of a command. For example, if we aren't in an authorised voice channel and we try to use the Audio cog, the bot should output something like "I cannot join that voice channel".
laggron42 commented 2018-06-20 11:59:20 +02:00 (Migrated from github.com)

And also, if I can add some suggestions, I'd like these features in the permissions cog:

  • Be able to select everything (instead of a cog or a command), so you can do things like lock all commands everywhere except in the #bot channel.

  • Be able to select multiple objects and combine them (for example x role can use y command in z channel only, while the others can't)

And also, if I can add some suggestions, I'd like these features in the permissions cog: - Be able to select everything (instead of a cog or a command), so you can do things like lock all commands everywhere except in the #bot channel. - Be able to select multiple objects and combine them (for example x role can use y command in z channel only, while the others can't)
mikeshardmind commented 2018-06-20 12:25:05 +02:00 (Migrated from github.com)

I feel like both of those are out of scope for what permissions is aimed at doing. That said, if you want either of those behaviors, here's a brief demo of the extensibility built into permissions (not thoroughly documented yet) for such special cases.

class PermissionExtender:
    """Demonstrate the pre/post hooks in core Permissions"""

    async def __red_permissions_before(self, ctx, level) -> bool:
        """
        This gets evaluated prior to normal permissions logic.
        Should return 
        `True` if the user can run it, (use this one with extreme caution)
        `False` if they can't or 
        `None` to defer to remaining logic
        """
        if ctx.guild is None:
            return None
        if ctx.guild.id == 133049272517001216:
            if ctx.channel.name == "bot-chamber":
                return None  # We don't want to allow, we want to not disallow
            else:
                return False  # block commands in that guild not in the bot-chamber
   

    async def __red_permissions_after(self, ctx, level) -> bool:
        """
        This gets evaluated after normal permissions logic.
        Should return 
        `True` if the user can run it, (use this one with extreme caution)
        `False` if they can't or 
        `None` to defer to remaining logic 
        """
        if ctx.channel.name == "red-team" and "Red Team Leader" in [r.name for r in ctx.author.roles]:
            if ctx.command.name == 'mute':
                return True
        return None
I feel like both of those are out of scope for what permissions is aimed at doing. That said, if you want either of those behaviors, here's a brief demo of the extensibility built into permissions (not thoroughly documented yet) for such special cases. ```py class PermissionExtender: """Demonstrate the pre/post hooks in core Permissions""" async def __red_permissions_before(self, ctx, level) -> bool: """ This gets evaluated prior to normal permissions logic. Should return `True` if the user can run it, (use this one with extreme caution) `False` if they can't or `None` to defer to remaining logic """ if ctx.guild is None: return None if ctx.guild.id == 133049272517001216: if ctx.channel.name == "bot-chamber": return None # We don't want to allow, we want to not disallow else: return False # block commands in that guild not in the bot-chamber async def __red_permissions_after(self, ctx, level) -> bool: """ This gets evaluated after normal permissions logic. Should return `True` if the user can run it, (use this one with extreme caution) `False` if they can't or `None` to defer to remaining logic """ if ctx.channel.name == "red-team" and "Red Team Leader" in [r.name for r in ctx.author.roles]: if ctx.command.name == 'mute': return True return None ```
mikeshardmind commented 2018-07-14 04:10:15 +02:00 (Migrated from github.com)

This is done as of #1905

This is done as of #1905
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#1877
No description provided.