Backfill member data when a guild is loaded or a new member joins it (#77)

This PR backfills member data when a guild is loaded or a new member
joins it. The reason for that is some actions that happen on member tick
(default role grant, nickname filtering) would only occur if a member
had data related to them (due to being banned or setting a reminder). In
addition, the `.editorconfig` was updated with new inspections provided
by a new release of Rider, 2023.2
See explanations for some changes in comments.

---------

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-08-04 18:52:54 +05:00 committed by GitHub
parent d023033ed4
commit e9f7825e4a
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 61 additions and 35 deletions

View file

@ -30,14 +30,14 @@ public sealed class GuildData
MemberDataPath = memberDataPath;
}
public MemberData GetMemberData(Snowflake userId)
public MemberData GetOrCreateMemberData(Snowflake userId)
{
if (MemberData.TryGetValue(userId.Value, out var existing))
{
return existing;
}
var newData = new MemberData(userId.Value, null);
var newData = new MemberData(userId.Value);
MemberData.Add(userId.Value, newData);
return newData;
}

View file

@ -5,7 +5,7 @@ namespace Boyfriend.Data;
/// </summary>
public sealed class MemberData
{
public MemberData(ulong id, DateTimeOffset? bannedUntil)
public MemberData(ulong id, DateTimeOffset? bannedUntil = null)
{
Id = id;
BannedUntil = bannedUntil;