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 parent = guild.GetChannel(model.CategoryId.Value);
var entity = new SocketThreadChannel(guild.Discord, guild, model.Id, parent, model.ThreadMetadata.GetValueOrDefault()?.CreatedAt.GetValueOrDefault(null));
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;
return entity;
}
}
internal override void Update(ClientState state, Model model)
internal override void Update(ClientStateManager state, Model model)
{
{
base.Update(state, model);
base.Update(state, model);
@@ -171,7 +171,6 @@ namespace Discord.WebSocket
else
else
{
{
member = SocketThreadUser.Create(Guild, this, model, guildMember);
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>
/// <summary>
/// Gets the built-in role containing all users in this guild.
/// Gets the built-in role containing all users in this guild.
/// </summary>
/// </summary>
@@ -324,7 +324,7 @@ namespace Discord.WebSocket
get
get
{
{
var channels = _channels;
var channels = _channels;
var state = Discord.State;
var state = Discord.StateManager;
return channels.Select(x => x.Value).Where(x => x != null).ToReadOnlyCollection(channels);
return channels.Select(x => x.Value).Where(x => x != null).ToReadOnlyCollection(channels);
}
}
}
}
@@ -356,7 +356,7 @@ namespace Discord.WebSocket
/// <returns>
/// <returns>
/// A collection of guild users found within this guild.
/// A collection of guild users found within this guild.
/// </returns>
/// </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>();
_events = new ConcurrentDictionary<ulong, SocketGuildEvent>();
if (_channels == null)
if (_channels == null)
_channels = new ConcurrentDictionary<ulong, SocketGuildChannel>();
_channels = new ConcurrentDictionary<ulong, SocketGuildChannel>();
if (_members == null)
_members = new ConcurrentDictionary<ulong, SocketGuildUser>();
if (_roles == null)
if (_roles == null)
_roles = new ConcurrentDictionary<ulong, SocketRole>();
_roles = new ConcurrentDictionary<ulong, SocketRole>();
/*if (Emojis == null)
/*if (Emojis == null)
@@ -431,25 +429,6 @@ namespace Discord.WebSocket
_channels = channels;
_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));
var voiceStates = new ConcurrentDictionary<ulong, SocketVoiceState>(ConcurrentHashSet.DefaultConcurrencyLevel, (int)(model.VoiceStates.Length * 1.05));
{
{
for (int i = 0; i < model.VoiceStates.Length; i++)
for (int i = 0; i < model.VoiceStates.Length; i++)
@@ -473,6 +452,10 @@ namespace Discord.WebSocket
}
}
_events = events;
_events = events;
DownloadedMemberCount = model.Members.Length;
MemberCount = model.MemberCount;
_syncPromise = new TaskCompletionSource<bool>();
_syncPromise = new TaskCompletionSource<bool>();
_downloaderPromise = new TaskCompletionSource<bool>();
_downloaderPromise = new TaskCompletionSource<bool>();
@@ -480,7 +463,7 @@ namespace Discord.WebSocket
/*if (!model.Large)
/*if (!model.Large)
_ = _downloaderPromise.TrySetResultAsync(true);*/
_ = _downloaderPromise.TrySetResultAsync(true);*/
}
}
internal void Update(ClientState state, Model model)
internal void Update(ClientStateManager state, Model model)
{
{
AFKChannelId = model.AFKChannelId;
AFKChannelId = model.AFKChannelId;
if (model.WidgetChannelId.IsSpecified)
if (model.WidgetChannelId.IsSpecified)
@@ -561,31 +544,18 @@ namespace Discord.WebSocket
else
else
_stickers = new ConcurrentDictionary<ulong, SocketCustomSticker>(ConcurrentHashSet.DefaultConcurrencyLevel, 7);
_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.