internal new static SocketThreadChannel Create(SocketGuild guild, ClientState state, Model model)
internal new static SocketThreadChannel Create(SocketGuild guild, ClientStateManager state, Model model)
{
var parent = guild.GetChannel(model.CategoryId.Value);
var entity = new SocketThreadChannel(guild.Discord, guild, model.Id, parent, model.ThreadMetadata.GetValueOrDefault()?.CreatedAt.GetValueOrDefault(null));
@@ -126,7 +126,7 @@ namespace Discord.WebSocket
return entity;
}
internal override void Update(ClientState state, Model model)
internal override void Update(ClientStateManager state, Model model)
{
base.Update(state, model);
@@ -171,7 +171,6 @@ namespace Discord.WebSocket
else
{
member = SocketThreadUser.Create(Guild, this, model, guildMember);
public SocketGuildUser CurrentUser => _members.TryGetValue(Discord.CurrentUser.Id, out SocketGuildUser member) ? member : null;
public SocketGuildUser CurrentUser => Discord.StateManager.TryGetMemberStore(Id, out var store) ? store.Get(Discord.CurrentUser.Id) : null;
/// <summary>
/// Gets the built-in role containing all users in this guild.
/// </summary>
@@ -324,7 +324,7 @@ namespace Discord.WebSocket
get
{
var channels = _channels;
var state = Discord.State;
var state = Discord.StateManager;
return channels.Select(x => x.Value).Where(x => x != null).ToReadOnlyCollection(channels);
}
}
@@ -356,7 +356,7 @@ namespace Discord.WebSocket
/// <returns>
/// A collection of guild users found within this guild.
/// </returns>
public IReadOnlyCollection<SocketGuildUser> Users => _members.ToReadOnlyCollection();
public IReadOnlyCollection<SocketGuildUser> Users => Discord.StateManager.TryGetMemberStore(Id, out var store) ? store.GetAll().ToImmutableArray() : ImmutableArray<SocketGuildUser>.Empty;
_events = new ConcurrentDictionary<ulong, SocketGuildEvent>();
if (_channels == null)
_channels = new ConcurrentDictionary<ulong, SocketGuildChannel>();
if (_members == null)
_members = new ConcurrentDictionary<ulong, SocketGuildUser>();
if (_roles == null)
_roles = new ConcurrentDictionary<ulong, SocketRole>();
/*if (Emojis == null)
@@ -431,25 +429,6 @@ namespace Discord.WebSocket
_channels = channels;
var members = new ConcurrentDictionary<ulong, SocketGuildUser>(ConcurrentHashSet.DefaultConcurrencyLevel, (int)(model.Members.Length * 1.05));
{
for (int i = 0; i < model.Members.Length; i++)
{
var member = SocketGuildUser.Create(this, state, model.Members[i]);
if (members.TryAdd(member.Id, member))
member.GlobalUser.AddRef();
}
DownloadedMemberCount = members.Count;
for (int i = 0; i < model.Presences.Length; i++)
{
if (members.TryGetValue(model.Presences[i].User.Id, out SocketGuildUser member))
member.Update(state, model.Presences[i], true);
}
}
_members = members;
MemberCount = model.MemberCount;
var voiceStates = new ConcurrentDictionary<ulong, SocketVoiceState>(ConcurrentHashSet.DefaultConcurrencyLevel, (int)(model.VoiceStates.Length * 1.05));
{
for (int i = 0; i < model.VoiceStates.Length; i++)
@@ -473,6 +452,10 @@ namespace Discord.WebSocket
}
_events = events;
DownloadedMemberCount = model.Members.Length;
MemberCount = model.MemberCount;
_syncPromise = new TaskCompletionSource<bool>();
_downloaderPromise = new TaskCompletionSource<bool>();
@@ -480,7 +463,7 @@ namespace Discord.WebSocket
/*if (!model.Large)
_ = _downloaderPromise.TrySetResultAsync(true);*/
}
internal void Update(ClientState state, Model model)
internal void Update(ClientStateManager state, Model model)
{
AFKChannelId = model.AFKChannelId;
if (model.WidgetChannelId.IsSpecified)
@@ -561,31 +544,18 @@ namespace Discord.WebSocket
else
_stickers = new ConcurrentDictionary<ulong, SocketCustomSticker>(ConcurrentHashSet.DefaultConcurrencyLevel, 7);
}
/*internal void Update(ClientState state, GuildSyncModel model) //TODO remove? userbot related
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.