Added guild join event

This commit is contained in:
2023-09-28 08:03:27 +02:00
parent a8ea9f5e49
commit 378d2c3dc9
4 changed files with 70 additions and 22 deletions

View File

@@ -4,6 +4,7 @@ from datetime import datetime
from cpl_core.configuration import ConfigurationModelABC
from cpl_core.database import TableABC
from cpl_query.extension import List
from discord import Guild
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
from bot_data.model.server import Server
@@ -59,6 +60,29 @@ class ServerConfig(TableABC, ConfigurationModelABC):
self._created_at = created_at if created_at is not None else self._created_at
self._modified_at = modified_at if modified_at is not None else self._modified_at
@staticmethod
def new(guild: Guild, server: Server) -> "ServerConfig":
return ServerConfig(
6,
guild.system_channel.id,
6,
1,
1,
20,
10,
10,
10,
guild.system_channel.id,
guild.system_channel.id,
guild.system_channel.id,
guild.system_channel.id,
guild.default_role.id,
{},
server,
List(int),
List(int),
)
@property
def id(self) -> int:
return self._id

View File

@@ -34,31 +34,12 @@ class ServerConfigSeeder(DataSeederABC):
if self._server_config.does_server_config_exists(server.id):
continue
config = ServerConfig(
6,
guild.system_channel.id,
6,
1,
1,
20,
10,
10,
10,
guild.system_channel.id,
guild.system_channel.id,
guild.system_channel.id,
guild.system_channel.id,
guild.default_role.id,
{},
server,
[],
[],
)
config = ServerConfig.new(guild, server)
self._server_config.add_server_config(config)
self._db.save_changes()
self._logger.debug(__name__, "Seeded technician config")
self._logger.debug(__name__, "Seeded server config")
except Exception as e:
self._logger.error(__name__, f"Seeding technician config failed", e)
self._logger.error(__name__, f"Seeding server config failed", e)