From d7fbf44d5325d6e3ea356a1cc0314f856b8ea9fa Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 17 Nov 2024 19:32:41 +0000 Subject: [PATCH] fix: re-added a missing extension method --- .../SelfAssignableRolesExtensions.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/NadekoBot/_common/Abstractions/Extensions/SelfAssignableRolesExtensions.cs diff --git a/src/NadekoBot/_common/Abstractions/Extensions/SelfAssignableRolesExtensions.cs b/src/NadekoBot/_common/Abstractions/Extensions/SelfAssignableRolesExtensions.cs new file mode 100644 index 000000000..c7ce54a8c --- /dev/null +++ b/src/NadekoBot/_common/Abstractions/Extensions/SelfAssignableRolesExtensions.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore; +using NadekoBot.Db.Models; + +namespace NadekoBot.Db; + +public static class SelfAssignableRolesExtensions +{ + public static bool DeleteByGuildAndRoleId(this DbSet 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 GetFromGuild( + this DbSet roles, + ulong guildId) + => roles.AsQueryable().Where(s => s.GuildId == guildId).ToArray(); +} \ No newline at end of file