<commit_before>from __future__ import annotations

from typing import Callable, TypeVar

from discord import Member, TextChannel
from discord.ext import commands
from discord.ext.commands import Context

T = TypeVar("T")


def is_owner_or(**perms: bool) -> Callable[[T], T]:
    async def predicate(ctx: Context) -> bool:
        author = ctx.author
        channel = ctx.channel
        if not isinstance(channel, TextChannel):
            return True
        assert isinstance(author, Member)
        if await ctx.bot.is_owner(author):
            return True
        permissions = channel.permissions_for(author)
        return all(
            getattr(permissions, perm, None) == value for perm, value in perms.items()
        )

    return commands.check(predicate)<commit_msg>Fix is_owner_or for threads<commit_after>from __future__ import annotations

from typing import Callable, TypeVar

from discord import Member, TextChannel, Thread
from discord.ext import commands
from discord.ext.commands import Context

T = TypeVar("T")


def is_owner_or(**perms: bool) -> Callable[[T], T]:
    async def predicate(ctx: Context) -> bool:
        author = ctx.author
        channel = ctx.channel
        if ctx.guild is None:
            return True
        assert isinstance(author, Member)
        assert isinstance(channel, (TextChannel, Thread))
        if await ctx.bot.is_owner(author):
            return True
        permissions = channel.permissions_for(author)
        return all(
            getattr(permissions, perm, None) == value for perm, value in perms.items()
        )

    return commands.check(predicate)
{'fraction_non_alphanumeric': 0.08553846153846154, 'fraction_numerical': 0.0, 'mean_word_length': 2.889952153110048, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1824205', 'n_tokens_mistral': 446, 'n_tokens_neox': 430, 'n_words': 141}