re-added a missing extension method

This commit is contained in:
Toastie 2024-11-18 17:21:00 +13:00
parent 2d806119b4
commit 4af3a9086f
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4

View file

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore;
using EllieBot.Db.Models;
namespace EllieBot.Db;
public static class SelfAssignableRolesExtensions
{
public static bool DeleteByGuildAndRoleId(this DbSet<SelfAssignedRole> roles, ulong guildId, ulong roleId)
{
var role = roles.FirstOrDefault(s => s.GuildId == guildId && s.RoleId == roleId);
if (role is null)
return false;
roles.Remove(role);
return true;
}
public static IReadOnlyCollection<SelfAssignedRole> GetFromGuild(
this DbSet<SelfAssignedRole> roles,
ulong guildId)
=> roles.AsQueryable().Where(s => s.GuildId == guildId).ToArray();
}