1.0.0 #253
@ -19,6 +19,7 @@ from bot_graphql.mutations.level_mutation import LevelMutation
|
||||
from bot_graphql.queries.auto_role_query import AutoRoleQuery
|
||||
from bot_graphql.queries.auto_role_rule_query import AutoRoleRuleQuery
|
||||
from bot_graphql.queries.client_query import ClientQuery
|
||||
from bot_graphql.queries.known_user_query import KnownUserQuery
|
||||
from bot_graphql.queries.level_query import LevelQuery
|
||||
from bot_graphql.queries.server_query import ServerQuery
|
||||
from bot_graphql.queries.user_joined_server_query import UserJoinedServerQuery
|
||||
@ -41,6 +42,7 @@ class GraphQLModule(ModuleABC):
|
||||
services.add_singleton(Query)
|
||||
services.add_singleton(Mutation)
|
||||
services.add_transient(QueryABC, ServerQuery)
|
||||
services.add_transient(QueryABC, KnownUserQuery)
|
||||
services.add_transient(QueryABC, LevelQuery)
|
||||
services.add_transient(QueryABC, LevelMutation)
|
||||
services.add_transient(QueryABC, ClientQuery)
|
||||
|
@ -38,6 +38,7 @@ type Server implements TableQuery {
|
||||
id: ID
|
||||
discord_id: String
|
||||
name: String
|
||||
auto_roles: [AutoRole]
|
||||
clients: [Client]
|
||||
members: [User]
|
||||
levels: [Level]
|
||||
@ -90,7 +91,7 @@ input UserFilter {
|
||||
discord_id: String
|
||||
name: String
|
||||
xp: Int
|
||||
ontime: Int
|
||||
ontime: Float
|
||||
level: LevelFilter
|
||||
|
||||
page_index: Int
|
||||
@ -104,11 +105,11 @@ type User implements TableQuery {
|
||||
discord_id: String
|
||||
name: String
|
||||
xp: Int
|
||||
ontime: Int
|
||||
ontime: Float
|
||||
level: Level
|
||||
|
||||
joined_servers: [UserJoinedServer]
|
||||
joined_voice_channel: [UserJoinedVoiceChannel]
|
||||
joined_voice_channels: [UserJoinedVoiceChannel]
|
||||
|
||||
server: Server
|
||||
|
||||
|
@ -35,13 +35,13 @@ class AutoRoleQuery(DataQueryABC):
|
||||
def resolve_message_id(x: AutoRole, *_):
|
||||
return x.discord_message_id
|
||||
|
||||
def resolve_server(self, x: AutoRole, *_, filter: ServerFilter):
|
||||
def resolve_server(self, x: AutoRole, *_, filter: ServerFilter = None):
|
||||
if filter is not None:
|
||||
return filter.filter(self._servers.get_server_by_id(x.server_id))
|
||||
|
||||
return self._servers.get_server_by_id(x.server_id)
|
||||
|
||||
def resolve_rules(self, x: AutoRole, *_, filter: AutoRoleRuleFilter):
|
||||
def resolve_rules(self, x: AutoRole, *_, filter: AutoRoleRuleFilter = None):
|
||||
if filter is not None:
|
||||
return filter.filter(self._auto_role_rules.get_auto_role_rules_by_auto_role_id(x.auto_role_id))
|
||||
|
||||
|
18
kdb-bot/src/bot_graphql/queries/known_user_query.py
Normal file
18
kdb-bot/src/bot_graphql/queries/known_user_query.py
Normal file
@ -0,0 +1,18 @@
|
||||
from bot_data.model.known_user import KnownUser
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
|
||||
|
||||
class KnownUserQuery(DataQueryABC):
|
||||
def __init__(self):
|
||||
DataQueryABC.__init__(self, "KnownUser")
|
||||
|
||||
self.set_field("id", self.resolve_id)
|
||||
self.set_field("discord_id", self.resolve_discord_id)
|
||||
|
||||
@staticmethod
|
||||
def resolve_id(x: KnownUser, *_):
|
||||
return x.known_user_id
|
||||
|
||||
@staticmethod
|
||||
def resolve_discord_id(x: KnownUser, *_):
|
||||
return x.discord_id
|
@ -50,7 +50,7 @@ class ServerQuery(DataQueryABC):
|
||||
guild = self._bot.get_guild(server.discord_server_id)
|
||||
return None if guild is None else guild.name
|
||||
|
||||
def resolve_auto_roles(self, server: Server, *_, filter: AutoRoleFilter):
|
||||
def resolve_auto_roles(self, server: Server, *_, filter: AutoRoleFilter = None):
|
||||
if filter is not None:
|
||||
return filter.filter(self._auto_roles.get_auto_roles_by_server_id(server.server_id))
|
||||
|
||||
|
@ -32,7 +32,7 @@ class UserQuery(DataQueryABC):
|
||||
self.set_field("ontime", self.resolve_ontime)
|
||||
self.set_field("level", self.resolve_level)
|
||||
self.set_field("joined_servers", self.resolve_joined_servers)
|
||||
self.set_field("joined_voice_channel", self.resolve_joined_voice_channel)
|
||||
self.set_field("joined_voice_channels", self.resolve_joined_voice_channel)
|
||||
self.set_field("server", self.resolve_server)
|
||||
|
||||
@staticmethod
|
||||
@ -44,7 +44,9 @@ class UserQuery(DataQueryABC):
|
||||
return user.discord_id
|
||||
|
||||
def resolve_name(self, user: User, *_):
|
||||
return self._bot.get_guild(user.server.discord_server_id).get_member(user.discord_id).name
|
||||
guild = self._bot.get_guild(user.server.discord_server_id)
|
||||
user = guild.get_member(user.discord_id)
|
||||
return None if user is None else user.name
|
||||
|
||||
@staticmethod
|
||||
def resolve_xp(user: User, *_):
|
||||
|
Loading…
Reference in New Issue
Block a user