NadekoBot.Extensions should now be fully annotated with nullable reference types as well as many classes from NadekoBot.Common

This commit is contained in:
Kwoth
2021-12-28 10:44:00 +01:00
parent 0634470a8a
commit 59f5056035
543 changed files with 1895 additions and 1448 deletions

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Common;
#nullable disable
using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Common.AnimalRacing;
using NadekoBot.Modules.Gambling.Services;
using NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions;
@@ -172,4 +173,4 @@ public partial class Gambling
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Common;
#nullable disable
using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Common.Blackjack;
using NadekoBot.Modules.Gambling.Services;
@@ -180,4 +181,4 @@ public partial class Gambling
await ctx.Message.DeleteAsync().ConfigureAwait(false);
}
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions;
#nullable disable
using NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions;
using NadekoBot.Modules.Games.Common;
namespace NadekoBot.Modules.Gambling.Common.AnimalRacing;
@@ -148,4 +149,4 @@ public sealed class AnimalRace : IDisposable
_locker.Dispose();
_users.Clear();
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Games.Common;
#nullable disable
using NadekoBot.Modules.Games.Common;
namespace NadekoBot.Modules.Gambling.Common.AnimalRacing;
@@ -24,4 +25,4 @@ public class AnimalRacingUser
public override int GetHashCode()
=> this.UserId.GetHashCode();
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions;
public class AlreadyJoinedException : Exception
{
@@ -14,4 +15,4 @@ public class AlreadyJoinedException : Exception
public AlreadyJoinedException(string message, Exception innerException) : base(message, innerException)
{
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions;
public class AlreadyStartedException : Exception
{
@@ -13,4 +14,4 @@ public class AlreadyStartedException : Exception
public AlreadyStartedException(string message, Exception innerException) : base(message, innerException)
{
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions;
public class AnimalRaceFullException : Exception
{
@@ -13,4 +14,4 @@ public class AnimalRaceFullException : Exception
public AnimalRaceFullException(string message, Exception innerException) : base(message, innerException)
{
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common.AnimalRacing.Exceptions;
public class NotEnoughFundsException : Exception
{
@@ -13,4 +14,4 @@ public class NotEnoughFundsException : Exception
public NotEnoughFundsException(string message, Exception innerException) : base(message, innerException)
{
}
}
}

View File

@@ -1,4 +1,5 @@
using CommandLine;
#nullable disable
using CommandLine;
namespace NadekoBot.Modules.Gambling.Common.AnimalRacing;
@@ -12,4 +13,4 @@ public class RaceOptions : INadekoCommandOptions
if (this.StartTime is < 10 or > 120)
this.StartTime = 20;
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common;
public class Betroll
{
@@ -40,4 +41,4 @@ public class Betroll
Threshold = pair.WhenAbove,
};
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common.Blackjack;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common.Blackjack;
public class Blackjack
{
@@ -339,4 +340,4 @@ public class Blackjack
return Task.CompletedTask;
return StateUpdated.Invoke(this);
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common.Blackjack;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common.Blackjack;
public abstract class Player
{
@@ -53,4 +54,4 @@ public class User : Player
public long Bet { get; set; }
public IUser DiscordUser { get; }
public bool Done => State != UserState.Waiting;
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common;
public class CurrencyRaffleGame
{
@@ -66,4 +67,4 @@ public class CurrencyRaffleGame
var usrs = _users.ToArray();
return usrs[rng.Next(0, usrs.Length)];
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common;
public class QuadDeck : Deck
{
@@ -299,4 +300,4 @@ public class Deck
}
return "High card " + (cards.FirstOrDefault(c => c.Number == 1)?.GetValueText() ?? cards.Max().GetValueText());
}
}
}

View File

@@ -1,4 +1,5 @@
using CommandLine;
#nullable disable
using CommandLine;
namespace NadekoBot.Modules.Gambling.Common.Events;
@@ -25,4 +26,4 @@ public class EventOptions : INadekoCommandOptions
if (PotSize != 0 && PotSize < Amount)
PotSize = 0;
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Services.Database.Models;
#nullable disable
using NadekoBot.Services.Database.Models;
namespace NadekoBot.Modules.Gambling.Common.Events;
@@ -191,4 +192,4 @@ public class GameStatusEvent : ICurrencyEvent
}
return true;
}
}
}

View File

@@ -1,8 +1,9 @@
namespace NadekoBot.Modules.Gambling.Common;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common;
public interface ICurrencyEvent
{
event Func<ulong, Task> OnEnded;
Task StopEvent();
Task StartEvent();
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Services.Database.Models;
#nullable disable
using NadekoBot.Services.Database.Models;
namespace NadekoBot.Modules.Gambling.Common.Events;
@@ -189,4 +190,4 @@ public class ReactionEvent : ICurrencyEvent
}
return true;
}
}
}

