using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using JacobTechEncryption.Enums; using Luski.net.Enums.Public; namespace Luski.net.Structures.Public; public class SocketCategory { public PublicServer Server { get; init; } = default!; public long ID { get; init; } public Color Color { get; init; } internal long ParentID { get; set; } internal long[] RoleOverides { get; set; } internal long[] UserOverides { get; set; } internal long[] Channels { get; set; } internal long[] Categories { get; set; } SocketCategory? RawParent = null; List? RawRoleOverides = null; List? RawUserOverides = null; List? RawChan = null; List? RawCat = null; public async Task GetParent() { if (ParentID != -1 && RawParent is null) { RawParent = await Server.GetCategory(ParentID, CancellationToken.None); } return RawParent; } public async Task GetChannels() { if (RawChan is null) { RawChan = new(); foreach (long chan in Channels) { RawChan.Add(await Server.GetChannel(chan, CancellationToken.None)); } } if (RawChan.Count != Channels.Length) { foreach (long chan in Channels) { if (RawChan.Any(s => s.ID == chan)) continue; RawChan.Add(await Server.GetChannel(chan, CancellationToken.None)); } } return RawChan.ToArray(); } public async Task GetCategories() { if (RawCat is null) { RawCat = new(); foreach (long chan in Categories) { RawCat.Add(await Server.GetCategory(chan, CancellationToken.None)); } } if (RawCat.Count != Channels.Length) { foreach (long chan in Categories) { if (RawCat.Any(s => s.ID == chan)) continue; RawCat.Add(await Server.GetCategory(chan, CancellationToken.None)); } } return RawCat.ToArray(); } public string Name { get; internal set; } public string Description { get; internal set; } public Task GetRoleOverides() { if (RawRoleOverides is null) { RawRoleOverides = new(); } return Task.FromResult(RawRoleOverides!.ToArray()); } public Task GetUserOveride() { if (RawUserOverides is null) { RawUserOverides = new(); } return Task.FromResult(RawUserOverides!.ToArray()); } public long TitleEncryptionKey { get; internal set; } public long DescriptionEncryptionKey { get; internal set; } public EncoderType TitleEncoderType { get; internal set; } public EncoderType DescriptionEncoderType { get; internal set; } }