Move Data extensions to a more suitable area

This commit is contained in:
Noi 2022-02-24 20:26:30 -08:00
parent a01b1113f9
commit 7abe03b70d
2 changed files with 21 additions and 17 deletions

View file

@ -136,20 +136,3 @@ public abstract class BotModuleBase : InteractionModuleBase<SocketInteractionCon
protected static string FormatDate(int month, int day) => $"{day:00}-{Common.MonthNames[month]}";
#endregion
}
internal static class Extensions {
/// <summary>
/// Retrieves the database-backed guild configuration for the executing guild.
/// </summary>
internal static async Task<GuildConfiguration> GetGuildConfAsync(this SocketInteractionContext context)
#pragma warning disable CS8603 // Possible null reference return.
=> await GuildConfiguration.LoadAsync(context.Guild.Id, false);
#pragma warning restore CS8603 // Possible null reference return.
/// <summary>
/// Retrieves the database-backed guild user configuration for the executing user.
/// </summary>
internal static async Task<GuildUserConfiguration> GetGuildUserConfAsync(this SocketInteractionContext context)
=> await GuildUserConfiguration.LoadAsync(context.Guild.Id, context.User.Id);
}

21
Data/Extensions.cs Normal file
View file

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BirthdayBot.Data;
internal static class Extensions {
/// <summary>
/// Retrieves the database-backed guild configuration for the executing guild.
/// </summary>
internal static async Task<GuildConfiguration> GetConfigAsync(this SocketGuild guild)
=> await GuildConfiguration.LoadAsync(guild.Id, false);
/// <summary>
/// Retrieves the database-backed guild user configuration for this user.
/// </summary>
internal static async Task<GuildUserConfiguration> GetConfigAsync(this SocketGuildUser user)
=> await GuildUserConfiguration.LoadAsync(user.Guild.Id, user.Id);
}