View File

@@ -1,4 +1,5 @@
using Cloneable;
#nullable disable
using Cloneable;
using NadekoBot.Common.Yml;
using SixLabors.ImageSharp.PixelFormats;
using YamlDotNet.Serialization;
@@ -308,4 +309,4 @@ public sealed partial class BetRollPair
{
public int WhenAbove { get; set; }
public float MultiplyBy { get; set; }
}
}

View File

@@ -1,7 +1,8 @@
#nullable disable
namespace NadekoBot.Modules.Gambling;
public enum GamblingError
{
None,
NotEnough
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Services;
#nullable disable
using NadekoBot.Modules.Gambling.Services;
namespace NadekoBot.Modules.Gambling.Common;
@@ -57,4 +58,4 @@ public abstract class GamblingSubmodule<TService> : GamblingModule<TService>
protected GamblingSubmodule(GamblingConfigService gamblingConfService) : base(gamblingConfService)
{
}
}
}

View File

@@ -1,7 +1,8 @@
namespace NadekoBot.Modules.Gambling.Common;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common;
public class Payout
{
public string User { get; set; }
public int Amount { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common;
public class RollDuelGame
{
@@ -129,4 +130,4 @@ public struct RollDuelChallenge
{
public ulong Player1 { get; set; }
public ulong Player2 { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common.Slot;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common.Slot;
public class SlotGame
{
@@ -36,4 +37,4 @@ public class SlotGame
return new(multi, rolls);
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling;
#nullable disable
namespace NadekoBot.Modules.Gambling;
public class SlotResponse
{
@@ -6,4 +7,4 @@ public class SlotResponse
public long Won { get; set; }
public List<int> Rolls { get; set; } = new();
public GamblingError Error { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common.Waifu;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common.Waifu;
public enum AffinityTitle
{
@@ -12,4 +13,4 @@ public enum AffinityTitle
Sloot,
Depraved,
Harlot
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common.Waifu;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common.Waifu;
public enum ClaimTitle
{
@@ -14,4 +15,4 @@ public enum ClaimTitle
Incubis,
Harem_King,
Harem_God,
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common.Waifu;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common.Waifu;
public enum DivorceResult
{
@@ -6,4 +7,4 @@ public enum DivorceResult
SucessWithPenalty,
NotYourWife,
Cooldown
}
}

View File

@@ -1,8 +1,9 @@
namespace NadekoBot.Modules.Gambling.Common.Waifu;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common.Waifu;
public enum WaifuClaimResult
{
Success,
NotEnoughFunds,
InsufficientAmount
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Common.WheelOfFortune;
#nullable disable
namespace NadekoBot.Modules.Gambling.Common.WheelOfFortune;
public class WheelOfFortuneGame
{
@@ -38,4 +39,4 @@ public class WheelOfFortuneGame
Amount = amount,
};
}
}
}

View File

@@ -1,4 +1,5 @@
using CommandLine;
#nullable disable
using CommandLine;
using System.Collections.Immutable;
namespace NadekoBot.Modules.Gambling.Common.Connect4;
@@ -388,4 +389,4 @@ public sealed class Connect4Game : IDisposable
[Option('b', "bet", Required = false, Default = 0, HelpText = "Amount you bet. Default 0.")]
public int Bet { get; set; } = 0;
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Common;
#nullable disable
using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Common.Connect4;
using NadekoBot.Modules.Gambling.Services;
using System.Text;
@@ -194,4 +195,4 @@ public partial class Gambling
return sb.ToString();
}
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Services;
#nullable disable
using NadekoBot.Modules.Gambling.Services;
using NadekoBot.Modules.Gambling.Common.Events;
using NadekoBot.Services.Database.Models;
using NadekoBot.Modules.Gambling.Common;
@@ -71,4 +72,4 @@ public partial class Gambling
potSizeStr));
}
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Services;
#nullable disable
using NadekoBot.Modules.Gambling.Services;
using NadekoBot.Modules.Gambling.Common;
namespace NadekoBot.Modules.Gambling;
@@ -49,4 +50,4 @@ public partial class Gambling
}
}
}
}
}

