[commands] fix bot_has_role and is_nsfw for threads
This commit is contained in:
parent
60d82cf908
commit
8851e03a6d
@ -1673,11 +1673,10 @@ def bot_has_role(item):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
ch = ctx.channel
|
if ctx.guild is None:
|
||||||
if not isinstance(ch, discord.abc.GuildChannel):
|
|
||||||
raise NoPrivateMessage()
|
raise NoPrivateMessage()
|
||||||
|
|
||||||
me = ch.guild.me
|
me = ctx.me
|
||||||
if isinstance(item, int):
|
if isinstance(item, int):
|
||||||
role = discord.utils.get(me.roles, id=item)
|
role = discord.utils.get(me.roles, id=item)
|
||||||
else:
|
else:
|
||||||
@ -1701,11 +1700,10 @@ def bot_has_any_role(*items):
|
|||||||
instead of generic checkfailure
|
instead of generic checkfailure
|
||||||
"""
|
"""
|
||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
ch = ctx.channel
|
if ctx.guild is None:
|
||||||
if not isinstance(ch, discord.abc.GuildChannel):
|
|
||||||
raise NoPrivateMessage()
|
raise NoPrivateMessage()
|
||||||
|
|
||||||
me = ch.guild.me
|
me = ctx.me
|
||||||
getter = functools.partial(discord.utils.get, me.roles)
|
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):
|
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
|
return True
|
||||||
@ -1902,7 +1900,7 @@ def is_nsfw():
|
|||||||
"""
|
"""
|
||||||
def pred(ctx):
|
def pred(ctx):
|
||||||
ch = ctx.channel
|
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
|
return True
|
||||||
raise NSFWChannelRequired(ch)
|
raise NSFWChannelRequired(ch)
|
||||||
return check(pred)
|
return check(pred)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user