18 lines
493 B
Python
18 lines
493 B
Python
from collections import AsyncIterable
|
|
from typing import Callable, AsyncGenerator, Optional
|
|
import discord
|
|
|
|
|
|
async def async_filter(fun: Callable, iterable: AsyncIterable) -> AsyncGenerator:
|
|
async for val in iterable:
|
|
if fun(val):
|
|
yield val
|
|
|
|
|
|
def find_category(guild: discord.Guild, group: str) -> Optional[discord.CategoryChannel]:
|
|
group = group.lower()
|
|
for cat in guild.categories:
|
|
if cat.name.lower() == group:
|
|
return cat
|
|
return None
|