re-added a missing extension method
This commit is contained in:
parent
2d806119b4
commit
4af3a9086f
1 changed files with 23 additions and 0 deletions
|
@ -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();
|
||||||
|
}
|
Loading…
Reference in a new issue