mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-04 00:34:26 -05:00 
			
		
		
		
	dev: Added argumentoutofrange static methods, no functional change
This commit is contained in:
		@@ -22,8 +22,7 @@ public static class WarningExtensions
 | 
			
		||||
        string mod,
 | 
			
		||||
        int index)
 | 
			
		||||
    {
 | 
			
		||||
        if (index < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(index));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(index);
 | 
			
		||||
 | 
			
		||||
        var warn = warnings.AsQueryable()
 | 
			
		||||
                           .Where(x => x.GuildId == guildId && x.UserId == userId)
 | 
			
		||||
 
 | 
			
		||||
@@ -69,8 +69,7 @@ public sealed class PlayingRotateService : INService, IReadyExecutor
 | 
			
		||||
 | 
			
		||||
    public async Task<string> RemovePlayingAsync(int index)
 | 
			
		||||
    {
 | 
			
		||||
        if (index < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(index));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(index);
 | 
			
		||||
 | 
			
		||||
        await using var uow = _db.GetDbContext();
 | 
			
		||||
        var toRemove = await uow.Set<RotatingPlayingStatus>().AsQueryable().AsNoTracking().Skip(index).FirstOrDefaultAsync();
 | 
			
		||||
 
 | 
			
		||||
@@ -22,8 +22,7 @@ public class PruneService : INService
 | 
			
		||||
        ArgumentNullException.ThrowIfNull(channel, nameof(channel));
 | 
			
		||||
 | 
			
		||||
        var originalAmount = amount;
 | 
			
		||||
        if (amount <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(amount));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(amount);
 | 
			
		||||
 | 
			
		||||
        using var cancelSource = new CancellationTokenSource();
 | 
			
		||||
        if (!_pruningGuilds.TryAdd(channel.GuildId, cancelSource))
 | 
			
		||||
 
 | 
			
		||||
@@ -250,11 +250,9 @@ public sealed class ReactionRolesService : IReadyExecutor, INService, IReactionR
 | 
			
		||||
        int group = 0,
 | 
			
		||||
        int levelReq = 0)
 | 
			
		||||
    {
 | 
			
		||||
        if (group < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(group));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(group);
 | 
			
		||||
 | 
			
		||||
        if (levelReq < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(group));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(levelReq);
 | 
			
		||||
 | 
			
		||||
        await using var ctx = _db.GetDbContext();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -64,8 +64,7 @@ public class UserPunishService : INService, IReadyExecutor
 | 
			
		||||
        long weight,
 | 
			
		||||
        string reason)
 | 
			
		||||
    {
 | 
			
		||||
        if (weight <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(weight));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(weight);
 | 
			
		||||
 | 
			
		||||
        var modName = mod.ToString();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -61,8 +61,7 @@ public sealed class AnimalRace : IDisposable
 | 
			
		||||
 | 
			
		||||
    public async Task<AnimalRacingUser> JoinRace(ulong userId, string userName, long bet = 0)
 | 
			
		||||
    {
 | 
			
		||||
        if (bet < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(bet));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(bet);
 | 
			
		||||
 | 
			
		||||
        var user = new AnimalRacingUser(userName, userId, bet);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -17,8 +17,7 @@ public sealed class BankService : IBankService, INService
 | 
			
		||||
 | 
			
		||||
    public async Task<bool> AwardAsync(ulong userId, long amount)
 | 
			
		||||
    {
 | 
			
		||||
        if (amount <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(amount));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(amount);
 | 
			
		||||
 | 
			
		||||
        await using var ctx = _db.GetDbContext();
 | 
			
		||||
        await ctx.GetTable<BankUser>()
 | 
			
		||||
@@ -41,9 +40,8 @@ public sealed class BankService : IBankService, INService
 | 
			
		||||
    
 | 
			
		||||
    public async Task<bool> TakeAsync(ulong userId, long amount)
 | 
			
		||||
    {
 | 
			
		||||
        if (amount <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(amount));
 | 
			
		||||
        
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(amount);
 | 
			
		||||
 | 
			
		||||
        await using var ctx = _db.GetDbContext();
 | 
			
		||||
        var rows = await ctx.Set<BankUser>()
 | 
			
		||||
            .ToLinqToDBTable()
 | 
			
		||||
@@ -58,9 +56,8 @@ public sealed class BankService : IBankService, INService
 | 
			
		||||
 | 
			
		||||
    public async Task<bool> DepositAsync(ulong userId, long amount)
 | 
			
		||||
    {
 | 
			
		||||
        if (amount <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(amount));
 | 
			
		||||
        
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(amount);
 | 
			
		||||
 | 
			
		||||
        if (!await _cur.RemoveAsync(userId, amount, new("bank", "deposit")))
 | 
			
		||||
            return false;
 | 
			
		||||
 | 
			
		||||
@@ -86,9 +83,8 @@ public sealed class BankService : IBankService, INService
 | 
			
		||||
 | 
			
		||||
    public async Task<bool> WithdrawAsync(ulong userId, long amount)
 | 
			
		||||
    {
 | 
			
		||||
        if (amount <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(amount));
 | 
			
		||||
        
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(amount);
 | 
			
		||||
 | 
			
		||||
        await using var ctx = _db.GetDbContext();
 | 
			
		||||
        var rows = await ctx.Set<BankUser>()
 | 
			
		||||
                 .ToLinqToDBTable()
 | 
			
		||||
 
 | 
			
		||||
@@ -49,8 +49,7 @@ public class User : Player
 | 
			
		||||
 | 
			
		||||
    public User(IUser user, long bet)
 | 
			
		||||
    {
 | 
			
		||||
        if (bet <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(bet));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(bet);
 | 
			
		||||
 | 
			
		||||
        Bet = bet;
 | 
			
		||||
        DiscordUser = user;
 | 
			
		||||
 
 | 
			
		||||
@@ -20,10 +20,8 @@ public class ShopService : IShopService, INService
 | 
			
		||||
 | 
			
		||||
    public async Task<bool> ChangeEntryPriceAsync(ulong guildId, int index, int newPrice)
 | 
			
		||||
    {
 | 
			
		||||
        if (index < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(index));
 | 
			
		||||
        if (newPrice <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(newPrice));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(index);
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(newPrice);
 | 
			
		||||
 | 
			
		||||
        await using var uow = _db.GetDbContext();
 | 
			
		||||
        var entries = GetEntriesInternal(uow, guildId);
 | 
			
		||||
@@ -38,8 +36,8 @@ public class ShopService : IShopService, INService
 | 
			
		||||
 | 
			
		||||
    public async Task<bool> ChangeEntryNameAsync(ulong guildId, int index, string newName)
 | 
			
		||||
    {
 | 
			
		||||
        if (index < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(index));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(index);
 | 
			
		||||
        
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(newName))
 | 
			
		||||
            throw new ArgumentNullException(nameof(newName));
 | 
			
		||||
 | 
			
		||||
@@ -56,10 +54,8 @@ public class ShopService : IShopService, INService
 | 
			
		||||
 | 
			
		||||
    public async Task<bool> SwapEntriesAsync(ulong guildId, int index1, int index2)
 | 
			
		||||
    {
 | 
			
		||||
        if (index1 < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(index1));
 | 
			
		||||
        if (index2 < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(index2));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(index1);
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(index2);
 | 
			
		||||
 | 
			
		||||
        await using var uow = _db.GetDbContext();
 | 
			
		||||
        var entries = GetEntriesInternal(uow, guildId);
 | 
			
		||||
@@ -76,10 +72,8 @@ public class ShopService : IShopService, INService
 | 
			
		||||
 | 
			
		||||
    public async Task<bool> MoveEntryAsync(ulong guildId, int fromIndex, int toIndex)
 | 
			
		||||
    {
 | 
			
		||||
        if (fromIndex < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(fromIndex));
 | 
			
		||||
        if (toIndex < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(toIndex));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(fromIndex);
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(toIndex);
 | 
			
		||||
 | 
			
		||||
        await using var uow = _db.GetDbContext();
 | 
			
		||||
        var entries = GetEntriesInternal(uow, guildId);
 | 
			
		||||
 
 | 
			
		||||
@@ -27,8 +27,8 @@ public static class WaifuExtensions
 | 
			
		||||
 | 
			
		||||
    public static IEnumerable<WaifuLbResult> GetTop(this DbSet<WaifuInfo> waifus, int count, int skip = 0)
 | 
			
		||||
    {
 | 
			
		||||
        if (count < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(count));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(count);
 | 
			
		||||
        
 | 
			
		||||
        if (count == 0)
 | 
			
		||||
            return new List<WaifuLbResult>();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -14,5 +14,5 @@ public interface IGamblingService
 | 
			
		||||
    Task<OneOf<SlotResult, GamblingError>> SlotAsync(ulong userId, long amount);
 | 
			
		||||
    Task<FlipResult[]> FlipAsync(int count);
 | 
			
		||||
    Task<OneOf<RpsResult, GamblingError>> RpsAsync(ulong userId, long amount, byte pick);
 | 
			
		||||
    Task<OneOf<BetdrawResult, GamblingError>> BetDrawAsync(ulong userId, long amount, byte? guessValue, byte? guessColor);
 | 
			
		||||
    Task<OneOf<BetdrawResult, GamblingError>> BetDrawAsync(ulong userId, long amount, byte? maybeGuessValue, byte? maybeGuessColor);
 | 
			
		||||
}
 | 
			
		||||
@@ -20,9 +20,8 @@ public sealed class NewGamblingService : IGamblingService, INService
 | 
			
		||||
    
 | 
			
		||||
    public async Task<OneOf<LuLaResult, GamblingError>> LulaAsync(ulong userId, long amount)
 | 
			
		||||
    {
 | 
			
		||||
        if (amount < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(amount));
 | 
			
		||||
        
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(amount);
 | 
			
		||||
 | 
			
		||||
        if (amount > 0)
 | 
			
		||||
        {
 | 
			
		||||
            var isTakeSuccess = await _cs.RemoveAsync(userId, amount, new("lula", "bet"));
 | 
			
		||||
@@ -47,8 +46,7 @@ public sealed class NewGamblingService : IGamblingService, INService
 | 
			
		||||
 | 
			
		||||
    public async Task<OneOf<BetrollResult, GamblingError>> BetRollAsync(ulong userId, long amount)
 | 
			
		||||
    {
 | 
			
		||||
        if (amount < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(amount));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(amount);
 | 
			
		||||
 | 
			
		||||
        if (amount > 0)
 | 
			
		||||
        {
 | 
			
		||||
@@ -77,11 +75,9 @@ public sealed class NewGamblingService : IGamblingService, INService
 | 
			
		||||
 | 
			
		||||
    public async Task<OneOf<BetflipResult, GamblingError>> BetFlipAsync(ulong userId, long amount, byte guess)
 | 
			
		||||
    {
 | 
			
		||||
        if (amount < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(amount));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(amount);
 | 
			
		||||
 | 
			
		||||
        if (guess > 1)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(guess));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfGreaterThan(guess, 1);
 | 
			
		||||
 | 
			
		||||
        if (amount > 0)
 | 
			
		||||
        {
 | 
			
		||||
@@ -105,19 +101,18 @@ public sealed class NewGamblingService : IGamblingService, INService
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public async Task<OneOf<BetdrawResult, GamblingError>> BetDrawAsync(ulong userId, long amount, byte? guessValue, byte? guessColor)
 | 
			
		||||
    public async Task<OneOf<BetdrawResult, GamblingError>> BetDrawAsync(ulong userId, long amount, byte? maybeGuessValue, byte? maybeGuessColor)
 | 
			
		||||
    {
 | 
			
		||||
        if (amount < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(amount));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(amount);
 | 
			
		||||
 | 
			
		||||
        if (guessColor is null && guessValue is null)
 | 
			
		||||
        if (maybeGuessColor is null && maybeGuessValue is null)
 | 
			
		||||
            throw new ArgumentNullException();
 | 
			
		||||
 | 
			
		||||
        if (guessColor > 1)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(guessColor));
 | 
			
		||||
        if (maybeGuessColor > 1)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(maybeGuessColor));
 | 
			
		||||
        
 | 
			
		||||
        if (guessValue > 1)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(guessValue));
 | 
			
		||||
        if (maybeGuessValue > 1)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(maybeGuessValue));
 | 
			
		||||
 | 
			
		||||
        if (amount > 0)
 | 
			
		||||
        {
 | 
			
		||||
@@ -130,7 +125,7 @@ public sealed class NewGamblingService : IGamblingService, INService
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var game = new BetdrawGame();
 | 
			
		||||
        var result = game.Draw((BetdrawValueGuess?)guessValue, (BetdrawColorGuess?)guessColor, amount);
 | 
			
		||||
        var result = game.Draw((BetdrawValueGuess?)maybeGuessValue, (BetdrawColorGuess?)maybeGuessColor, amount);
 | 
			
		||||
        
 | 
			
		||||
        var won = (long)result.Won;
 | 
			
		||||
        if (won > 0)
 | 
			
		||||
@@ -143,9 +138,8 @@ public sealed class NewGamblingService : IGamblingService, INService
 | 
			
		||||
 | 
			
		||||
    public async Task<OneOf<SlotResult, GamblingError>> SlotAsync(ulong userId, long amount)
 | 
			
		||||
    {
 | 
			
		||||
        if (amount < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(amount));
 | 
			
		||||
        
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(amount);
 | 
			
		||||
 | 
			
		||||
        if (amount > 0)
 | 
			
		||||
        {
 | 
			
		||||
            var isTakeSuccess = await _cs.RemoveAsync(userId, amount, new("slot", "bet"));
 | 
			
		||||
@@ -170,9 +164,8 @@ public sealed class NewGamblingService : IGamblingService, INService
 | 
			
		||||
 | 
			
		||||
    public Task<FlipResult[]> FlipAsync(int count)
 | 
			
		||||
    {
 | 
			
		||||
        if (count < 1)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(count));
 | 
			
		||||
        
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfLessThan(count, 1);
 | 
			
		||||
 | 
			
		||||
        var game = new BetflipGame(0);
 | 
			
		||||
 | 
			
		||||
        var results = new FlipResult[count];
 | 
			
		||||
@@ -242,11 +235,8 @@ public sealed class NewGamblingService : IGamblingService, INService
 | 
			
		||||
 | 
			
		||||
    public async Task<OneOf<RpsResult, GamblingError>> RpsAsync(ulong userId, long amount, byte pick)
 | 
			
		||||
    {
 | 
			
		||||
        if (amount < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(amount));
 | 
			
		||||
 | 
			
		||||
        if (pick > 2)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(pick));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(amount);
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfGreaterThan(pick, 2);
 | 
			
		||||
        
 | 
			
		||||
        if (amount > 0)
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -201,12 +201,9 @@ public sealed partial class MusicQueue : IMusicQueue
 | 
			
		||||
 | 
			
		||||
    public IQueuedTrackInfo? MoveTrack(int from, int to)
 | 
			
		||||
    {
 | 
			
		||||
        if (from < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(from));
 | 
			
		||||
        if (to < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(to));
 | 
			
		||||
        if (to == from)
 | 
			
		||||
            throw new ArgumentException($"{nameof(from)} and {nameof(to)} must be different");
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(from);
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(to);
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfEqual(to, from);
 | 
			
		||||
 | 
			
		||||
        lock (_locker)
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -8,8 +8,7 @@ public static class MusicPlaylistExtensions
 | 
			
		||||
{
 | 
			
		||||
    public static List<MusicPlaylist> GetPlaylistsOnPage(this DbSet<MusicPlaylist> playlists, int num)
 | 
			
		||||
    {
 | 
			
		||||
        if (num < 1)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(num));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfLessThan(num, 1);
 | 
			
		||||
 | 
			
		||||
        return playlists.AsQueryable().Skip((num - 1) * 20).Take(20).Include(pl => pl.Songs).ToList();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -16,8 +16,7 @@ public partial class Permissions
 | 
			
		||||
 | 
			
		||||
        private async Task ListBlacklistInternal(string title, BlacklistType type, int page = 0)
 | 
			
		||||
        {
 | 
			
		||||
            if (page < 0)
 | 
			
		||||
                throw new ArgumentOutOfRangeException(nameof(page));
 | 
			
		||||
            ArgumentOutOfRangeException.ThrowIfNegative(page);
 | 
			
		||||
 | 
			
		||||
            var list = _service.GetBlacklist();
 | 
			
		||||
            var allItems = await list.Where(x => x.Type == type)
 | 
			
		||||
 
 | 
			
		||||
@@ -112,9 +112,8 @@ public sealed class CmdCdService : IExecPreCommand, IReadyExecutor, INService
 | 
			
		||||
 | 
			
		||||
    public void AddCooldown(ulong guildId, string name, int secs)
 | 
			
		||||
    {
 | 
			
		||||
        if (secs <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(secs));
 | 
			
		||||
        
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(secs);
 | 
			
		||||
 | 
			
		||||
        var sett = _settings.GetOrAdd(guildId, static _ => new());
 | 
			
		||||
        sett[name] = secs;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
public class PlainGoogleScrapeSearchResult : ISearchResult
 | 
			
		||||
{
 | 
			
		||||
    public string? Answer { get; init;  } = null!;
 | 
			
		||||
    public IReadOnlyCollection<ISearchResultEntry> Entries { get; init; } = null!;
 | 
			
		||||
    public ISearchResultInformation Info { get; init; } = null!;
 | 
			
		||||
    public required string? Answer { get; init;  } 
 | 
			
		||||
    public required IReadOnlyCollection<ISearchResultEntry> Entries { get; init; }
 | 
			
		||||
    public required ISearchResultInformation Info { get; init; } 
 | 
			
		||||
}
 | 
			
		||||
@@ -363,8 +363,7 @@ public sealed class RepeaterService : IReadyExecutor, INService
 | 
			
		||||
 | 
			
		||||
    public async Task<RunningRepeater?> RemoveByIndexAsync(ulong guildId, int index)
 | 
			
		||||
    {
 | 
			
		||||
        if (index > MAX_REPEATERS * 2)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(index));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfGreaterThan(index, MAX_REPEATERS * 2);
 | 
			
		||||
 | 
			
		||||
        await using var uow = _db.GetDbContext();
 | 
			
		||||
        var toRemove = await uow.Set<Repeater>()
 | 
			
		||||
 
 | 
			
		||||
@@ -332,8 +332,7 @@ public class ClubService : INService, IClubService
 | 
			
		||||
 | 
			
		||||
    public List<ClubInfo> GetClubLeaderboardPage(int page)
 | 
			
		||||
    {
 | 
			
		||||
        if (page < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(page));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(page);
 | 
			
		||||
 | 
			
		||||
        using var uow = _db.GetDbContext();
 | 
			
		||||
        return uow.Set<ClubInfo>().GetClubLeaderboardPage(page);
 | 
			
		||||
 
 | 
			
		||||
@@ -43,8 +43,7 @@ public sealed partial class GoogleApiService : IGoogleApiService, INService
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(keywords))
 | 
			
		||||
            throw new ArgumentNullException(nameof(keywords));
 | 
			
		||||
 | 
			
		||||
        if (count <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(count));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(count);
 | 
			
		||||
 | 
			
		||||
        var match = _plRegex.Match(keywords);
 | 
			
		||||
        if (match.Length > 1)
 | 
			
		||||
@@ -62,9 +61,8 @@ public sealed partial class GoogleApiService : IGoogleApiService, INService
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(id))
 | 
			
		||||
            throw new ArgumentNullException(nameof(id));
 | 
			
		||||
 | 
			
		||||
        if (count <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(count));
 | 
			
		||||
        
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(count);
 | 
			
		||||
 | 
			
		||||
        var query = _yt.Search.List("snippet");
 | 
			
		||||
        query.MaxResults = count;
 | 
			
		||||
        query.Q = id;
 | 
			
		||||
@@ -82,8 +80,7 @@ public sealed partial class GoogleApiService : IGoogleApiService, INService
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(keywords))
 | 
			
		||||
            throw new ArgumentNullException(nameof(keywords));
 | 
			
		||||
 | 
			
		||||
        if (count <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(count));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(count);
 | 
			
		||||
 | 
			
		||||
        var query = _yt.Search.List("snippet");
 | 
			
		||||
        query.MaxResults = count;
 | 
			
		||||
@@ -100,8 +97,7 @@ public sealed partial class GoogleApiService : IGoogleApiService, INService
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(keywords))
 | 
			
		||||
            throw new ArgumentNullException(nameof(keywords));
 | 
			
		||||
 | 
			
		||||
        if (count <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(count));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(count);
 | 
			
		||||
 | 
			
		||||
        var query = _yt.Search.List("snippet");
 | 
			
		||||
        query.MaxResults = count;
 | 
			
		||||
@@ -150,8 +146,7 @@ public sealed partial class GoogleApiService : IGoogleApiService, INService
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(playlistId))
 | 
			
		||||
            throw new ArgumentNullException(nameof(playlistId));
 | 
			
		||||
 | 
			
		||||
        if (count <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(count));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(count);
 | 
			
		||||
 | 
			
		||||
        string nextPageToken = null;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -46,12 +46,8 @@ public sealed class ConcurrentHashSet<T> : IReadOnlyCollection<T>, ICollection<T
 | 
			
		||||
    public void CopyTo(T[] array, int arrayIndex)
 | 
			
		||||
    {
 | 
			
		||||
        ArgumentNullException.ThrowIfNull(array);
 | 
			
		||||
        
 | 
			
		||||
        if (arrayIndex < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(arrayIndex));
 | 
			
		||||
        
 | 
			
		||||
        if (arrayIndex >= array.Length)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(arrayIndex));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(arrayIndex);
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(arrayIndex, array.Length);
 | 
			
		||||
 | 
			
		||||
        CopyToInternal(array, arrayIndex);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -38,8 +38,8 @@ public sealed class NadekoRandom : Random
 | 
			
		||||
 | 
			
		||||
    public long NextLong(long minValue, long maxValue)
 | 
			
		||||
    {
 | 
			
		||||
        if (minValue > maxValue)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(maxValue));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfGreaterThan(minValue, maxValue);
 | 
			
		||||
        
 | 
			
		||||
        if (minValue == maxValue)
 | 
			
		||||
            return minValue;
 | 
			
		||||
        var bytes = new byte[sizeof(long)];
 | 
			
		||||
 
 | 
			
		||||
@@ -9,8 +9,7 @@ public sealed class QueueRunner
 | 
			
		||||
 | 
			
		||||
    public QueueRunner(int delayMs = 0, int maxCapacity = -1)
 | 
			
		||||
    {
 | 
			
		||||
        if (delayMs < 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(delayMs));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegative(delayMs);
 | 
			
		||||
 | 
			
		||||
        _delayMs = delayMs;
 | 
			
		||||
        _channel = maxCapacity switch
 | 
			
		||||
 
 | 
			
		||||
@@ -9,8 +9,7 @@ public sealed class RatelimitAttribute : PreconditionAttribute
 | 
			
		||||
 | 
			
		||||
    public RatelimitAttribute(int seconds)
 | 
			
		||||
    {
 | 
			
		||||
        if (seconds <= 0)
 | 
			
		||||
            throw new ArgumentOutOfRangeException(nameof(seconds));
 | 
			
		||||
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(seconds);
 | 
			
		||||
 | 
			
		||||
        Seconds = seconds;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user