diff --git a/src/Nadeko.Common/ShmartNumber.cs b/src/Nadeko.Common/ShmartNumber.cs index dcfdbcc6b..1aa786318 100644 --- a/src/Nadeko.Common/ShmartNumber.cs +++ b/src/Nadeko.Common/ShmartNumber.cs @@ -1,4 +1,6 @@ -namespace Nadeko.Common; +using System.Numerics; + +namespace Nadeko.Common; public readonly struct ShmartNumber : IEquatable { diff --git a/src/NadekoBot/Modules/Gambling/Bank/BankCommands.cs b/src/NadekoBot/Modules/Gambling/Bank/BankCommands.cs index a8022939e..c96019950 100644 --- a/src/NadekoBot/Modules/Gambling/Bank/BankCommands.cs +++ b/src/NadekoBot/Modules/Gambling/Bank/BankCommands.cs @@ -29,7 +29,7 @@ public partial class Gambling if (await _bank.DepositAsync(ctx.User.Id, amount)) { - await ReplyConfirmLocalizedAsync(strs.bank_deposited(N(amount))); + await ReplyConfirmLocalizedAsync(strs.bank_deposited(N(amount.Value))); } else { @@ -45,7 +45,7 @@ public partial class Gambling if (await _bank.WithdrawAsync(ctx.User.Id, amount)) { - await ReplyConfirmLocalizedAsync(strs.bank_withdrew(N(amount))); + await ReplyConfirmLocalizedAsync(strs.bank_withdrew(N(amount.Amount))); } else { diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index 225ff59a8..b1b15acd1 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -435,7 +435,7 @@ public partial class Gambling : GamblingModule return; } - if (!await _cs.TransferAsync(_eb, ctx.User, receiver, amount, msg, N(amount))) + if (!await _cs.TransferAsync(_eb, ctx.User, receiver, amount, msg, N(amount.Value))) { await ReplyErrorLocalizedAsync(strs.not_enough(CurrencySign)); return; @@ -744,7 +744,7 @@ public partial class Gambling : GamblingModule await ctx.Channel.TriggerTypingAsync(); await _tracker.EnsureUsersDownloadedAsync(ctx.Guild); - var sg = (SocketGuild)ctx.Guild; + var sg = (SocketGuild)ctx.Guild!; cleanRichest = cleanRichest.Where(x => sg.GetUser(x.UserId) is not null).ToList(); } else @@ -920,10 +920,11 @@ public partial class Gambling : GamblingModule [OwnerOnly] public async Task BetTest() { - await SendConfirmAsync(GetText(strs.available_tests), - Enum.GetValues() - .Select(x => $"`{x}`") - .Join(", ")); + var values = Enum.GetValues() + .Select(x => $"`{x}`") + .Join(", "); + + await SendConfirmAsync(GetText(strs.available_tests), values); } [Cmd] diff --git a/src/NadekoBot/Modules/Gambling/GamblingTopLevelModule.cs b/src/NadekoBot/Modules/Gambling/GamblingTopLevelModule.cs index 2b7094faa..c1a53e779 100644 --- a/src/NadekoBot/Modules/Gambling/GamblingTopLevelModule.cs +++ b/src/NadekoBot/Modules/Gambling/GamblingTopLevelModule.cs @@ -1,6 +1,7 @@ #nullable disable using NadekoBot.Modules.Gambling.Services; using System.Globalization; +using System.Numerics; namespace NadekoBot.Modules.Gambling.Common; @@ -39,16 +40,12 @@ public abstract class GamblingModule : NadekoModule return true; } - public static string N(long cur, IFormatProvider format) + public static string N(T cur, IFormatProvider format) + where T : INumber => cur.ToString("C0", format); - - public static string N(decimal cur, IFormatProvider format) - => cur.ToString("C0", format); - - protected string N(long cur) - => N(cur, GetFlowersCiInternal()); - protected string N(decimal cur) + protected string N(T cur) + where T : INumber => N(cur, GetFlowersCiInternal()); protected IFormatProvider GetFlowersCiInternal()