Some refactorings - Updated editorconfig, removed some unused variables and parameters, updated some old thorwaway variable code, some general cleanup

This commit is contained in:
Kwoth
2022-02-01 13:51:07 +01:00
parent d31cfcc5a8
commit 7ee51332b0
20 changed files with 64 additions and 201 deletions

View File

@@ -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

View File

@@ -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.style = all_upper
dotnet_naming_rule.const_fields.severity = warning 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.severity = error
dotnet_naming_rule.class_should_be_pascal_case.symbols = class # 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.style = pascal_case
dotnet_naming_rule.struct_should_be_pascal_case.severity = error dotnet_naming_rule.struct_should_be_pascal_case.severity = error
dotnet_naming_rule.struct_should_be_pascal_case.symbols = struct 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.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i 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.severity = error
dotnet_naming_rule.types_should_be_pascal_case.symbols = types # 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.style = pascal_case
dotnet_naming_rule.enum_should_be_pascal_case.severity = error # 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.symbols = enum
dotnet_naming_rule.enum_should_be_pascal_case.style = pascal_case # 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.severity = error
dotnet_naming_rule.property_should_be_pascal_case.symbols = property # 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.style = pascal_case
dotnet_naming_rule.method_should_be_pascal_case.severity = error dotnet_naming_rule.method_should_be_pascal_case.severity = error
dotnet_naming_rule.method_should_be_pascal_case.symbols = method 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.symbols = async_method
dotnet_naming_rule.async_method_should_be_ends_with_async.style = ends_with_async 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.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.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.style = pascal_case
dotnet_naming_rule.local_variable_should_be_camel_case.severity = error dotnet_naming_rule.local_variable_should_be_camel_case.severity = error
dotnet_naming_rule.local_variable_should_be_camel_case.symbols = local_variable dotnet_naming_rule.local_variable_should_be_camel_case.symbols = local_variable

View File

@@ -40,7 +40,7 @@ public sealed class ShmartNumberTypeReader : NadekoTypeReader<ShmartNumber>
} }
catch (Exception) catch (Exception)
{ {
return ValueTask.FromResult(TypeReaderResult.FromError<Common.ShmartNumber>(CommandError.ParseFailed, $"Invalid input: {input}")); return ValueTask.FromResult(TypeReaderResult.FromError<ShmartNumber>(CommandError.ParseFailed, $"Invalid input: {input}"));
} }
} }

View File

