Add och!groups command

This commit is contained in:
2021-03-12 14:14:05 +01:00
parent 02221b0790
commit da5450cd62
3 changed files with 114 additions and 2 deletions

View File

@@ -1,8 +1,17 @@
from collections import AsyncIterable
from typing import Callable, AsyncGenerator
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