mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
Round 2 of nullable checks
This commit is contained in:
@@ -220,7 +220,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
|
||||
|
||||
IOrderedDictionary validGamesToRedeemInBackground = Bot.ValidateGamesToRedeemInBackground(request.GamesToRedeemInBackground);
|
||||
|
||||
if ((validGamesToRedeemInBackground == null) || (validGamesToRedeemInBackground.Count == 0)) {
|
||||
if (validGamesToRedeemInBackground.Count == 0) {
|
||||
return BadRequest(new GenericResponse(false, string.Format(Strings.ErrorIsEmpty, nameof(validGamesToRedeemInBackground))));
|
||||
}
|
||||
|
||||
|
||||
@@ -57,16 +57,16 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
|
||||
return BadRequest(new GenericResponse(false, string.Format(Strings.ErrorIsInvalid, nameof(ASF.GlobalConfig.SteamOwnerID))));
|
||||
}
|
||||
|
||||
Bot? targetBot = Bot.Bots.OrderBy(bot => bot.Key, Bot.BotsComparer).Select(bot => bot.Value).FirstOrDefault();
|
||||
Bot? targetBot = Bot.Bots?.OrderBy(bot => bot.Key, Bot.BotsComparer).Select(bot => bot.Value).FirstOrDefault();
|
||||
|
||||
if (targetBot == null) {
|
||||
return BadRequest(new GenericResponse(false, Strings.ErrorNoBotsDefined));
|
||||
}
|
||||
|
||||
string command = request.Command!;
|
||||
string? commandPrefix = ASF.GlobalConfig?.CommandPrefix ?? GlobalConfig.DefaultCommandPrefix;
|
||||
string? commandPrefix = ASF.GlobalConfig != null ? ASF.GlobalConfig.CommandPrefix : GlobalConfig.DefaultCommandPrefix;
|
||||
|
||||
if (!string.IsNullOrEmpty(commandPrefix) && command.StartsWith(commandPrefix, StringComparison.Ordinal)) {
|
||||
if (!string.IsNullOrEmpty(commandPrefix) && command.StartsWith(commandPrefix!, StringComparison.Ordinal)) {
|
||||
command = command.Substring(commandPrefix!.Length);
|
||||
|
||||
if (string.IsNullOrEmpty(command)) {
|
||||
|
||||
@@ -87,11 +87,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
|
||||
underlyingType = enumType.GetUnifiedName();
|
||||
|
||||
foreach (object? value in Enum.GetValues(targetType)) {
|
||||
if (value == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
string? valueText = value.ToString();
|
||||
string? valueText = value?.ToString();
|
||||
|
||||
if (string.IsNullOrEmpty(valueText)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(valueText));
|
||||
@@ -105,7 +101,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
|
||||
continue;
|
||||
}
|
||||
|
||||
body[valueText] = valueObjText!;
|
||||
body[valueText!] = valueObjText!;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user