View File

@@ -1,3 +1,4 @@
#nullable disable
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using System.Text.RegularExpressions;
@@ -204,4 +205,4 @@ public partial class Gambling
return Image.Load(_images.Dice[num]);
}
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Common;
#nullable disable
using NadekoBot.Modules.Gambling.Common;
using Image = SixLabors.ImageSharp.Image;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
@@ -107,4 +108,4 @@ public partial class Gambling
await ReplyConfirmLocalizedAsync(strs.deck_reshuffled).ConfigureAwait(false);
}
}
}
}

View File

@@ -1,3 +1,4 @@
#nullable disable
using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Services;
using SixLabors.ImageSharp;
@@ -116,4 +117,4 @@ public partial class Gambling
.WithImageUrl(imageToSend.ToString())).ConfigureAwait(false);
}
}
}
}

View File

@@ -1,3 +1,4 @@
#nullable disable
using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Db.Models;
using NadekoBot.Modules.Gambling.Services;
@@ -124,7 +125,7 @@ public partial class Gambling : GamblingModule<GamblingService>
[RequireContext(ContextType.Guild)]
public async Task Raffle([Leftover] IRole role = null)
{
role = role ?? ctx.Guild.EveryoneRole;
role ??= ctx.Guild.EveryoneRole;
var members = (await role.GetMembersAsync().ConfigureAwait(false)).Where(u => u.Status != UserStatus.Offline);
var membersArray = members as IUser[] ?? members.ToArray();
@@ -140,7 +141,7 @@ public partial class Gambling : GamblingModule<GamblingService>
[RequireContext(ContextType.Guild)]
public async Task RaffleAny([Leftover] IRole role = null)
{
role = role ?? ctx.Guild.EveryoneRole;
role ??= ctx.Guild.EveryoneRole;
var members = await role.GetMembersAsync().ConfigureAwait(false);
var membersArray = members as IUser[] ?? members.ToArray();
@@ -207,7 +208,7 @@ public partial class Gambling : GamblingModule<GamblingService>
[Priority(1)]
public async Task Cash([Leftover] IUser user = null)
{
user = user ?? ctx.User;
user ??= ctx.User;
await ConfirmLocalizedAsync(strs.has(Format.Bold(user.ToString()), $"{GetCurrency(user.Id)}"));
}
@@ -659,4 +660,4 @@ public partial class Gambling : GamblingModule<GamblingService>
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
}
}
}

View File

@@ -1,3 +1,4 @@
#nullable disable
using NadekoBot.Modules.Administration.Services;
using NadekoBot.Modules.Gambling.Services;
using NadekoBot.Modules.Gambling.Common;
@@ -111,4 +112,4 @@ public partial class Gambling
}, enabledIn.Count(), 9);
}
}
}
}

View File

@@ -1,8 +1,9 @@
using NadekoBot.Modules.Gambling.Common.AnimalRacing;
#nullable disable
using NadekoBot.Modules.Gambling.Common.AnimalRacing;
namespace NadekoBot.Modules.Gambling.Services;
public class AnimalRaceService : INService
{
public ConcurrentDictionary<ulong, AnimalRace> AnimalRaces { get; } = new();
}
}

View File

@@ -1,8 +1,9 @@
using NadekoBot.Modules.Gambling.Common.Blackjack;
#nullable disable
using NadekoBot.Modules.Gambling.Common.Blackjack;
namespace NadekoBot.Modules.Gambling.Services;
public class BlackJackService : INService
{
public ConcurrentDictionary<ulong, Blackjack> Games { get; } = new();
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Common.Events;
#nullable disable
using NadekoBot.Modules.Gambling.Common.Events;
using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Services.Database.Models;
@@ -69,4 +70,4 @@ public class CurrencyEventsService : INService
_events.TryRemove(gid, out _);
return Task.CompletedTask;
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Common;
#nullable disable
using NadekoBot.Modules.Gambling.Common;
namespace NadekoBot.Modules.Gambling.Services;
@@ -77,4 +78,4 @@ public class CurrencyRaffleService : INService
_locker.Release();
}
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Common.Configs;
#nullable disable
using NadekoBot.Common.Configs;
using NadekoBot.Modules.Gambling.Common;
namespace NadekoBot.Modules.Gambling.Services;
@@ -75,4 +76,4 @@ public sealed class GamblingConfigService : ConfigServiceBase<GamblingConfig>
});
}
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Common;
#nullable disable
using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Common.Connect4;
using NadekoBot.Modules.Gambling.Common.WheelOfFortune;
using Newtonsoft.Json;
@@ -157,4 +158,4 @@ WHERE CurrencyAmount > {config.Decay.MinThreshold} AND UserId!={_client.CurrentU
public Task<WheelOfFortuneGame.Result> WheelOfFortuneSpinAsync(ulong userId, long bet)
=> new WheelOfFortuneGame(userId, bet, _gss.Data, _cs).SpinAsync();
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Gambling.Services;
#nullable disable
namespace NadekoBot.Modules.Gambling.Services;
public interface IShopService
{
@@ -37,4 +38,4 @@ public interface IShopService
/// <param name="toIndex">Destination index of the entry</param>
/// <returns>Whether swap was successful</returns>
Task<bool> MoveEntryAsync(ulong guildId, int fromIndex, int toIndex);
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Common.Collections;
using NadekoBot.Services.Database;
using NadekoBot.Services.Database.Models;
@@ -97,4 +98,4 @@ public class ShopService : IShopService, INService
await uow.SaveChangesAsync();
return true;
}
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
using SixLabors.Fonts;
using SixLabors.ImageSharp;
@@ -353,4 +354,4 @@ public class PlantPickService : INService
});
await uow.SaveChangesAsync();
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Text.Json;
#nullable disable
using System.Text.Json;
using System.Text.Json.Serialization;
using NadekoBot.Common.ModuleBehaviors;
@@ -110,4 +111,4 @@ public class VoteRewardService : INService, IReadyExecutor
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Common.Waifu;
#nullable disable
using NadekoBot.Modules.Gambling.Common.Waifu;
using NadekoBot.Services.Database.Models;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Db;
@@ -504,4 +505,4 @@ public class WaifuService : INService
.Select(x => new WaifuItemModel(x.ItemEmoji, (int)(x.Price * conf.Waifu.Multipliers.AllGiftPrices), x.Name, x.Negative))
.ToList();
}
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Common.Collections;
using NadekoBot.Modules.Gambling.Common;
using NadekoBot.Modules.Gambling.Services;
@@ -459,4 +460,4 @@ public partial class Gambling
return "";
}
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Text;
#nullable disable
using System.Text;
using NadekoBot.Db.Models;
using NadekoBot.Modules.Gambling.Services;
using NadekoBot.Modules.Gambling.Common;
@@ -252,4 +253,4 @@ public partial class Gambling
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
using Discord.Interactions;
#nullable disable
using Discord.Interactions;
namespace NadekoBot.Modules.Gambling;
@@ -7,4 +8,4 @@ public class TestGamblingService : InteractionModuleBase
[SlashCommand("test", "uwu")]
public async Task Test(string input1, int input2)
=> await RespondAsync("Bravo " + input1 + input2);
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Gambling.Common.Waifu;
#nullable disable
using NadekoBot.Modules.Gambling.Common.Waifu;
using NadekoBot.Modules.Gambling.Services;
using NadekoBot.Modules.Gambling.Common;
@@ -354,4 +355,4 @@ public partial class Gambling
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
using Wof = NadekoBot.Modules.Gambling.Common.WheelOfFortune.WheelOfFortuneGame;
#nullable disable
using Wof = NadekoBot.Modules.Gambling.Common.WheelOfFortune.WheelOfFortuneGame;
using NadekoBot.Modules.Gambling.Services;
using NadekoBot.Modules.Gambling.Common;
using System.Collections.Immutable;
@@ -54,4 +55,4 @@ public partial class Gambling
『{wofMultipliers[3]}』 『{wofMultipliers[4]}』 『{wofMultipliers[5]}』")).ConfigureAwait(false);
}
}
}
}