mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
refactor(bot): remove saving own user ID from ready event, rely on ID in config
This commit is contained in:
parent
aeb6411b6c
commit
9303dbb91e
17 changed files with 51 additions and 69 deletions
|
|
@ -11,7 +11,12 @@ public class MemoryDiscordCache: IDiscordCache
|
|||
private readonly ConcurrentDictionary<ulong, CachedGuild> _guilds = new();
|
||||
private readonly ConcurrentDictionary<ulong, Role> _roles = new();
|
||||
private readonly ConcurrentDictionary<ulong, User> _users = new();
|
||||
private ulong? _ownUserId { get; set; }
|
||||
private readonly ulong _ownUserId;
|
||||
|
||||
public MemoryDiscordCache(ulong ownUserId)
|
||||
{
|
||||
_ownUserId = ownUserId;
|
||||
}
|
||||
|
||||
public ValueTask SaveGuild(Guild guild)
|
||||
{
|
||||
|
|
@ -48,15 +53,6 @@ public class MemoryDiscordCache: IDiscordCache
|
|||
await SaveUser(recipient);
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
@ -127,7 +123,7 @@ public class MemoryDiscordCache: IDiscordCache
|
|||
return default;
|
||||
}
|
||||
|
||||
public Task<ulong> GetOwnUser() => Task.FromResult(_ownUserId!.Value);
|
||||
public ulong GetOwnUser() => _ownUserId;
|
||||
|
||||
public ValueTask RemoveRole(ulong guildId, ulong roleId)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue