Redirected SocketClient's GetGuildEmbed, GetGuilds and GetVoiceRegions to the cache.
This commit is contained in:
@@ -279,6 +279,18 @@ namespace Discord
|
|||||||
{
|
{
|
||||||
return Task.FromResult<IGuild>(DataStore.GetGuild(id));
|
return Task.FromResult<IGuild>(DataStore.GetGuild(id));
|
||||||
}
|
}
|
||||||
|
public override Task<GuildEmbed?> GetGuildEmbedAsync(ulong id)
|
||||||
|
{
|
||||||
|
var guild = DataStore.GetGuild(id);
|
||||||
|
if (guild != null)
|
||||||
|
return Task.FromResult<GuildEmbed?>(new GuildEmbed(guild.IsEmbeddable, guild.EmbedChannelId));
|
||||||
|
else
|
||||||
|
return Task.FromResult<GuildEmbed?>(null);
|
||||||
|
}
|
||||||
|
public override Task<IReadOnlyCollection<IUserGuild>> GetGuildsAsync()
|
||||||
|
{
|
||||||
|
return Task.FromResult<IReadOnlyCollection<IUserGuild>>(Guilds);
|
||||||
|
}
|
||||||
internal CachedGuild AddGuild(API.Gateway.ExtendedGuild model, DataStore dataStore)
|
internal CachedGuild AddGuild(API.Gateway.ExtendedGuild model, DataStore dataStore)
|
||||||
{
|
{
|
||||||
var guild = new CachedGuild(this, model, dataStore);
|
var guild = new CachedGuild(this, model, dataStore);
|
||||||
@@ -385,6 +397,11 @@ namespace Discord
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Task<IReadOnlyCollection<IVoiceRegion>> GetVoiceRegionsAsync()
|
||||||
|
{
|
||||||
|
return Task.FromResult<IReadOnlyCollection<IVoiceRegion>>(_voiceRegions.ToReadOnlyCollection());
|
||||||
|
}
|
||||||
|
|
||||||
private async Task ProcessMessageAsync(GatewayOpCode opCode, int? seq, string type, object payload)
|
private async Task ProcessMessageAsync(GatewayOpCode opCode, int? seq, string type, object payload)
|
||||||
{
|
{
|
||||||
#if BENCHMARK
|
#if BENCHMARK
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ using VoiceStateModel = Discord.API.VoiceState;
|
|||||||
|
|
||||||
namespace Discord
|
namespace Discord
|
||||||
{
|
{
|
||||||
internal class CachedGuild : Guild, ICachedEntity<ulong>
|
internal class CachedGuild : Guild, IUserGuild, ICachedEntity<ulong>
|
||||||
{
|
{
|
||||||
private TaskCompletionSource<bool> _downloaderPromise;
|
private TaskCompletionSource<bool> _downloaderPromise;
|
||||||
private ConcurrentHashSet<ulong> _channels;
|
private ConcurrentHashSet<ulong> _channels;
|
||||||
@@ -257,5 +257,8 @@ namespace Discord
|
|||||||
throw new InvalidOperationException($"Unknown channel type: {model.Type.Value}");
|
throw new InvalidOperationException($"Unknown channel type: {model.Type.Value}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IUserGuild.IsOwner => OwnerId == Discord.CurrentUser.Id;
|
||||||
|
GuildPermissions IUserGuild.Permissions => CurrentUser.GuildPermissions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace Discord
|
|||||||
{
|
{
|
||||||
internal class CachedPublicUser : User, ICachedUser
|
internal class CachedPublicUser : User, ICachedUser
|
||||||
{
|
{
|
||||||
|
//TODO: Fix removed game/status (add CachedDMUser?)
|
||||||
private int _references;
|
private int _references;
|
||||||
//private Game? _game;
|
//private Game? _game;
|
||||||
//private UserStatus _status;
|
//private UserStatus _status;
|
||||||
|
|||||||
Reference in New Issue
Block a user