refactor: change ulong[] to List<ulong> for better ergonomics
This commit is contained in:
parent
e12bd6194b
commit
4eb5c16451
8 changed files with 37 additions and 46 deletions
|
|
@ -119,25 +119,14 @@ public class GuildRepository(ILogger logger, DatabaseConnection conn)
|
|||
|
||||
private record BannedSystem(Guid SystemId, ulong UserId, ulong GuildId);
|
||||
|
||||
public async Task AddKeyRoleAsync(Snowflake guildId, Snowflake roleId) =>
|
||||
await conn.ExecuteAsync(
|
||||
"update guilds set key_roles = array_append(key_roles, @RoleId) where id = @GuildId",
|
||||
new { GuildId = guildId.Value, RoleId = roleId.Value }
|
||||
);
|
||||
|
||||
public async Task RemoveKeyRoleAsync(Snowflake guildId, Snowflake roleId) =>
|
||||
await conn.ExecuteAsync(
|
||||
"update guilds set key_roles = array_remove(key_roles, @RoleId) where id = @GuildId",
|
||||
new { GuildId = guildId.Value, RoleId = roleId.Value }
|
||||
);
|
||||
|
||||
public async Task UpdateConfigAsync(Snowflake id, Guild config) =>
|
||||
await conn.ExecuteAsync(
|
||||
"""
|
||||
update guilds set channels = @Channels::jsonb,
|
||||
messages = @Messages::jsonb,
|
||||
ignored_channels = @IgnoredChannels,
|
||||
ignored_roles = @IgnoredRoles
|
||||
ignored_roles = @IgnoredRoles,
|
||||
key_roles = @KeyRoles
|
||||
where id = @Id
|
||||
""",
|
||||
new
|
||||
|
|
@ -147,6 +136,7 @@ public class GuildRepository(ILogger logger, DatabaseConnection conn)
|
|||
config.Messages,
|
||||
config.IgnoredChannels,
|
||||
config.IgnoredRoles,
|
||||
config.KeyRoles,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -155,7 +145,7 @@ public class GuildRepository(ILogger logger, DatabaseConnection conn)
|
|||
Guild.ChannelConfig channels,
|
||||
Guild.MessageConfig messages,
|
||||
string[] bannedSystems,
|
||||
ulong[] keyRoles
|
||||
List<ulong> keyRoles
|
||||
) =>
|
||||
await conn.ExecuteAsync(
|
||||
"update guilds set channels = @channels::jsonb, messages = @messages::jsonb, banned_systems = @bannedSystems, key_roles = @keyRoles where id = @id",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue