mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 00:19:00 +03:00
Octol1ttle
793afd0e06
1. The root namespace was changed from `Octobot` to `TeamOctolings.Octobot`: > DO prefix namespace names with a company name to prevent namespaces from different companies from having the same name. 2. `Octobot.cs` was renamed to `Program.cs`: > DO NOT use the same name for a namespace and a type in that namespace. 3. `IOption`, `Option` were renamed to `IGuildOption` and `GuildOption` respectively: > DO NOT introduce generic type names such as Element, Node, Log, and Message. 4. `Utility` was moved out of the `Services` namespace. It didn't belong there anyway 5. `Program` static fields were moved to `Utility` 6. Localisation files were moved back to the project source files. Looks like this fixed `Message.Designer.cs` code generation --------- Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using System.Text.Json.Nodes;
|
|
using Remora.Rest.Core;
|
|
|
|
namespace TeamOctolings.Octobot.Data;
|
|
|
|
/// <summary>
|
|
/// Stores information about a guild. This information is not accessible via the Discord API.
|
|
/// </summary>
|
|
/// <remarks>This information is stored on disk as a JSON file.</remarks>
|
|
public sealed class GuildData
|
|
{
|
|
public readonly Dictionary<ulong, MemberData> MemberData;
|
|
public readonly string MemberDataPath;
|
|
|
|
public readonly Dictionary<ulong, ScheduledEventData> ScheduledEvents;
|
|
public readonly string ScheduledEventsPath;
|
|
public readonly JsonNode Settings;
|
|
public readonly string SettingsPath;
|
|
|
|
public readonly bool DataLoadFailed;
|
|
|
|
public GuildData(
|
|
JsonNode settings, string settingsPath,
|
|
Dictionary<ulong, ScheduledEventData> scheduledEvents, string scheduledEventsPath,
|
|
Dictionary<ulong, MemberData> memberData, string memberDataPath, bool dataLoadFailed)
|
|
{
|
|
Settings = settings;
|
|
SettingsPath = settingsPath;
|
|
ScheduledEvents = scheduledEvents;
|
|
ScheduledEventsPath = scheduledEventsPath;
|
|
MemberData = memberData;
|
|
MemberDataPath = memberDataPath;
|
|
DataLoadFailed = dataLoadFailed;
|
|
}
|
|
|
|
public MemberData GetOrCreateMemberData(Snowflake memberId)
|
|
{
|
|
if (MemberData.TryGetValue(memberId.Value, out var existing))
|
|
{
|
|
return existing;
|
|
}
|
|
|
|
var newData = new MemberData(memberId.Value);
|
|
MemberData.Add(memberId.Value, newData);
|
|
return newData;
|
|
}
|
|
}
|