1.1.7 - #376 #375 #374 #377

Merged
edraft merged 24 commits from 1.1.7 into support 2023-09-28 18:12:58 +02:00
Showing only changes of commit 0037a30c11 - Show all commits

View File

@ -1,3 +1,4 @@
import discord
from cpl_discord.service import DiscordBotServiceABC
from cpl_query.extension import List
from discord import Guild
@ -17,22 +18,24 @@ class GuildQuery(QueryABC):
self.set_field("id", lambda g, *_: g.id)
self.set_field("name", lambda g, *_: g.name)
self.set_field("channels", self._resolve_channels)
self.set_field("roles", lambda g, *_: g.roles)
self.set_field("emojis", lambda g, *_: g.emojis)
self.set_field("roles", lambda g, *_: g.roles.order_by(lambda x: x.position))
self.set_field(
"emojis", lambda g, *_: List(discord.Emoji, g.emojis).order_by_descending(lambda x: x.created_at)
)
def _resolve_channels(self, g: Guild, *_, filter=None):
users = List(any).extend(g.channels)
channels = List(any).extend(g.channels)
if filter is None:
return users
return channels
if "id" in filter:
users = users.where(lambda c: c.id == int(filter["id"]))
channels = channels.where(lambda c: c.id == int(filter["id"]))
if "name" in filter:
users = users.where(lambda c: c.id == filter["name"])
channels = channels.where(lambda c: c.id == filter["name"])
if "type" in filter:
users = users.where(lambda c: type(c).__name__ == filter["type"])
channels = channels.where(lambda c: type(c).__name__ == filter["type"])
return users
return channels.order_by(lambda x: x.position)