feat: export guilds from old bot and import into new one
This commit is contained in:
parent
301744dd4e
commit
9302ba200f
10 changed files with 1326 additions and 0 deletions
56
Catalogger.GoImporter/Program.cs
Normal file
56
Catalogger.GoImporter/Program.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
using System.Text.Json;
|
||||
using Catalogger.Backend;
|
||||
using Catalogger.Backend.Database;
|
||||
using Catalogger.Backend.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NodaTime;
|
||||
using NodaTime.Serialization.SystemTextJson;
|
||||
using NodaTime.Text;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using Serilog.Sinks.SystemConsole.Themes;
|
||||
|
||||
namespace Catalogger.GoImporter;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
public static JsonSerializerOptions JsonOptions =
|
||||
new JsonSerializerOptions().ConfigureForNodaTime(
|
||||
new NodaJsonSettings
|
||||
{
|
||||
InstantConverter = new NodaPatternConverter<Instant>(InstantPattern.ExtendedIso),
|
||||
}
|
||||
);
|
||||
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.Enrich.FromLogContext()
|
||||
.MinimumLevel.Debug()
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
||||
.WriteTo.Console(theme: AnsiConsoleTheme.Sixteen)
|
||||
.CreateLogger();
|
||||
|
||||
var config = new ConfigurationBuilder().AddConfiguration().Build().Get<Config>();
|
||||
if (config == null)
|
||||
{
|
||||
Log.Fatal("No configuration object was created");
|
||||
return;
|
||||
}
|
||||
|
||||
var db = new DatabaseContext(config, null);
|
||||
await db.Database.MigrateAsync();
|
||||
|
||||
var type = args[0].ToLowerInvariant();
|
||||
var file = args[1];
|
||||
|
||||
if (type == "guilds")
|
||||
{
|
||||
Log.Information("Importing guilds from {File}", file);
|
||||
await GuildImport.DoImportAsync(db, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue