1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-20 00:43:36 +03:00

Resolve build errors

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-06-08 22:32:13 +05:00
parent 4c31ebf826
commit 26d7777577
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
5 changed files with 21 additions and 12 deletions

View file

@ -29,5 +29,5 @@ jobs:
uses: muno92/resharper_inspectcode@1.6.13
with:
solutionPath: ./Boyfriend.sln
ignoreIssueType: InvertIf
ignoreIssueType: InvertIf,ConvertIfStatementToReturnStatement
solutionWideAnalysis: true

View file

@ -1,15 +1,18 @@
using System.Drawing;
// ReSharper disable UnusedMember.Global
// TODO: remove this when all colors are used
namespace Boyfriend;
public static class ColorsList {
public static readonly Color Default = Color.Gray;
public static readonly Color Red = Color.Firebrick;
public static readonly Color Green = Color.PaleGreen;
public static readonly Color Yellow = Color.Gold;
public static readonly Color Blue = Color.RoyalBlue;
public static readonly Color Magneta = Color.Orchid;
public static readonly Color Cyan = Color.LightSkyBlue;
public static readonly Color Black = Color.Black;
public static readonly Color White = Color.WhiteSmoke;
public static readonly Color Red = Color.Firebrick;
public static readonly Color Green = Color.PaleGreen;
public static readonly Color Yellow = Color.Gold;
public static readonly Color Blue = Color.RoyalBlue;
public static readonly Color Magenta = Color.Orchid;
public static readonly Color Cyan = Color.LightSkyBlue;
public static readonly Color Black = Color.Black;
public static readonly Color White = Color.WhiteSmoke;
}

View file

@ -13,6 +13,9 @@ using Remora.Discord.Commands.Feedback.Services;
using Remora.Discord.Extensions.Embeds;
using Remora.Results;
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable UnusedMember.Global
namespace Boyfriend.Commands;
public class BanCommand : CommandGroup {

View file

@ -89,6 +89,7 @@ public static class Extensions {
public static TResult? MaxOrDefault<TSource, TResult>(
this IEnumerable<TSource> source, Func<TSource, TResult> selector) {
return source.Any() ? source.Max(selector) : default;
var list = source.ToList();
return list.Any() ? list.Max(selector) : default;
}
}

View file

@ -62,8 +62,10 @@ public class UtilityService : IHostedService {
var interacterRoles = roles.Where(r => interacter.Roles.Contains(r.ID));
var botRoles = roles.Where(r => currentMember.Roles.Contains(r.ID));
var targetBotRoleDiff = targetRoles.MaxOrDefault(r => r.Position) - botRoles.Max(r => r.Position);
var targetInteracterRoleDiff = targetRoles.MaxOrDefault(r => r.Position) - interacterRoles.Max(r => r.Position);
var targetRolesList = targetRoles.ToList();
var targetBotRoleDiff = targetRolesList.MaxOrDefault(r => r.Position) - botRoles.Max(r => r.Position);
var targetInteracterRoleDiff
= targetRolesList.MaxOrDefault(r => r.Position) - interacterRoles.Max(r => r.Position);
if (targetInteracterRoleDiff >= 0)
return Result<string?>.FromSuccess($"UserCannot{action}Target".Localized());