Refactor server config models/commands
This commit is contained in:
11
PluralKit.Core/Models/GuildConfig.cs
Normal file
11
PluralKit.Core/Models/GuildConfig.cs
Normal 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; }
|
||||
}
|
||||
}
|
14
PluralKit.Core/Models/ModelQueryExt.cs
Normal file
14
PluralKit.Core/Models/ModelQueryExt.cs
Normal 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});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user