@@ -64,7 +64,7 @@ public partial class Gambling : GamblingModule<GamblingService>
_configService = configService; _configService = configService;
} }
private string n(long cur) private string N(long cur)
{ {
var flowersCi = (CultureInfo)Culture.Clone(); var flowersCi = (CultureInfo)Culture.Clone();
flowersCi.NumberFormat.CurrencySymbol = CurrencySign; flowersCi.NumberFormat.CurrencySymbol = CurrencySign;
@@ -78,7 +78,7 @@ public partial class Gambling : GamblingModule<GamblingService>
{ {
var wallet = await _cs.GetWalletAsync(userId); var wallet = await _cs.GetWalletAsync(userId);
var bal = await wallet.GetBalance(); var bal = await wallet.GetBalance();
return n(bal); return N(bal);
} }
[Cmd] [Cmd]
@@ -99,7 +99,7 @@ public partial class Gambling : GamblingModule<GamblingService>
.AddField(GetText(strs.currency_one_percent), (onePercent * 100).ToString("F2") + "%") .AddField(GetText(strs.currency_one_percent), (onePercent * 100).ToString("F2") + "%")
.AddField(GetText(strs.currency_planted), (BigInteger)ec.Planted) .AddField(GetText(strs.currency_planted), (BigInteger)ec.Planted)
.AddField(GetText(strs.owned_waifus_total), (BigInteger)ec.Waifus + CurrencySign) .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), .AddField(GetText(strs.total),
((BigInteger)(ec.Cash + ec.Planted + ec.Waifus)).ToString("N", Culture) + CurrencySign) ((BigInteger)(ec.Cash + ec.Planted + ec.Waifus)).ToString("N", Culture) + CurrencySign)
.WithOkColor(); .WithOkColor();
@@ -127,7 +127,7 @@ public partial class Gambling : GamblingModule<GamblingService>
await _cs.AddAsync(ctx.User.Id, val, new("timely", "claim")); 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] [Cmd]
@@ -154,7 +154,7 @@ public partial class Gambling : GamblingModule<GamblingService>
if (amount == 0) if (amount == 0)
await ReplyConfirmLocalizedAsync(strs.timely_set_none); await ReplyConfirmLocalizedAsync(strs.timely_set_none);
else 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] [Cmd]
@@ -230,7 +230,7 @@ public partial class Gambling : GamblingModule<GamblingService>
var date = $"#{Format.Code(kwumId)} `〖{GetFormattedCurtrDate(tr)}〗`"; 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); var transactionString = GetHumanReadableTransaction(tr.Type, tr.Extra, tr.OtherId);
if(transactionString is not null) if(transactionString is not null)
sb.AppendLine(transactionString); sb.AppendLine(transactionString);
@@ -270,7 +270,7 @@ public partial class Gambling : GamblingModule<GamblingService>
eb.WithAuthor(ctx.User); eb.WithAuthor(ctx.User);
eb.WithTitle(GetText(strs.transaction)); eb.WithTitle(GetText(strs.transaction));
eb.WithDescription(new kwum(tr.Id).ToString()); 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("Type", tr.Type, true);
eb.AddField("Extra", tr.Extra, true); eb.AddField("Extra", tr.Extra, true);
@@ -332,7 +332,7 @@ public partial class Gambling : GamblingModule<GamblingService>
return; return;
} }
await ReplyConfirmLocalizedAsync(strs.gifted(n(amount), Format.Bold(receiver.ToString()))); await ReplyConfirmLocalizedAsync(strs.gifted(N(amount), Format.Bold(receiver.ToString())));
} }
[Cmd] [Cmd]
@@ -375,7 +375,7 @@ public partial class Gambling : GamblingModule<GamblingService>
amount, amount,
new TxData("award", ctx.User.ToString()!, msg, ctx.User.Id) 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] [Cmd]
@@ -393,7 +393,7 @@ public partial class Gambling : GamblingModule<GamblingService>
role.Name, role.Name,
ctx.User.Id)); ctx.User.Id));
await ReplyConfirmLocalizedAsync(strs.mass_award(n(amount), await ReplyConfirmLocalizedAsync(strs.mass_award(N(amount),
Format.Bold(users.Count.ToString()), Format.Bold(users.Count.ToString()),
Format.Bold(role.Name))); Format.Bold(role.Name)));
} }
@@ -413,7 +413,7 @@ public partial class Gambling : GamblingModule<GamblingService>
null, null,
ctx.User.Id)); ctx.User.Id));
await ReplyConfirmLocalizedAsync(strs.mass_take(n(amount), await ReplyConfirmLocalizedAsync(strs.mass_take(N(amount),
Format.Bold(users.Count.ToString()), Format.Bold(users.Count.ToString()),
Format.Bold(role.Name))); Format.Bold(role.Name)));
} }
@@ -433,9 +433,9 @@ public partial class Gambling : GamblingModule<GamblingService>
ctx.User.Id); ctx.User.Id);
if (await _cs.RemoveAsync(user.Id, amount, extra)) 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 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<GamblingService>
ctx.User.Id); ctx.User.Id);
if (await _cs.RemoveAsync(usrId, amount, extra)) if (await _cs.RemoveAsync(usrId, amount, extra))
await ReplyConfirmLocalizedAsync(strs.take(n(amount), $"<@{usrId}>")); await ReplyConfirmLocalizedAsync(strs.take(N(amount), $"<@{usrId}>"));
else 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] [Cmd]
@@ -502,7 +502,7 @@ public partial class Gambling : GamblingModule<GamblingService>
await ReplyConfirmLocalizedAsync(strs.roll_duel_challenge(Format.Bold(ctx.User.ToString()), await ReplyConfirmLocalizedAsync(strs.roll_duel_challenge(Format.Bold(ctx.User.ToString()),
Format.Bold(u.ToString()), Format.Bold(u.ToString()),
Format.Bold(n(amount)))); Format.Bold(N(amount))));
} }
async Task GameOnGameTick(RollDuelGame arg) async Task GameOnGameTick(RollDuelGame arg)
@@ -530,7 +530,7 @@ public partial class Gambling : GamblingModule<GamblingService>
if (reason == RollDuelGame.Reason.Normal) if (reason == RollDuelGame.Reason.Normal)
{ {
var winner = rdGame.Winner == rdGame.P1 ? ctx.User : u; 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); embed = embed.WithDescription(description);
@@ -572,7 +572,7 @@ public partial class Gambling : GamblingModule<GamblingService>
if (result.Multiplier > 0) if (result.Multiplier > 0)
{ {
var win = (long)(amount * result.Multiplier); 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")); await _cs.AddAsync(ctx.User, win, new("betroll", "win"));
} }
else else
@@ -655,7 +655,7 @@ public partial class Gambling : GamblingModule<GamblingService>
var usrStr = x.ToString().TrimTo(20, true); var usrStr = x.ToString().TrimTo(20, true);
var j = i; 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; return embed;
@@ -668,7 +668,6 @@ public partial class Gambling : GamblingModule<GamblingService>
[Cmd] [Cmd]
public async partial Task Rps(RpsPick pick, ShmartNumber amount = default) public async partial Task Rps(RpsPick pick, ShmartNumber amount = default)
{ {
long oldAmount = amount;
if (!await CheckBetOptional(amount) || amount == 1) if (!await CheckBetOptional(amount) || amount == 1)
return; return;
@@ -714,13 +713,12 @@ public partial class Gambling : GamblingModule<GamblingService>
amount = (long)(amount * Config.BetFlip.Multiplier); amount = (long)(amount * Config.BetFlip.Multiplier);
await _cs.AddAsync(ctx.User.Id, amount, new("rps", "win")); await _cs.AddAsync(ctx.User.Id, amount, new("rps", "win"));
embed.WithOkColor(); 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))); msg = GetText(strs.rps_win(ctx.User.Mention, GetRpsPick(pick), GetRpsPick(nadekoPick)));
} }
else else
{ {
embed.WithErrorColor(); embed.WithErrorColor();
amount = 0;
msg = GetText(strs.rps_win(ctx.Client.CurrentUser.Mention, GetRpsPick(nadekoPick), GetRpsPick(pick))); msg = GetText(strs.rps_win(ctx.Client.CurrentUser.Mention, GetRpsPick(nadekoPick), GetRpsPick(pick)));
} }

View File

@@ -112,7 +112,7 @@ public class PlantPickService : INService
if (string.IsNullOrWhiteSpace(pass)) if (string.IsNullOrWhiteSpace(pass))
{ {
// determine the extension // determine the extension
using (var img = Image.Load(curImg, out var format)) using (_ = Image.Load(curImg, out var format))
{ {
extension = format.FileExtensions.FirstOrDefault() ?? "png"; extension = format.FileExtensions.FirstOrDefault() ?? "png";
} }

View File

@@ -282,8 +282,11 @@ public partial class Gambling
.ShopEntries); .ShopEntries);
entry = entries.ElementAtOrDefault(index); entry = entries.ElementAtOrDefault(index);
if (entry is not null && (rightType = entry.Type == ShopEntryType.List)) 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(); uow.SaveChanges();
}
} }
if (entry is null) if (entry is null)

View File

@@ -189,9 +189,9 @@ public partial class Gambling
if (page > 100) if (page > 100)
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); await ReplyConfirmLocalizedAsync(strs.waifus_none);
return; return;

View File

@@ -130,7 +130,7 @@ public class Deck
var toReturn = cards.Max(card => card.Number) - cards.Min(card => card.Number) == 4; var toReturn = cards.Max(card => card.Number) - cards.Min(card => card.Number) == 4;
if (toReturn || cards.All(c => c.Number != 1)) return toReturn; 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; return newCards.Max(card => card.Number) - newCards.Min(card => card.Number) == 4;
} }

View File

@@ -48,15 +48,6 @@ public class GirlRating
var imgStream = new MemoryStream(); var imgStream = new MemoryStream();
img.SaveAsPng(imgStream); img.SaveAsPng(imgStream);
return 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) catch (Exception ex)
{ {

View File

@@ -154,21 +154,21 @@ public sealed class NunchiGame : IDisposable
if (failure is not null) if (failure is not null)
participants.Remove(failure.Value); // remove the dude who failed from the list of players 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 if (participants.Count <= 1) // means we have a winner or everyone was booted out
{ {
killTimer.Change(Timeout.Infinite, Timeout.Infinite); killTimer.Change(Timeout.Infinite, Timeout.Infinite);
CurrentPhase = Phase.Ended; CurrentPhase = Phase.Ended;
_= OnGameEnded?.Invoke(this, participants.Count > 0 ? participants.First().Name : null); _ = OnGameEnded?.Invoke(this, participants.Count > 0 ? participants.First().Name : null);
return; return;
} }
CurrentPhase = Phase.WaitingForNextRound; CurrentPhase = Phase.WaitingForNextRound;
var throwawayDelay = Task.Run(async () => Task.Run(async () =>
{ {
await Task.Delay(NEXT_ROUND_TIMEOUT); await Task.Delay(NEXT_ROUND_TIMEOUT);
CurrentPhase = Phase.Playing; CurrentPhase = Phase.Playing;
var ___ = OnRoundStarted?.Invoke(this, CurrentNumber); _ = OnRoundStarted?.Invoke(this, CurrentNumber);
}); });
} }

View File

@@ -59,8 +59,6 @@ public partial class Games
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async partial Task Pollend() public async partial Task Pollend()
{ {
var channel = (ITextChannel)ctx.Channel;
Poll p; Poll p;
if ((p = _service.StopPoll(ctx.Guild.Id)) is null) if ((p = _service.StopPoll(ctx.Guild.Id)) is null)
return; return;

View File

@@ -337,7 +337,7 @@ public sealed partial class Music : NadekoModule<IMusicService>
var videos = await _service.SearchVideosAsync(query); var videos = await _service.SearchVideosAsync(query);
if (videos is null || videos.Count == 0) if (videos.Count == 0)
{ {
await ReplyErrorLocalizedAsync(strs.song_not_found); await ReplyErrorLocalizedAsync(strs.song_not_found);
return; return;

View File

@@ -1,5 +1,4 @@
using Ayu.Discord.Voice; using Ayu.Discord.Voice;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
@@ -291,10 +290,10 @@ public sealed class MusicPlayer : IMusicPlayer
private void HandleQueuePostTrack() private void HandleQueuePostTrack()
{ {
if (this.forceIndex is { } forceIndex) if (forceIndex is { } index)
{ {
_queue.SetIndex(forceIndex); _queue.SetIndex(index);
this.forceIndex = null; forceIndex = null;
return; return;
} }

View File

@@ -107,7 +107,6 @@ public class SearchImageCacher : INService
private ImageData QueryLocal( private ImageData QueryLocal(
string[] tags, string[] tags,
bool forceExplicit,
Booru type, Booru type,
HashSet<string> blacklistedTags) HashSet<string> blacklistedTags)
{ {
@@ -194,7 +193,7 @@ public class SearchImageCacher : INService
return default; return default;
// query for an image // query for an image
var image = QueryLocal(tags, forceExplicit, type, blacklistedTags); var image = QueryLocal(tags, type, blacklistedTags);
if (image is not null) if (image is not null)
return image; return image;
@@ -211,7 +210,7 @@ public class SearchImageCacher : INService
if (!success) if (!success)
return default; return default;
image = QueryLocal(tags, forceExplicit, type, blacklistedTags); image = QueryLocal(tags, type, blacklistedTags);
return image; return image;
} }

View File

@@ -53,7 +53,7 @@ public class SearchImagesService : ISearchImagesService, INService
using var uow = db.GetDbContext(); using var uow = db.GetDbContext();
BlacklistedTags = new(uow.NsfwBlacklistedTags.AsEnumerable() BlacklistedTags = new(uow.NsfwBlacklistedTags.AsEnumerable()
.GroupBy(x => x.GuildId) .GroupBy(x => x.GuildId)
.ToDictionary(x => x.Key, x => new HashSet<string>(x.Select(x => x.Tag)))); .ToDictionary(x => x.Key, x => new HashSet<string>(x.Select(y => y.Tag))));
} }
private Task<UrlReply> GetNsfwImageAsync( private Task<UrlReply> GetNsfwImageAsync(

View File

@@ -38,7 +38,7 @@ public partial class Searches
var rawJson = await res.Content.ReadAsStringAsync(); var rawJson = await res.Content.ReadAsStringAsync();
var data = JsonConvert.DeserializeObject<List<MemegenTemplate>>(rawJson); var data = JsonConvert.DeserializeObject<List<MemegenTemplate>>(rawJson)!;
await ctx.SendPaginatedConfirmAsync(page, await ctx.SendPaginatedConfirmAsync(page,
curPage => curPage =>

View File

@@ -520,16 +520,16 @@ public partial class Searches : NadekoModule<SearchesService>
await ctx.SendPaginatedConfirmAsync(0, await ctx.SendPaginatedConfirmAsync(0,
page => page =>
{ {
var data = col.Skip(page).First(); var model = col.Skip(page).First();
var embed = _eb.Create() var embed = _eb.Create()
.WithDescription(ctx.User.Mention) .WithDescription(ctx.User.Mention)
.AddField(GetText(strs.word), data.Word, true) .AddField(GetText(strs.word), model.Word, true)
.AddField(GetText(strs._class), data.WordType, true) .AddField(GetText(strs._class), model.WordType, true)
.AddField(GetText(strs.definition), data.Definition) .AddField(GetText(strs.definition), model.Definition)
.WithOkColor(); .WithOkColor();
if (!string.IsNullOrWhiteSpace(data.Example)) if (!string.IsNullOrWhiteSpace(model.Example))
embed.AddField(GetText(strs.example), data.Example); embed.AddField(GetText(strs.example), model.Example);
return embed; return embed;
}, },

View File

@@ -229,6 +229,7 @@ public class SearchesService : INService
+ $"&by=position" + $"&by=position"
+ $"&lat={geoData.Lat}" + $"&lat={geoData.Lat}"
+ $"&lng={geoData.Lon}"); + $"&lng={geoData.Lon}");
using var geoRes = await http.SendAsync(req); using var geoRes = await http.SendAsync(req);
var resString = await geoRes.Content.ReadAsStringAsync(); var resString = await geoRes.Content.ReadAsStringAsync();
var timeObj = JsonConvert.DeserializeObject<TimeZoneResult>(resString); var timeObj = JsonConvert.DeserializeObject<TimeZoneResult>(resString);

View File

@@ -15,7 +15,7 @@
<!-- Analysis/Warnings --> <!-- Analysis/Warnings -->
<!-- <AnalysisMode>Recommended</AnalysisMode>--> <!-- <AnalysisMode>Recommended</AnalysisMode>-->
<!-- <AnalysisModeGlobalization>None</AnalysisModeGlobalization>--> <!-- <AnalysisModeGlobalization>None</AnalysisModeGlobalization>-->
<!-- <AnalysisModeNaming>None</AnalysisModeNaming> --> <AnalysisModeNaming>None</AnalysisModeNaming>
<NoWarn>CS1066</NoWarn> <NoWarn>CS1066</NoWarn>
</PropertyGroup> </PropertyGroup>

View File

@@ -1,7 +1,6 @@
#nullable disable #nullable disable
using LinqToDB; using LinqToDB;
using NadekoBot.Services.Currency; using NadekoBot.Services.Currency;
using NadekoBot.Services.Database.Models;
namespace NadekoBot.Services; namespace NadekoBot.Services;
@@ -67,9 +66,6 @@ public class CurrencyService : ICurrencyService, INService
throw new ArgumentOutOfRangeException(nameof(type)); 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( public async Task AddAsync(
ulong userId, ulong userId,
long amount, long amount,