From 3d4f9500e916080856338819a0562ed8f225d10e Mon Sep 17 00:00:00 2001 From: Michael H Date: Sun, 26 Jan 2020 19:00:08 -0500 Subject: [PATCH] [Permissions] Ordering fix (#3452) --- redbot/core/commands/requires.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/redbot/core/commands/requires.py b/redbot/core/commands/requires.py index 69d7d44c5..a476e9c79 100644 --- a/redbot/core/commands/requires.py +++ b/redbot/core/commands/requires.py @@ -9,6 +9,7 @@ checks like bot permissions checks. import asyncio import enum import inspect +from collections import ChainMap from typing import ( Union, Optional, @@ -21,6 +22,7 @@ from typing import ( TypeVar, Tuple, ClassVar, + Mapping, ) import discord @@ -367,6 +369,8 @@ class Requires: guild_id : int The ID of the guild for the rule's scope. Set to `Requires.GLOBAL` for a global rule. + If a global rule is set for a model, + it will be prefered over the guild rule. Returns ------- @@ -377,8 +381,9 @@ class Requires: """ if not isinstance(model, (str, int)): model = model.id + rules: Mapping[Union[int, str], PermState] if guild_id: - rules = self._guild_rules.get(guild_id, _RulesDict()) + rules = ChainMap(self._global_rules, self._guild_rules.get(guild_id, _RulesDict())) else: rules = self._global_rules return rules.get(model, PermState.NORMAL)