Skip to content

Commit

Permalink
Let EF Core do the configs, dependency updates and minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Plerx2493 committed Apr 7, 2024
1 parent 2e18bba commit 97f3951
Show file tree
Hide file tree
Showing 23 changed files with 1,093 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using DSharpPlus.Entities;
using DSharpPlus.SlashCommands;
using Humanizer;
using Humanizer.Localisation;
using MADS.Entities;
using MADS.Extensions;
using Microsoft.EntityFrameworkCore;
Expand Down
1 change: 0 additions & 1 deletion ModularAssistentForDiscordServer/Commands/Slash/Ping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using DSharpPlus.Entities;
using DSharpPlus.SlashCommands;
using Humanizer;
using Humanizer.Localisation;
using MADS.Extensions;

namespace MADS.Commands.Slash;
Expand Down
6 changes: 3 additions & 3 deletions ModularAssistentForDiscordServer/Commands/Slash/Reminder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace MADS.Commands.Slash;
[SlashCommandGroup("reminder", "mangage reminders")]
public sealed class Reminder : MadsBaseApplicationCommand
{
private ReminderService _reminderService;
private readonly ReminderService _reminderService;

public Reminder(ReminderService reminderService)
{
Expand Down Expand Up @@ -63,9 +63,9 @@ public async Task AddReminder
IsPrivate = isPrivate
};

await _reminderService.AddReminder(newReminder);
ReminderDbEntity reminder = await _reminderService.AddReminder(newReminder);

await EditResponse_Success($"Reminder created. I will remind you in {Formatter.Timestamp(timeSpan.Value)}");
await EditResponse_Success($"Reminder created with id {reminder.Id}. I will remind you in {Formatter.Timestamp(timeSpan.Value)}");
}

[SlashCommand("list", "list your Reminder")]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,20 @@
using MADS.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace MADS.EventListeners;

internal static partial class EventListener
{
public static void GuildDownload(DiscordClient client)
=> client.GuildDownloadCompleted += async (_, args) => { await UpdateDb(args); };

private static async Task UpdateDb( GuildDownloadCompletedEventArgs args)
public static async Task UpdateDb(DiscordClient client, GuildDownloadCompletedEventArgs args)
{
IDbContextFactory<MadsContext> dbFactory = ModularDiscordBot.Services.GetRequiredService<IDbContextFactory<MadsContext>>();
Task updateGuilds = UpdateGuilds(args, dbFactory);
Task updateUsers = UpdateUsersDb(args, dbFactory);

await Task.WhenAll(updateGuilds, updateUsers);
client.Logger.LogInformation("Database updated!");
}

private static async Task UpdateUsersDb
Expand Down
Loading

0 comments on commit 97f3951

Please sign in to comment.