mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-03 20:49:54 +03:00
Add support for temporary bans
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
e883e143eb
commit
9c080d9691
10 changed files with 144 additions and 31 deletions
|
@ -83,5 +83,7 @@ public class GuildConfiguration {
|
|||
/// </summary>
|
||||
public TimeSpan EventEarlyNotificationOffset { get; set; } = TimeSpan.Zero;
|
||||
|
||||
public CultureInfo Culture => CultureInfoCache[Language];
|
||||
public CultureInfo GetCulture() {
|
||||
return CultureInfoCache[Language];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Globalization;
|
||||
using Remora.Rest.Core;
|
||||
|
||||
namespace Boyfriend.Data;
|
||||
|
||||
|
@ -10,17 +11,31 @@ public class GuildData {
|
|||
public readonly GuildConfiguration Configuration;
|
||||
public readonly string ConfigurationPath;
|
||||
|
||||
public readonly Dictionary<ulong, MemberData> MemberData;
|
||||
public readonly string MemberDataPath;
|
||||
|
||||
public readonly Dictionary<ulong, ScheduledEventData> ScheduledEvents;
|
||||
public readonly string ScheduledEventsPath;
|
||||
|
||||
public GuildData(
|
||||
GuildConfiguration configuration, string configurationPath,
|
||||
Dictionary<ulong, ScheduledEventData> scheduledEvents, string scheduledEventsPath) {
|
||||
Dictionary<ulong, ScheduledEventData> scheduledEvents, string scheduledEventsPath,
|
||||
Dictionary<ulong, MemberData> memberData, string memberDataPath) {
|
||||
Configuration = configuration;
|
||||
ConfigurationPath = configurationPath;
|
||||
ScheduledEvents = scheduledEvents;
|
||||
ScheduledEventsPath = scheduledEventsPath;
|
||||
MemberData = memberData;
|
||||
MemberDataPath = memberDataPath;
|
||||
}
|
||||
|
||||
public CultureInfo Culture => Configuration.Culture;
|
||||
public CultureInfo Culture => Configuration.GetCulture();
|
||||
|
||||
public MemberData GetMemberData(Snowflake userId) {
|
||||
if (MemberData.TryGetValue(userId.Value, out var existing)) return existing;
|
||||
|
||||
var newData = new MemberData(userId.Value, null);
|
||||
MemberData.Add(userId.Value, newData);
|
||||
return newData;
|
||||
}
|
||||
}
|
||||
|
|
11
Data/MemberData.cs
Normal file
11
Data/MemberData.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
namespace Boyfriend.Data;
|
||||
|
||||
public class MemberData {
|
||||
public MemberData(ulong id, DateTimeOffset? bannedUntil) {
|
||||
Id = id;
|
||||
BannedUntil = bannedUntil;
|
||||
}
|
||||
|
||||
public ulong Id { get; }
|
||||
public DateTimeOffset? BannedUntil { get; set; }
|
||||
}
|
|
@ -7,10 +7,10 @@ namespace Boyfriend.Data;
|
|||
/// </summary>
|
||||
/// <remarks>This information is stored on disk as a JSON file.</remarks>
|
||||
public class ScheduledEventData {
|
||||
public DateTimeOffset? ActualStartTime;
|
||||
public GuildScheduledEventStatus Status;
|
||||
|
||||
public ScheduledEventData(GuildScheduledEventStatus status) {
|
||||
Status = status;
|
||||
}
|
||||
|
||||
public DateTimeOffset? ActualStartTime { get; set; }
|
||||
public GuildScheduledEventStatus Status { get; set; }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue