From 7ee51332b0d9ac9ce0d61352e906cbda133573fb Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 1 Feb 2022 13:51:07 +0100 Subject: [PATCH] Some refactorings - Updated editorconfig, removed some unused variables and parameters, updated some old thorwaway variable code, some general cleanup --- .editorconfig | 122 ------------------ src/NadekoBot/.editorconfig | 30 ++--- .../TypeReaders/ShmartNumberTypeReader.cs | 2 +- src/NadekoBot/Modules/Gambling/Gambling.cs | 42 +++--- .../Gambling/PlantPick/PlantPickService.cs | 2 +- .../Modules/Gambling/Shop/ShopCommands.cs | 5 +- .../Gambling/Waifus/WaifuClaimCommands.cs | 4 +- .../Modules/Gambling/~Shared/Decks/Deck.cs | 2 +- src/NadekoBot/Modules/Games/GirlRating.cs | 9 -- src/NadekoBot/Modules/Games/Nunchi/Nunchi.cs | 8 +- .../Modules/Games/Polls/PollCommands.cs | 2 - src/NadekoBot/Modules/Music/Music.cs | 2 +- .../Modules/Music/_Common/Impl/MusicPlayer.cs | 7 +- .../Modules/Nsfw/SearchImageCacher.cs | 5 +- .../Modules/Nsfw/SearchImagesService.cs | 2 +- .../Modules/Searches/MemegenCommands.cs | 2 +- src/NadekoBot/Modules/Searches/Searches.cs | 12 +- .../Modules/Searches/SearchesService.cs | 1 + src/NadekoBot/NadekoBot.csproj | 2 +- .../Services/Currency/CurrencyService.cs | 4 - 20 files changed, 64 insertions(+), 201 deletions(-) delete mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 3f356f43b..000000000 --- a/.editorconfig +++ /dev/null @@ -1,122 +0,0 @@ - -[*] -charset = utf-8-bom -end_of_line = crlf -trim_trailing_whitespace = false -insert_final_newline = false -indent_style = space -indent_size = 4 - -[{*.har,*.inputactions,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}] -indent_style = space -indent_size = 2 - -[{*.yaml,*.yml}] -indent_style = space -indent_size = 2 - -[*.proto] -indent_style = space -indent_size = 2 - -[*.{appxmanifest,asax,ascx,aspx,axaml,build,cg,cginc,compute,cs,cshtml,dtd,hlsl,hlsli,hlslinc,master,nuspec,paml,razor,resw,resx,shader,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}] -indent_style = space -indent_size = 4 -tab_width = 4 - -[*.cs] - -# Microsoft .NET properties -csharp_new_line_before_members_in_object_initializers = false -csharp_preferred_modifier_order = public, private, protected, internal, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async:suggestion -csharp_style_var_elsewhere = true:suggestion -csharp_style_var_for_built_in_types = true:suggestion -csharp_style_var_when_type_is_apparent = true:suggestion -dotnet_naming_rule.constants_rule.import_to_resharper = as_predefined -dotnet_naming_rule.constants_rule.severity = suggestion -dotnet_naming_rule.constants_rule.style = all_upper_style -dotnet_naming_rule.constants_rule.symbols = constants_symbols -dotnet_naming_rule.local_constants_rule.import_to_resharper = as_predefined -dotnet_naming_rule.local_constants_rule.severity = suggestion -dotnet_naming_rule.local_constants_rule.style = all_upper_style -dotnet_naming_rule.local_constants_rule.symbols = local_constants_symbols -dotnet_naming_rule.private_constants_rule.import_to_resharper = as_predefined -dotnet_naming_rule.private_constants_rule.severity = suggestion -dotnet_naming_rule.private_constants_rule.style = all_upper_style -dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols -dotnet_naming_rule.unity_serialized_field_rule.import_to_resharper = True -dotnet_naming_rule.unity_serialized_field_rule.resharper_description = Unity serialized field -dotnet_naming_rule.unity_serialized_field_rule.resharper_guid = 5f0fdb63-c892-4d2c-9324-15c80b22a7ef -dotnet_naming_rule.unity_serialized_field_rule.severity = suggestion -dotnet_naming_rule.unity_serialized_field_rule.style = lower_camel_case_style -dotnet_naming_rule.unity_serialized_field_rule.symbols = unity_serialized_field_symbols -dotnet_naming_style.all_upper_style.capitalization = all_upper -dotnet_naming_style.all_upper_style.word_separator = _ -dotnet_naming_style.lower_camel_case_style.capitalization = camel_case -dotnet_naming_symbols.constants_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected -dotnet_naming_symbols.constants_symbols.applicable_kinds = field -dotnet_naming_symbols.constants_symbols.required_modifiers = const -dotnet_naming_symbols.local_constants_symbols.applicable_accessibilities = * -dotnet_naming_symbols.local_constants_symbols.applicable_kinds = local -dotnet_naming_symbols.local_constants_symbols.required_modifiers = const -dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private -dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field -dotnet_naming_symbols.private_constants_symbols.required_modifiers = const -dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities = * -dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds = -dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds = unity_serialised_field -dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers = instance -dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none -dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none -dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none -dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion -dotnet_style_predefined_type_for_member_access = true:suggestion -dotnet_style_qualification_for_event = false:suggestion -dotnet_style_qualification_for_field = false:suggestion -dotnet_style_qualification_for_method = false:suggestion -dotnet_style_qualification_for_property = false:suggestion -dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion - -# ReSharper properties -resharper_autodetect_indent_settings = true -resharper_object_creation_when_type_not_evident = target_typed -resharper_show_autodetect_configure_formatting_tip = false -resharper_use_indent_from_vs = false - -# ReSharper inspection severities -resharper_arrange_object_creation_when_type_evident_highlighting = none -resharper_arrange_redundant_parentheses_highlighting = hint -resharper_arrange_this_qualifier_highlighting = hint -resharper_arrange_type_member_modifiers_highlighting = hint -resharper_arrange_type_modifiers_highlighting = hint -resharper_built_in_type_reference_style_for_member_access_highlighting = hint -resharper_built_in_type_reference_style_highlighting = hint -resharper_check_namespace_highlighting = none -resharper_comment_typo_highlighting = none -resharper_empty_general_catch_clause_highlighting = none -resharper_function_never_returns_highlighting = suggestion -resharper_identifier_typo_highlighting = none -resharper_inconsistent_naming_highlighting = suggestion -resharper_invert_if_highlighting = none -resharper_non_readonly_member_in_get_hash_code_highlighting = suggestion -resharper_redundant_anonymous_type_property_name_highlighting = suggestion -resharper_redundant_base_qualifier_highlighting = warning -resharper_string_literal_typo_highlighting = none -resharper_suggest_var_or_type_built_in_types_highlighting = hint -resharper_suggest_var_or_type_elsewhere_highlighting = hint -resharper_suggest_var_or_type_simple_types_highlighting = hint -resharper_unused_method_return_value_local_highlighting = suggestion -resharper_web_config_module_not_resolved_highlighting = warning -resharper_web_config_type_not_resolved_highlighting = warning -resharper_web_config_wrong_module_highlighting = warning -resharper_convert_to_using_declaration_highlighting = warning - -# Expression-bodied members -csharp_style_expression_bodied_accessors = true:warning -csharp_style_expression_bodied_constructors = true:warning -csharp_style_expression_bodied_indexers = true:warning -csharp_style_expression_bodied_lambdas = true:warning -csharp_style_expression_bodied_local_functions = true:warning -csharp_style_expression_bodied_methods = true:warning -csharp_style_expression_bodied_operators = when_on_single_line:suggestion -csharp_style_expression_bodied_properties = true:warning \ No newline at end of file diff --git a/src/NadekoBot/.editorconfig b/src/NadekoBot/.editorconfig index 54a8cfb80..5787b55e0 100644 --- a/src/NadekoBot/.editorconfig +++ b/src/NadekoBot/.editorconfig @@ -189,9 +189,9 @@ dotnet_naming_rule.const_fields.symbols = const_fields dotnet_naming_rule.const_fields.style = all_upper dotnet_naming_rule.const_fields.severity = warning -dotnet_naming_rule.class_should_be_pascal_case.severity = error -dotnet_naming_rule.class_should_be_pascal_case.symbols = class -dotnet_naming_rule.class_should_be_pascal_case.style = pascal_case +# dotnet_naming_rule.class_should_be_pascal_case.severity = error +# dotnet_naming_rule.class_should_be_pascal_case.symbols = class +# dotnet_naming_rule.class_should_be_pascal_case.style = pascal_case dotnet_naming_rule.struct_should_be_pascal_case.severity = error dotnet_naming_rule.struct_should_be_pascal_case.symbols = struct @@ -201,17 +201,17 @@ dotnet_naming_rule.interface_should_be_begins_with_i.severity = error dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i -dotnet_naming_rule.types_should_be_pascal_case.severity = error -dotnet_naming_rule.types_should_be_pascal_case.symbols = types -dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case +# dotnet_naming_rule.types_should_be_pascal_case.severity = error +# dotnet_naming_rule.types_should_be_pascal_case.symbols = types +# dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case -dotnet_naming_rule.enum_should_be_pascal_case.severity = error -dotnet_naming_rule.enum_should_be_pascal_case.symbols = enum -dotnet_naming_rule.enum_should_be_pascal_case.style = pascal_case +# dotnet_naming_rule.enum_should_be_pascal_case.severity = error +# dotnet_naming_rule.enum_should_be_pascal_case.symbols = enum +# dotnet_naming_rule.enum_should_be_pascal_case.style = pascal_case -dotnet_naming_rule.property_should_be_pascal_case.severity = error -dotnet_naming_rule.property_should_be_pascal_case.symbols = property -dotnet_naming_rule.property_should_be_pascal_case.style = pascal_case +# dotnet_naming_rule.property_should_be_pascal_case.severity = error +# dotnet_naming_rule.property_should_be_pascal_case.symbols = property +# dotnet_naming_rule.property_should_be_pascal_case.style = pascal_case dotnet_naming_rule.method_should_be_pascal_case.severity = error dotnet_naming_rule.method_should_be_pascal_case.symbols = method @@ -221,9 +221,9 @@ dotnet_naming_rule.async_method_should_be_ends_with_async.severity = error dotnet_naming_rule.async_method_should_be_ends_with_async.symbols = async_method dotnet_naming_rule.async_method_should_be_ends_with_async.style = ends_with_async -dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = error -dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members -dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case +# dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = error +# dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +# dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case dotnet_naming_rule.local_variable_should_be_camel_case.severity = error dotnet_naming_rule.local_variable_should_be_camel_case.symbols = local_variable diff --git a/src/NadekoBot/Common/TypeReaders/ShmartNumberTypeReader.cs b/src/NadekoBot/Common/TypeReaders/ShmartNumberTypeReader.cs index 158847cb0..62b9448af 100644 --- a/src/NadekoBot/Common/TypeReaders/ShmartNumberTypeReader.cs +++ b/src/NadekoBot/Common/TypeReaders/ShmartNumberTypeReader.cs @@ -40,7 +40,7 @@ public sealed class ShmartNumberTypeReader : NadekoTypeReader } catch (Exception) { - return ValueTask.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, $"Invalid input: {input}")); + return ValueTask.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, $"Invalid input: {input}")); } } diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index 378fa198e..97d57450f 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -64,7 +64,7 @@ public partial class Gambling : GamblingModule _configService = configService; } - private string n(long cur) + private string N(long cur) { var flowersCi = (CultureInfo)Culture.Clone(); flowersCi.NumberFormat.CurrencySymbol = CurrencySign; @@ -78,7 +78,7 @@ public partial class Gambling : GamblingModule { var wallet = await _cs.GetWalletAsync(userId); var bal = await wallet.GetBalance(); - return n(bal); + return N(bal); } [Cmd] @@ -99,7 +99,7 @@ public partial class Gambling : GamblingModule .AddField(GetText(strs.currency_one_percent), (onePercent * 100).ToString("F2") + "%") .AddField(GetText(strs.currency_planted), (BigInteger)ec.Planted) .AddField(GetText(strs.owned_waifus_total), (BigInteger)ec.Waifus + CurrencySign) - .AddField(GetText(strs.bot_currency), n(ec.Bot)) + .AddField(GetText(strs.bot_currency), N(ec.Bot)) .AddField(GetText(strs.total), ((BigInteger)(ec.Cash + ec.Planted + ec.Waifus)).ToString("N", Culture) + CurrencySign) .WithOkColor(); @@ -127,7 +127,7 @@ public partial class Gambling : GamblingModule await _cs.AddAsync(ctx.User.Id, val, new("timely", "claim")); - await ReplyConfirmLocalizedAsync(strs.timely(n(val), period)); + await ReplyConfirmLocalizedAsync(strs.timely(N(val), period)); } [Cmd] @@ -154,7 +154,7 @@ public partial class Gambling : GamblingModule if (amount == 0) await ReplyConfirmLocalizedAsync(strs.timely_set_none); else - await ReplyConfirmLocalizedAsync(strs.timely_set(Format.Bold(n(amount)), Format.Bold(period.ToString()))); + await ReplyConfirmLocalizedAsync(strs.timely_set(Format.Bold(N(amount)), Format.Bold(period.ToString()))); } [Cmd] @@ -230,7 +230,7 @@ public partial class Gambling : GamblingModule var date = $"#{Format.Code(kwumId)} `〖{GetFormattedCurtrDate(tr)}〗`"; - sb.AppendLine($"\\{change} {date} {Format.Bold(n(tr.Amount))}"); + sb.AppendLine($"\\{change} {date} {Format.Bold(N(tr.Amount))}"); var transactionString = GetHumanReadableTransaction(tr.Type, tr.Extra, tr.OtherId); if(transactionString is not null) sb.AppendLine(transactionString); @@ -270,7 +270,7 @@ public partial class Gambling : GamblingModule eb.WithAuthor(ctx.User); eb.WithTitle(GetText(strs.transaction)); eb.WithDescription(new kwum(tr.Id).ToString()); - eb.AddField("Amount", n(tr.Amount), false); + eb.AddField("Amount", N(tr.Amount)); eb.AddField("Type", tr.Type, true); eb.AddField("Extra", tr.Extra, true); @@ -332,7 +332,7 @@ public partial class Gambling : GamblingModule return; } - await ReplyConfirmLocalizedAsync(strs.gifted(n(amount), Format.Bold(receiver.ToString()))); + await ReplyConfirmLocalizedAsync(strs.gifted(N(amount), Format.Bold(receiver.ToString()))); } [Cmd] @@ -375,7 +375,7 @@ public partial class Gambling : GamblingModule amount, new TxData("award", ctx.User.ToString()!, msg, ctx.User.Id) ); - await ReplyConfirmLocalizedAsync(strs.awarded(n(amount), $"<@{usrId}>")); + await ReplyConfirmLocalizedAsync(strs.awarded(N(amount), $"<@{usrId}>")); } [Cmd] @@ -393,7 +393,7 @@ public partial class Gambling : GamblingModule role.Name, ctx.User.Id)); - await ReplyConfirmLocalizedAsync(strs.mass_award(n(amount), + await ReplyConfirmLocalizedAsync(strs.mass_award(N(amount), Format.Bold(users.Count.ToString()), Format.Bold(role.Name))); } @@ -413,7 +413,7 @@ public partial class Gambling : GamblingModule null, ctx.User.Id)); - await ReplyConfirmLocalizedAsync(strs.mass_take(n(amount), + await ReplyConfirmLocalizedAsync(strs.mass_take(N(amount), Format.Bold(users.Count.ToString()), Format.Bold(role.Name))); } @@ -433,9 +433,9 @@ public partial class Gambling : GamblingModule ctx.User.Id); if (await _cs.RemoveAsync(user.Id, amount, extra)) - await ReplyConfirmLocalizedAsync(strs.take(n(amount), Format.Bold(user.ToString()))); + await ReplyConfirmLocalizedAsync(strs.take(N(amount), Format.Bold(user.ToString()))); else - await ReplyErrorLocalizedAsync(strs.take_fail(n(amount), Format.Bold(user.ToString()), CurrencySign)); + await ReplyErrorLocalizedAsync(strs.take_fail(N(amount), Format.Bold(user.ToString()), CurrencySign)); } @@ -452,9 +452,9 @@ public partial class Gambling : GamblingModule ctx.User.Id); if (await _cs.RemoveAsync(usrId, amount, extra)) - await ReplyConfirmLocalizedAsync(strs.take(n(amount), $"<@{usrId}>")); + await ReplyConfirmLocalizedAsync(strs.take(N(amount), $"<@{usrId}>")); else - await ReplyErrorLocalizedAsync(strs.take_fail(n(amount), Format.Code(usrId.ToString()), CurrencySign)); + await ReplyErrorLocalizedAsync(strs.take_fail(N(amount), Format.Code(usrId.ToString()), CurrencySign)); } [Cmd] @@ -502,7 +502,7 @@ public partial class Gambling : GamblingModule await ReplyConfirmLocalizedAsync(strs.roll_duel_challenge(Format.Bold(ctx.User.ToString()), Format.Bold(u.ToString()), - Format.Bold(n(amount)))); + Format.Bold(N(amount)))); } async Task GameOnGameTick(RollDuelGame arg) @@ -530,7 +530,7 @@ public partial class Gambling : GamblingModule if (reason == RollDuelGame.Reason.Normal) { var winner = rdGame.Winner == rdGame.P1 ? ctx.User : u; - description += $"\n**{winner}** Won {n((long)(rdGame.Amount * 2 * 0.98))}"; + description += $"\n**{winner}** Won {N((long)(rdGame.Amount * 2 * 0.98))}"; embed = embed.WithDescription(description); @@ -572,7 +572,7 @@ public partial class Gambling : GamblingModule if (result.Multiplier > 0) { var win = (long)(amount * result.Multiplier); - str += GetText(strs.br_win(n(win), result.Threshold + (result.Roll == 100 ? " 👑" : ""))); + str += GetText(strs.br_win(N(win), result.Threshold + (result.Roll == 100 ? " 👑" : ""))); await _cs.AddAsync(ctx.User, win, new("betroll", "win")); } else @@ -655,7 +655,7 @@ public partial class Gambling : GamblingModule var usrStr = x.ToString().TrimTo(20, true); var j = i; - embed.AddField("#" + ((9 * curPage) + j + 1) + " " + usrStr, n(x.CurrencyAmount), true); + embed.AddField("#" + ((9 * curPage) + j + 1) + " " + usrStr, N(x.CurrencyAmount), true); } return embed; @@ -668,7 +668,6 @@ public partial class Gambling : GamblingModule [Cmd] public async partial Task Rps(RpsPick pick, ShmartNumber amount = default) { - long oldAmount = amount; if (!await CheckBetOptional(amount) || amount == 1) return; @@ -714,13 +713,12 @@ public partial class Gambling : GamblingModule amount = (long)(amount * Config.BetFlip.Multiplier); await _cs.AddAsync(ctx.User.Id, amount, new("rps", "win")); embed.WithOkColor(); - embed.AddField(GetText(strs.won), n(amount)); + embed.AddField(GetText(strs.won), N(amount)); msg = GetText(strs.rps_win(ctx.User.Mention, GetRpsPick(pick), GetRpsPick(nadekoPick))); } else { embed.WithErrorColor(); - amount = 0; msg = GetText(strs.rps_win(ctx.Client.CurrentUser.Mention, GetRpsPick(nadekoPick), GetRpsPick(pick))); } diff --git a/src/NadekoBot/Modules/Gambling/PlantPick/PlantPickService.cs b/src/NadekoBot/Modules/Gambling/PlantPick/PlantPickService.cs index b8dd98d88..cb0ef3d4f 100644 --- a/src/NadekoBot/Modules/Gambling/PlantPick/PlantPickService.cs +++ b/src/NadekoBot/Modules/Gambling/PlantPick/PlantPickService.cs @@ -112,7 +112,7 @@ public class PlantPickService : INService if (string.IsNullOrWhiteSpace(pass)) { // determine the extension - using (var img = Image.Load(curImg, out var format)) + using (_ = Image.Load(curImg, out var format)) { extension = format.FileExtensions.FirstOrDefault() ?? "png"; } diff --git a/src/NadekoBot/Modules/Gambling/Shop/ShopCommands.cs b/src/NadekoBot/Modules/Gambling/Shop/ShopCommands.cs index d353d96c9..77474c5c1 100644 --- a/src/NadekoBot/Modules/Gambling/Shop/ShopCommands.cs +++ b/src/NadekoBot/Modules/Gambling/Shop/ShopCommands.cs @@ -282,8 +282,11 @@ public partial class Gambling .ShopEntries); entry = entries.ElementAtOrDefault(index); if (entry is not null && (rightType = entry.Type == ShopEntryType.List)) - if (added = entry.Items.Add(item)) + if (entry.Items.Add(item)) + { + added = true; uow.SaveChanges(); + } } if (entry is null) diff --git a/src/NadekoBot/Modules/Gambling/Waifus/WaifuClaimCommands.cs b/src/NadekoBot/Modules/Gambling/Waifus/WaifuClaimCommands.cs index 77b9dc16f..9f11b182f 100644 --- a/src/NadekoBot/Modules/Gambling/Waifus/WaifuClaimCommands.cs +++ b/src/NadekoBot/Modules/Gambling/Waifus/WaifuClaimCommands.cs @@ -189,9 +189,9 @@ public partial class Gambling if (page > 100) page = 100; - var waifus = _service.GetTopWaifusAtPage(page); + var waifus = _service.GetTopWaifusAtPage(page).ToList(); - if (waifus.Count() == 0) + if (waifus.Count == 0) { await ReplyConfirmLocalizedAsync(strs.waifus_none); return; diff --git a/src/NadekoBot/Modules/Gambling/~Shared/Decks/Deck.cs b/src/NadekoBot/Modules/Gambling/~Shared/Decks/Deck.cs index fd7ec8dd0..977f54ef9 100644 --- a/src/NadekoBot/Modules/Gambling/~Shared/Decks/Deck.cs +++ b/src/NadekoBot/Modules/Gambling/~Shared/Decks/Deck.cs @@ -130,7 +130,7 @@ public class Deck var toReturn = cards.Max(card => card.Number) - cards.Min(card => card.Number) == 4; if (toReturn || cards.All(c => c.Number != 1)) return toReturn; - var newCards = cards.Select(c => c.Number == 1 ? new(c.Suit, 14) : c); + var newCards = cards.Select(c => c.Number == 1 ? new(c.Suit, 14) : c).ToArray(); return newCards.Max(card => card.Number) - newCards.Min(card => card.Number) == 4; } diff --git a/src/NadekoBot/Modules/Games/GirlRating.cs b/src/NadekoBot/Modules/Games/GirlRating.cs index 163a39863..05e38eec7 100644 --- a/src/NadekoBot/Modules/Games/GirlRating.cs +++ b/src/NadekoBot/Modules/Games/GirlRating.cs @@ -48,15 +48,6 @@ public class GirlRating var imgStream = new MemoryStream(); img.SaveAsPng(imgStream); return imgStream; - //using (var byteContent = new ByteArrayContent(imgStream.ToArray())) - //{ - // http.AddFakeHeaders(); - - // using (var reponse = await http.PutAsync("https://transfer.sh/img.png", byteContent)) - // { - // url = await reponse.Content.ReadAsStringAsync(); - // } - //} } catch (Exception ex) { diff --git a/src/NadekoBot/Modules/Games/Nunchi/Nunchi.cs b/src/NadekoBot/Modules/Games/Nunchi/Nunchi.cs index 4f7763dd9..af7835c16 100644 --- a/src/NadekoBot/Modules/Games/Nunchi/Nunchi.cs +++ b/src/NadekoBot/Modules/Games/Nunchi/Nunchi.cs @@ -154,21 +154,21 @@ public sealed class NunchiGame : IDisposable if (failure is not null) participants.Remove(failure.Value); // remove the dude who failed from the list of players - var __ = OnRoundEnded?.Invoke(this, failure); + _ = OnRoundEnded?.Invoke(this, failure); if (participants.Count <= 1) // means we have a winner or everyone was booted out { killTimer.Change(Timeout.Infinite, Timeout.Infinite); CurrentPhase = Phase.Ended; - _= OnGameEnded?.Invoke(this, participants.Count > 0 ? participants.First().Name : null); + _ = OnGameEnded?.Invoke(this, participants.Count > 0 ? participants.First().Name : null); return; } CurrentPhase = Phase.WaitingForNextRound; - var throwawayDelay = Task.Run(async () => + Task.Run(async () => { await Task.Delay(NEXT_ROUND_TIMEOUT); CurrentPhase = Phase.Playing; - var ___ = OnRoundStarted?.Invoke(this, CurrentNumber); + _ = OnRoundStarted?.Invoke(this, CurrentNumber); }); } diff --git a/src/NadekoBot/Modules/Games/Polls/PollCommands.cs b/src/NadekoBot/Modules/Games/Polls/PollCommands.cs index 3efef1469..1b1e77bd7 100644 --- a/src/NadekoBot/Modules/Games/Polls/PollCommands.cs +++ b/src/NadekoBot/Modules/Games/Polls/PollCommands.cs @@ -59,8 +59,6 @@ public partial class Games [RequireContext(ContextType.Guild)] public async partial Task Pollend() { - var channel = (ITextChannel)ctx.Channel; - Poll p; if ((p = _service.StopPoll(ctx.Guild.Id)) is null) return; diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs index 25af56c9b..3ebffafad 100644 --- a/src/NadekoBot/Modules/Music/Music.cs +++ b/src/NadekoBot/Modules/Music/Music.cs @@ -337,7 +337,7 @@ public sealed partial class Music : NadekoModule var videos = await _service.SearchVideosAsync(query); - if (videos is null || videos.Count == 0) + if (videos.Count == 0) { await ReplyErrorLocalizedAsync(strs.song_not_found); return; diff --git a/src/NadekoBot/Modules/Music/_Common/Impl/MusicPlayer.cs b/src/NadekoBot/Modules/Music/_Common/Impl/MusicPlayer.cs index d939bb1d3..d64d108f0 100644 --- a/src/NadekoBot/Modules/Music/_Common/Impl/MusicPlayer.cs +++ b/src/NadekoBot/Modules/Music/_Common/Impl/MusicPlayer.cs @@ -1,5 +1,4 @@ using Ayu.Discord.Voice; -using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Services.Database.Models; using System.ComponentModel; using System.Diagnostics; @@ -291,10 +290,10 @@ public sealed class MusicPlayer : IMusicPlayer private void HandleQueuePostTrack() { - if (this.forceIndex is { } forceIndex) + if (forceIndex is { } index) { - _queue.SetIndex(forceIndex); - this.forceIndex = null; + _queue.SetIndex(index); + forceIndex = null; return; } diff --git a/src/NadekoBot/Modules/Nsfw/SearchImageCacher.cs b/src/NadekoBot/Modules/Nsfw/SearchImageCacher.cs index 7c2d498da..13d4e2998 100644 --- a/src/NadekoBot/Modules/Nsfw/SearchImageCacher.cs +++ b/src/NadekoBot/Modules/Nsfw/SearchImageCacher.cs @@ -107,7 +107,6 @@ public class SearchImageCacher : INService private ImageData QueryLocal( string[] tags, - bool forceExplicit, Booru type, HashSet blacklistedTags) { @@ -194,7 +193,7 @@ public class SearchImageCacher : INService return default; // query for an image - var image = QueryLocal(tags, forceExplicit, type, blacklistedTags); + var image = QueryLocal(tags, type, blacklistedTags); if (image is not null) return image; @@ -211,7 +210,7 @@ public class SearchImageCacher : INService if (!success) return default; - image = QueryLocal(tags, forceExplicit, type, blacklistedTags); + image = QueryLocal(tags, type, blacklistedTags); return image; } diff --git a/src/NadekoBot/Modules/Nsfw/SearchImagesService.cs b/src/NadekoBot/Modules/Nsfw/SearchImagesService.cs index 3a527a2d7..b8e0cafc8 100644 --- a/src/NadekoBot/Modules/Nsfw/SearchImagesService.cs +++ b/src/NadekoBot/Modules/Nsfw/SearchImagesService.cs @@ -53,7 +53,7 @@ public class SearchImagesService : ISearchImagesService, INService using var uow = db.GetDbContext(); BlacklistedTags = new(uow.NsfwBlacklistedTags.AsEnumerable() .GroupBy(x => x.GuildId) - .ToDictionary(x => x.Key, x => new HashSet(x.Select(x => x.Tag)))); + .ToDictionary(x => x.Key, x => new HashSet(x.Select(y => y.Tag)))); } private Task GetNsfwImageAsync( diff --git a/src/NadekoBot/Modules/Searches/MemegenCommands.cs b/src/NadekoBot/Modules/Searches/MemegenCommands.cs index f3f2eec0b..2791c7b2d 100644 --- a/src/NadekoBot/Modules/Searches/MemegenCommands.cs +++ b/src/NadekoBot/Modules/Searches/MemegenCommands.cs @@ -38,7 +38,7 @@ public partial class Searches var rawJson = await res.Content.ReadAsStringAsync(); - var data = JsonConvert.DeserializeObject>(rawJson); + var data = JsonConvert.DeserializeObject>(rawJson)!; await ctx.SendPaginatedConfirmAsync(page, curPage => diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 30a0cecc4..ae229e576 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -520,16 +520,16 @@ public partial class Searches : NadekoModule await ctx.SendPaginatedConfirmAsync(0, page => { - var data = col.Skip(page).First(); + var model = col.Skip(page).First(); var embed = _eb.Create() .WithDescription(ctx.User.Mention) - .AddField(GetText(strs.word), data.Word, true) - .AddField(GetText(strs._class), data.WordType, true) - .AddField(GetText(strs.definition), data.Definition) + .AddField(GetText(strs.word), model.Word, true) + .AddField(GetText(strs._class), model.WordType, true) + .AddField(GetText(strs.definition), model.Definition) .WithOkColor(); - if (!string.IsNullOrWhiteSpace(data.Example)) - embed.AddField(GetText(strs.example), data.Example); + if (!string.IsNullOrWhiteSpace(model.Example)) + embed.AddField(GetText(strs.example), model.Example); return embed; }, diff --git a/src/NadekoBot/Modules/Searches/SearchesService.cs b/src/NadekoBot/Modules/Searches/SearchesService.cs index 998086476..5c2dbbd10 100644 --- a/src/NadekoBot/Modules/Searches/SearchesService.cs +++ b/src/NadekoBot/Modules/Searches/SearchesService.cs @@ -229,6 +229,7 @@ public class SearchesService : INService + $"&by=position" + $"&lat={geoData.Lat}" + $"&lng={geoData.Lon}"); + using var geoRes = await http.SendAsync(req); var resString = await geoRes.Content.ReadAsStringAsync(); var timeObj = JsonConvert.DeserializeObject(resString); diff --git a/src/NadekoBot/NadekoBot.csproj b/src/NadekoBot/NadekoBot.csproj index 788fb5d82..dbdf9119a 100644 --- a/src/NadekoBot/NadekoBot.csproj +++ b/src/NadekoBot/NadekoBot.csproj @@ -15,7 +15,7 @@ - + None CS1066 diff --git a/src/NadekoBot/Services/Currency/CurrencyService.cs b/src/NadekoBot/Services/Currency/CurrencyService.cs index 7f5488140..5d8322848 100644 --- a/src/NadekoBot/Services/Currency/CurrencyService.cs +++ b/src/NadekoBot/Services/Currency/CurrencyService.cs @@ -1,7 +1,6 @@ #nullable disable using LinqToDB; using NadekoBot.Services.Currency; -using NadekoBot.Services.Database.Models; namespace NadekoBot.Services; @@ -67,9 +66,6 @@ public class CurrencyService : ICurrencyService, INService throw new ArgumentOutOfRangeException(nameof(type)); } - private CurrencyTransaction GetCurrencyTransaction(ulong userId, string reason, long amount) - => new() { Amount = amount, UserId = userId, Note = reason ?? "-" }; - public async Task AddAsync( ulong userId, long amount,