60 lines
No EOL
2.4 KiB
C#
60 lines
No EOL
2.4 KiB
C#
using System.ComponentModel.DataAnnotations.Schema;
|
|
using Catalogger.Backend.Extensions;
|
|
using Remora.Rest.Core;
|
|
|
|
namespace Catalogger.Backend.Database.Models;
|
|
|
|
public class Guild
|
|
{
|
|
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
|
public required ulong Id { get; init; }
|
|
|
|
[Column(TypeName = "jsonb")]
|
|
public ChannelConfig Channels { get; init; } = new();
|
|
public List<string> BannedSystems { get; init; } = [];
|
|
public List<ulong> KeyRoles { get; init; } = [];
|
|
|
|
public bool IsMessageIgnored(Snowflake channelId, Snowflake userId)
|
|
{
|
|
if (Channels is { MessageDelete: 0, MessageUpdate: 0, MessageDeleteBulk: 0 } ||
|
|
Channels.IgnoredChannels.Contains(channelId.ToUlong()) ||
|
|
Channels.IgnoredUsers.Contains(userId.ToUlong())) return true;
|
|
|
|
if (Channels.IgnoredUsersPerChannel.TryGetValue(channelId.ToUlong(),
|
|
out var thisChannelIgnoredUsers))
|
|
return thisChannelIgnoredUsers.Contains(userId.ToUlong());
|
|
|
|
return false;
|
|
}
|
|
|
|
public class ChannelConfig
|
|
{
|
|
public List<ulong> IgnoredChannels { get; init; } = [];
|
|
public List<ulong> IgnoredUsers { get; init; } = [];
|
|
public Dictionary<ulong, List<ulong>> IgnoredUsersPerChannel { get; init; } = [];
|
|
public Dictionary<ulong, ulong> Redirects { get; init; } = [];
|
|
|
|
public ulong GuildUpdate { get; init; }
|
|
public ulong GuildEmojisUpdate { get; init; }
|
|
public ulong GuildRoleCreate { get; init; }
|
|
public ulong GuildRoleUpdate { get; init; }
|
|
public ulong GuildRoleDelete { get; init; }
|
|
public ulong ChannelCreate { get; init; }
|
|
public ulong ChannelUpdate { get; init; }
|
|
public ulong ChannelDelete { get; init; }
|
|
public ulong GuildMemberAdd { get; init; }
|
|
public ulong GuildMemberUpdate { get; init; }
|
|
public ulong GuildKeyRoleUpdate { get; init; }
|
|
public ulong GuildMemberNickUpdate { get; init; }
|
|
public ulong GuildMemberAvatarUpdate { get; init; }
|
|
public ulong GuildMemberRemove { get; init; }
|
|
public ulong GuildMemberKick { get; init; }
|
|
public ulong GuildBanAdd { get; init; }
|
|
public ulong GuildBanRemove { get; init; }
|
|
public ulong InviteCreate { get; init; }
|
|
public ulong InviteDelete { get; init; }
|
|
public ulong MessageUpdate { get; init; }
|
|
public ulong MessageDelete { get; init; }
|
|
public ulong MessageDeleteBulk { get; init; }
|
|
}
|
|
} |