feat(bot): add new guild settings command

This commit is contained in:
Iris System 2024-11-10 15:46:36 +13:00
parent f0436332c0
commit 0473bd8f01
15 changed files with 179 additions and 15 deletions

View file

@ -18,6 +18,7 @@ public class MessageContext
public bool InBlacklist { get; }
public bool InLogBlacklist { get; }
public bool LogCleanupEnabled { get; }
public bool RequireSystemTag { get; }
public bool ProxyEnabled { get; }
public SwitchId? LastSwitch { get; }
public MemberId[] LastSwitchMembers { get; } = new MemberId[0];

View file

@ -25,6 +25,7 @@ create function message_context(account_id bigint, guild_id bigint, channel_id b
in_blacklist bool,
in_log_blacklist bool,
log_cleanup_enabled bool,
require_system_tag bool,
deny_bot_usage bool
)
@ -63,6 +64,7 @@ as $$
((channel_id = any (servers.log_blacklist))
or (thread_id = any (servers.log_blacklist))) as in_log_blacklist,
coalesce(servers.log_cleanup_enabled, false) as log_cleanup_enabled,
coalesce(servers.require_system_tag, false) as require_system_tag,
-- abuse_logs table
coalesce(abuse_logs.deny_bot_usage, false) as deny_bot_usage

View file

@ -0,0 +1,9 @@
-- database version 48
--
-- add guild settings for disabling "invalid command" responses &
-- enforcing the presence of system tags
alter table servers add column invalid_command_response_enabled bool not null default true;
alter table servers add column require_system_tag bool not null default false;
update info set schema_version = 48;

View file

@ -9,7 +9,7 @@ namespace PluralKit.Core;
internal class DatabaseMigrator
{
private const string RootPath = "PluralKit.Core.Database"; // "resource path" root for SQL files
private const int TargetSchemaVersion = 47;
private const int TargetSchemaVersion = 48;
private readonly ILogger _logger;
public DatabaseMigrator(ILogger logger)

View file

@ -7,4 +7,6 @@ public class GuildConfig
public ulong[] LogBlacklist { get; }
public ulong[] Blacklist { get; }
public bool LogCleanupEnabled { get; }
public bool InvalidCommandResponseEnabled { get; }
public bool RequireSystemTag { get; }
}

View file

@ -8,11 +8,15 @@ public class GuildPatch: PatchObject
public Partial<ulong[]> LogBlacklist { get; set; }
public Partial<ulong[]> Blacklist { get; set; }
public Partial<bool> LogCleanupEnabled { get; set; }
public Partial<bool> InvalidCommandResponseEnabled { get; set; }
public Partial<bool> RequireSystemTag { get; set; }
public override Query Apply(Query q) => q.ApplyPatch(wrapper => wrapper
.With("log_channel", LogChannel)
.With("log_blacklist", LogBlacklist)
.With("blacklist", Blacklist)
.With("log_cleanup_enabled", LogCleanupEnabled)
.With("invalid_command_response_enabled", InvalidCommandResponseEnabled)
.With("require_system_tag", RequireSystemTag)
);
}