[Permissions] Find things uniquely for models (#2258)

This is a safety measure to prevent accidentally passing a model which has the same name as another model, potentially modifying rules for the unwanted one.
This commit is contained in:
Michael H
2018-12-15 18:09:18 -05:00
committed by Toby Harradine
parent 2d9912cea7
commit 351749dff6
2 changed files with 135 additions and 6 deletions

View File

@@ -14,7 +14,13 @@ from redbot.core.utils.chat_formatting import box
from redbot.core.utils.menus import start_adding_reactions
from redbot.core.utils.predicates import ReactionPredicate, MessagePredicate
from .converters import CogOrCommand, RuleType, ClearableRuleType
from .converters import (
CogOrCommand,
RuleType,
ClearableRuleType,
GuildUniqueObjectFinder,
GlobalUniqueObjectFinder,
)
_ = Translator("Permissions", __file__)
@@ -275,7 +281,7 @@ class Permissions(commands.Cog):
ctx: commands.Context,
allow_or_deny: RuleType,
cog_or_command: CogOrCommand,
who_or_what: commands.GlobalPermissionModel,
who_or_what: GlobalUniqueObjectFinder,
):
"""Add a global rule to a command.
@@ -303,7 +309,7 @@ class Permissions(commands.Cog):
ctx: commands.Context,
allow_or_deny: RuleType,
cog_or_command: CogOrCommand,
who_or_what: commands.GuildPermissionModel,
who_or_what: GuildUniqueObjectFinder,
):
"""Add a rule to a command in this server.
@@ -328,7 +334,7 @@ class Permissions(commands.Cog):
self,
ctx: commands.Context,
cog_or_command: CogOrCommand,
who_or_what: commands.GlobalPermissionModel,
who_or_what: GlobalUniqueObjectFinder,
):
"""Remove a global rule from a command.
@@ -351,7 +357,7 @@ class Permissions(commands.Cog):
ctx: commands.Context,
cog_or_command: CogOrCommand,
*,
who_or_what: commands.GuildPermissionModel,
who_or_what: GuildUniqueObjectFinder,
):
"""Remove a server rule from a command.