mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
refactor: cache own user ID in IDiscordCache
- remove Cluster.User - remove Cluster.Application (it was only being used as an alternative to Cluster.User for some reason) - move Bot.PermissionsIn to DiscordCacheExtensions
This commit is contained in:
parent
24ac0725af
commit
7a5ba8246e
17 changed files with 61 additions and 40 deletions
|
|
@ -16,6 +16,7 @@ namespace Myriad.Cache
|
|||
private readonly ConcurrentDictionary<ulong, Role> _roles = new();
|
||||
private readonly ConcurrentDictionary<ulong, User> _users = new();
|
||||
private readonly ConcurrentDictionary<ulong, GuildMemberPartial> _guildMembers = new();
|
||||
private ulong? _ownUserId { get; set; }
|
||||
|
||||
public ValueTask SaveGuild(Guild guild)
|
||||
{
|
||||
|
|
@ -46,6 +47,15 @@ namespace Myriad.Cache
|
|||
}
|
||||
}
|
||||
|
||||
public ValueTask SaveOwnUser(ulong userId)
|
||||
{
|
||||
// this (hopefully) never changes at runtime, so we skip out on re-assigning it
|
||||
if (_ownUserId == null)
|
||||
_ownUserId = userId;
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
public ValueTask SaveUser(User user)
|
||||
{
|
||||
_users[user.Id] = user;
|
||||
|
|
@ -125,6 +135,8 @@ namespace Myriad.Cache
|
|||
return default;
|
||||
}
|
||||
|
||||
public Task<ulong> GetOwnUser() => Task.FromResult(_ownUserId!.Value);
|
||||
|
||||
public ValueTask RemoveRole(ulong guildId, ulong roleId)
|
||||
{
|
||||
_roles.TryRemove(roleId, out _);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue