mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
- Some renamings and code cleanups - Chained method calls, binary expressions and binary patterns will now break into newlines - Type param constraints and base constructor calls will be on the new line
23 lines
691 B
C#
23 lines
691 B
C#
using NadekoBot.Services.Database.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace NadekoBot.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 IEnumerable<SelfAssignedRole> GetFromGuild(this DbSet<SelfAssignedRole> roles, ulong guildId)
|
|
=> roles.AsQueryable()
|
|
.Where(s => s.GuildId == guildId)
|
|
.ToArray();
|
|
} |