1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 09:09:00 +03:00
Octobot/src/Data/GuildData.cs
Macintosh II 804bcd6e68
Rebrand to Octobot (#128)
We're moving!

---------

Signed-off-by: Macintosh II <mctaylxrs@outlook.com>
Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com>
Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-09-30 18:58:32 +05:00

44 lines
1.4 KiB
C#

using System.Text.Json.Nodes;
using Remora.Rest.Core;
namespace 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 GuildData(
JsonNode settings, string settingsPath,
Dictionary<ulong, ScheduledEventData> scheduledEvents, string scheduledEventsPath,
Dictionary<ulong, MemberData> memberData, string memberDataPath)
{
Settings = settings;
SettingsPath = settingsPath;
ScheduledEvents = scheduledEvents;
ScheduledEventsPath = scheduledEventsPath;
MemberData = memberData;
MemberDataPath = memberDataPath;
}
public MemberData GetOrCreateMemberData(Snowflake userId)
{
if (MemberData.TryGetValue(userId.Value, out var existing))
{
return existing;
}
var newData = new MemberData(userId.Value);
MemberData.Add(userId.Value, newData);
return newData;
}
}