106 lines
3.1 KiB
C#
106 lines
3.1 KiB
C#
|
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<RoleOveride>? RawRoleOverides = null;
|
||
|
List<UserOveride>? RawUserOverides = null;
|
||
|
List<SocketChannel>? RawChan = null;
|
||
|
List<SocketCategory>? RawCat = null;
|
||
|
|
||
|
public async Task<SocketCategory?> GetParent()
|
||
|
{
|
||
|
if (ParentID != -1 && RawParent is null)
|
||
|
{
|
||
|
RawParent = await Server.GetCategory<SocketCategory>(ParentID, CancellationToken.None);
|
||
|
}
|
||
|
|
||
|
return RawParent;
|
||
|
}
|
||
|
|
||
|
public async Task<SocketChannel[]> GetChannels()
|
||
|
{
|
||
|
if (RawChan is null)
|
||
|
{
|
||
|
RawChan = new();
|
||
|
foreach (long chan in Channels)
|
||
|
{
|
||
|
RawChan.Add(await Server.GetChannel<SocketChannel>(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<SocketChannel>(chan, CancellationToken.None));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return RawChan.ToArray();
|
||
|
}
|
||
|
public async Task<SocketCategory[]> GetCategories()
|
||
|
{
|
||
|
if (RawCat is null)
|
||
|
{
|
||
|
RawCat = new();
|
||
|
foreach (long chan in Categories)
|
||
|
{
|
||
|
RawCat.Add(await Server.GetCategory<SocketCategory>(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<SocketCategory>(chan, CancellationToken.None));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return RawCat.ToArray();
|
||
|
}
|
||
|
public string Name { get; internal set; }
|
||
|
public string Description { get; internal set; }
|
||
|
|
||
|
public Task<RoleOveride[]> GetRoleOverides()
|
||
|
{
|
||
|
if (RawRoleOverides is null)
|
||
|
{
|
||
|
RawRoleOverides = new();
|
||
|
}
|
||
|
|
||
|
return Task.FromResult(RawRoleOverides!.ToArray());
|
||
|
}
|
||
|
public Task<UserOveride[]> 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; }
|
||
|
}
|