master #475
@ -32,6 +32,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
default_role_id: Optional[int],
|
||||
short_role_name_only_set_highest_role: bool,
|
||||
game_offer_notification_chat_id: int,
|
||||
reset_member_after_rejoin: bool,
|
||||
feature_flags: dict[FeatureFlagsEnum],
|
||||
server: Server,
|
||||
afk_channel_ids: List[int],
|
||||
@ -58,6 +59,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
self._default_role_id = default_role_id
|
||||
self._short_role_name_only_set_highest_role = short_role_name_only_set_highest_role
|
||||
self._game_offer_notification_chat_id = game_offer_notification_chat_id
|
||||
self._reset_member_after_rejoin = reset_member_after_rejoin
|
||||
|
||||
self._feature_flags = feature_flags
|
||||
self._server = server
|
||||
@ -88,6 +90,7 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
None,
|
||||
False,
|
||||
guild.system_channel.id,
|
||||
False,
|
||||
{},
|
||||
server,
|
||||
List(int),
|
||||
@ -234,6 +237,14 @@ class ServerConfig(TableABC, ConfigurationModelABC):
|
||||
def game_offer_notification_chat_id(self, value: int):
|
||||
self._game_offer_notification_chat_id = value
|
||||
|
||||
@property
|
||||
def reset_member_after_rejoin(self) -> bool:
|
||||
return self._reset_member_after_rejoin
|
||||
|
||||
@reset_member_after_rejoin.setter
|
||||
def reset_member_after_rejoin(self, value: bool):
|
||||
self._reset_member_after_rejoin = value
|
||||
|
||||
@property
|
||||
def feature_flags(self) -> dict[FeatureFlagsEnum]:
|
||||
return self._feature_flags
|
||||
|
@ -38,6 +38,11 @@ class User(TableABC):
|
||||
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
|
||||
|
||||
def reset(self):
|
||||
self._xp = 0
|
||||
self._message_count = 0
|
||||
self._reaction_count = 0
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._user_id
|
||||
|
@ -0,0 +1,7 @@
|
||||
ALTER TABLE CFG_Server
|
||||
DROP COLUMN ResetMemberAfterRejoin;
|
||||
|
||||
ALTER TABLE CFG_ServerHistory
|
||||
DROP COLUMN ResetMemberAfterRejoin;
|
||||
|
||||
|
116
bot/src/bot_data/scripts/1.2.4/1_ResetMemberAfterRejoin_up.sql
Normal file
116
bot/src/bot_data/scripts/1.2.4/1_ResetMemberAfterRejoin_up.sql
Normal file
@ -0,0 +1,116 @@
|
||||
ALTER TABLE CFG_Server
|
||||
ADD ResetMemberAfterRejoin BOOLEAN NOT NULL DEFAULT FALSE AFTER GameOfferNotificationChatId;
|
||||
|
||||
|
||||
|
||||
ALTER TABLE CFG_ServerHistory
|
||||
ADD ResetMemberAfterRejoin BOOLEAN NOT NULL DEFAULT FALSE AFTER GameOfferNotificationChatId;
|
||||
|
||||
DROP TRIGGER IF EXISTS `TR_CFG_ServerUpdate`;;
|
||||
|
||||
CREATE TRIGGER `TR_CFG_ServerUpdate`
|
||||
AFTER UPDATE
|
||||
ON `CFG_Server`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO `CFG_ServerHistory` (`Id`,
|
||||
`MessageDeleteTimer`,
|
||||
`NotificationChatId`,
|
||||
`MaxVoiceStateHours`,
|
||||
`XpPerMessage`,
|
||||
`XpPerReaction`,
|
||||
`MaxMessageXpPerHour`,
|
||||
`XpPerOntimeHour`,
|
||||
`XpPerEventParticipation`,
|
||||
`XpPerAchievement`,
|
||||
`AFKCommandChannelId`,
|
||||
`HelpVoiceChannelId`,
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`DefaultRoleId`,
|
||||
`ShortRoleNameSetOnlyHighest`,
|
||||
`GameOfferNotificationChatId`,
|
||||
`ResetMemberAfterRejoin`,
|
||||
`FeatureFlags`,
|
||||
`ServerId`,
|
||||
`DateFrom`,
|
||||
`DateTo`)
|
||||
VALUES (OLD.Id,
|
||||
OLD.MessageDeleteTimer,
|
||||
OLD.NotificationChatId,
|
||||
OLD.MaxVoiceStateHours,
|
||||
OLD.XpPerMessage,
|
||||
OLD.XpPerReaction,
|
||||
OLD.MaxMessageXpPerHour,
|
||||
OLD.XpPerOntimeHour,
|
||||
OLD.XpPerEventParticipation,
|
||||
OLD.XpPerAchievement,
|
||||
OLD.AFKCommandChannelId,
|
||||
OLD.HelpVoiceChannelId,
|
||||
OLD.TeamChannelId,
|
||||
OLD.LoginMessageChannelId,
|
||||
OLD.DefaultRoleId,
|
||||
OLD.ShortRoleNameSetOnlyHighest,
|
||||
OLD.GameOfferNotificationChatId,
|
||||
OLD.ResetMemberAfterRejoin,
|
||||
OLD.FeatureFlags,
|
||||
OLD.ServerId,
|
||||
OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6));
|
||||
END;;
|
||||
|
||||
DROP TRIGGER IF EXISTS `TR_CFG_ServerDelete`;;
|
||||
|
||||
CREATE TRIGGER `TR_CFG_ServerDelete`
|
||||
AFTER DELETE
|
||||
ON `CFG_Server`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO `CFG_ServerHistory` (`Id`,
|
||||
`MessageDeleteTimer`,
|
||||
`NotificationChatId`,
|
||||
`MaxVoiceStateHours`,
|
||||
`XpPerMessage`,
|
||||
`XpPerReaction`,
|
||||
`MaxMessageXpPerHour`,
|
||||
`XpPerOntimeHour`,
|
||||
`XpPerEventParticipation`,
|
||||
`XpPerAchievement`,
|
||||
`AFKCommandChannelId`,
|
||||
`HelpVoiceChannelId`,
|
||||
`TeamChannelId`,
|
||||
`LoginMessageChannelId`,
|
||||
`DefaultRoleId`,
|
||||
`ShortRoleNameSetOnlyHighest`,
|
||||
`GameOfferNotificationChatId`,
|
||||
`ResetMemberAfterRejoin`,
|
||||
`ServerId`,
|
||||
`FeatureFlags`,
|
||||
`Deleted`,
|
||||
`DateFrom`,
|
||||
`DateTo`)
|
||||
VALUES (OLD.Id,
|
||||
OLD.MessageDeleteTimer,
|
||||
OLD.NotificationChatId,
|
||||
OLD.MaxVoiceStateHours,
|
||||
OLD.XpPerMessage,
|
||||
OLD.XpPerReaction,
|
||||
OLD.MaxMessageXpPerHour,
|
||||
OLD.XpPerOntimeHour,
|
||||
OLD.XpPerEventParticipation,
|
||||
OLD.XpPerAchievement,
|
||||
OLD.AFKCommandChannelId,
|
||||
OLD.HelpVoiceChannelId,
|
||||
OLD.TeamChannelId,
|
||||
OLD.LoginMessageChannelId,
|
||||
OLD.DefaultRoleId,
|
||||
OLD.ShortRoleNameSetOnlyHighest,
|
||||
OLD.GameOfferNotificationChatId,
|
||||
OLD.ResetMemberAfterRejoin,
|
||||
OLD.FeatureFlags,
|
||||
OLD.ServerId,
|
||||
TRUE,
|
||||
OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6));
|
||||
END;;
|
||||
|
@ -78,6 +78,12 @@ class BaseOnMemberJoinEvent(OnMemberJoinABC):
|
||||
user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id)
|
||||
if user is not None:
|
||||
self._user_joins.add_user_joined_server(UserJoinedServer(user, datetime.now()))
|
||||
|
||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}")
|
||||
if server_config.reset_member_after_rejoin:
|
||||
user.reset()
|
||||
self._users.update_user(user)
|
||||
|
||||
self._db.save_changes()
|
||||
return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user