fix: fixed nullref in blacklist

This commit is contained in:
Kwoth
2024-11-17 19:14:40 +00:00
parent 1631394638
commit 80a41c1f38
3 changed files with 4 additions and 28 deletions

View File

@@ -1,22 +0,0 @@
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Db.Models;
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 IReadOnlyCollection<SelfAssignedRole> GetFromGuild(this DbSet<SelfAssignedRole> roles, ulong guildId)
=> roles.AsQueryable().Where(s => s.GuildId == guildId).ToArray();
}

View File

@@ -5,7 +5,7 @@ namespace NadekoBot.Modules.Searches.Common.StreamNotifications.Providers;
/// <summary>
/// Abstract class implemented by providers of all supported platforms
/// </summary>
public abstract class Provider
public abstract class StreamProvider
{
/// <summary>
/// Type of the platform.

View File

@@ -1,4 +1,3 @@
#nullable disable
using LinqToDB;
using LinqToDB.Data;
using LinqToDB.EntityFrameworkCore;
@@ -53,8 +52,7 @@ public sealed class BlacklistService : IExecOnMessage, IReadyExecutor
private ValueTask OnReload(BlacklistEntry[] newBlacklist)
{
if (newBlacklist is null)
return default;
newBlacklist ??= [];
blacklistedGuilds =
new HashSet<ulong>(newBlacklist.Where(x => x.Type == BlacklistType.Server).Select(x => x.ItemId))
@@ -69,9 +67,9 @@ public sealed class BlacklistService : IExecOnMessage, IReadyExecutor
return default;
}
public Task<bool> ExecOnMessageAsync(IGuild guild, IUserMessage usrMsg)
public Task<bool> ExecOnMessageAsync(IGuild? guild, IUserMessage usrMsg)
{
if (blacklistedGuilds.Contains(guild.Id))
if (guild is not null && blacklistedGuilds.Contains(guild.Id))
{
Log.Information("Blocked input from blacklisted guild: {GuildName} [{GuildId}]",
guild.Name,