Add VoiceChannel and Thread to isinstance checks

This commit is contained in:
z03h 2022-05-16 12:32:13 -07:00 committed by GitHub
parent 9450a8e972
commit cdf787186e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -2317,7 +2317,9 @@ def is_nsfw() -> Check[Any]:
def pred(ctx: Context[BotT]) -> bool: def pred(ctx: Context[BotT]) -> bool:
ch = ctx.channel ch = ctx.channel
if ctx.guild is None or (isinstance(ch, (discord.TextChannel, discord.Thread)) and ch.is_nsfw()): if ctx.guild is None or (
isinstance(ch, (discord.TextChannel, discord.Thread, discord.VoiceChannel)) and ch.is_nsfw()
):
return True return True
raise NSFWChannelRequired(ch) # type: ignore raise NSFWChannelRequired(ch) # type: ignore

View File

@ -1485,7 +1485,7 @@ class ConnectionState:
self.dispatch('raw_typing', raw) self.dispatch('raw_typing', raw)
def _get_reaction_user(self, channel: MessageableChannel, user_id: int) -> Optional[Union[User, Member]]: def _get_reaction_user(self, channel: MessageableChannel, user_id: int) -> Optional[Union[User, Member]]:
if isinstance(channel, TextChannel): if isinstance(channel, (TextChannel, Thread, VoiceChannel)):
return channel.guild.get_member(user_id) return channel.guild.get_member(user_id)
return self.get_user(user_id) return self.get_user(user_id)