bot: add birthday command

This commit is contained in:
Ske
2019-05-13 22:44:49 +02:00
parent b42e052fee
commit 62dc2ce78e
7 changed files with 124 additions and 7 deletions

View File

@@ -10,6 +10,7 @@ using Discord.Commands;
using Discord.WebSocket;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using NodaTime;
using Npgsql;
namespace PluralKit.Bot
@@ -34,6 +35,14 @@ namespace PluralKit.Bot
SqlMapper.AddTypeHandler<ulong>(new UlongEncodeAsLongHandler());
Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true;
// Also, use NodaTime. it's good.
NpgsqlConnection.GlobalTypeMapper.UseNodaTime();
// With the thing we add above, Npgsql already handles NodaTime integration
// This makes Dapper confused since it thinks it has to convert it anyway and doesn't understand the types
// So we add a custom type handler that literally just passes the type through to Npgsql
SqlMapper.AddTypeHandler(new PassthroughTypeHandler<Instant>());
SqlMapper.AddTypeHandler(new PassthroughTypeHandler<LocalDate>());
using (var services = BuildServiceProvider())
{
Console.WriteLine("- Connecting to database...");