Refactor server config models/commands

This commit is contained in:
Ske
2020-06-13 13:58:27 +02:00
parent 23c595f675
commit ed511a6236
5 changed files with 77 additions and 97 deletions

View File

@@ -0,0 +1,11 @@
namespace PluralKit.Core
{
public class GuildConfig
{
public int Id { get; }
public ulong? LogChannel { get; }
public ulong[] LogBlacklist { get; }
public ulong[] Blacklist { get; }
public bool LogCleanupEnabled { get; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Data;
using System.Threading.Tasks;
using Dapper;
namespace PluralKit.Core
{
public static class ModelQueryExt
{
public static Task<GuildConfig> QueryOrInsertGuildConfig(this IDbConnection conn, ulong guild) =>
conn.QueryFirstOrDefaultAsync<GuildConfig>("insert into servers (id) values (@Guild) on conflict do nothing returning *", new {Guild = guild});
}
}