diff options
| author | z03h <[email protected]> | 2021-07-30 18:26:49 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-30 21:26:49 -0400 |
| commit | 8851e03a6d85e02d03ded0928ea277b8b9d689da (patch) | |
| tree | 8d09212afcd1ae180fcf33844e9f0e0668460eff | |
| parent | implement guild stickers (diff) | |
| download | discord.py-8851e03a6d85e02d03ded0928ea277b8b9d689da.tar.xz discord.py-8851e03a6d85e02d03ded0928ea277b8b9d689da.zip | |
[commands] fix bot_has_role and is_nsfw for threads
| -rw-r--r-- | discord/ext/commands/core.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index ef520e65..abf88326 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -1673,11 +1673,10 @@ def bot_has_role(item): """ def predicate(ctx): - ch = ctx.channel - if not isinstance(ch, discord.abc.GuildChannel): + if ctx.guild is None: raise NoPrivateMessage() - me = ch.guild.me + me = ctx.me if isinstance(item, int): role = discord.utils.get(me.roles, id=item) else: @@ -1701,11 +1700,10 @@ def bot_has_any_role(*items): instead of generic checkfailure """ def predicate(ctx): - ch = ctx.channel - if not isinstance(ch, discord.abc.GuildChannel): + if ctx.guild is None: raise NoPrivateMessage() - me = ch.guild.me + me = ctx.me getter = functools.partial(discord.utils.get, me.roles) if any(getter(id=item) is not None if isinstance(item, int) else getter(name=item) is not None for item in items): return True @@ -1902,7 +1900,7 @@ def is_nsfw(): """ def pred(ctx): ch = ctx.channel - if ctx.guild is None or (isinstance(ch, discord.TextChannel) and ch.is_nsfw()): + if ctx.guild is None or (isinstance(ch, (discord.TextChannel, discord.Thread)) and ch.is_nsfw()): return True raise NSFWChannelRequired(ch) return check(pred) |