mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 09:18:27 -04:00
fix: fixed nullref in blacklist
This commit is contained in:
@@ -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();
|
|
||||||
}
|
|
@@ -5,7 +5,7 @@ namespace NadekoBot.Modules.Searches.Common.StreamNotifications.Providers;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Abstract class implemented by providers of all supported platforms
|
/// Abstract class implemented by providers of all supported platforms
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class Provider
|
public abstract class StreamProvider
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Type of the platform.
|
/// Type of the platform.
|
@@ -1,4 +1,3 @@
|
|||||||
#nullable disable
|
|
||||||
using LinqToDB;
|
using LinqToDB;
|
||||||
using LinqToDB.Data;
|
using LinqToDB.Data;
|
||||||
using LinqToDB.EntityFrameworkCore;
|
using LinqToDB.EntityFrameworkCore;
|
||||||
@@ -53,8 +52,7 @@ public sealed class BlacklistService : IExecOnMessage, IReadyExecutor
|
|||||||
|
|
||||||
private ValueTask OnReload(BlacklistEntry[] newBlacklist)
|
private ValueTask OnReload(BlacklistEntry[] newBlacklist)
|
||||||
{
|
{
|
||||||
if (newBlacklist is null)
|
newBlacklist ??= [];
|
||||||
return default;
|
|
||||||
|
|
||||||
blacklistedGuilds =
|
blacklistedGuilds =
|
||||||
new HashSet<ulong>(newBlacklist.Where(x => x.Type == BlacklistType.Server).Select(x => x.ItemId))
|
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;
|
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}]",
|
Log.Information("Blocked input from blacklisted guild: {GuildName} [{GuildId}]",
|
||||||
guild.Name,
|
guild.Name,
|
||||||
|
Reference in New Issue
Block a user