diff --git a/src/NadekoBot/Modules/Gambling/Commands/CurrencyEvents.cs b/src/NadekoBot/Modules/Gambling/Commands/CurrencyEvents.cs index 02c8803e..4681d91b 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/CurrencyEvents.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/CurrencyEvents.cs @@ -19,7 +19,7 @@ namespace NadekoBot.Modules.Gambling public partial class Gambling { [Group] - public class CurrencyEvents : ModuleBase + public class CurrencyEvents : NadekoSubmodule { public enum CurrencyEvent { diff --git a/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs b/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs index 4616aa91..4bda25a4 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs @@ -17,7 +17,7 @@ namespace NadekoBot.Modules.Gambling public partial class Gambling { [Group] - public class DriceRollCommands : ModuleBase + public class DriceRollCommands : NadekoSubmodule { private Regex dndRegex { get; } = new Regex(@"^(?\d+)d(?\d+)(?:\+(?\d+))?(?:\-(?\d+))?$", RegexOptions.Compiled); private Regex fudgeRegex { get; } = new Regex(@"^(?\d+)d(?:F|f)$", RegexOptions.Compiled); diff --git a/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs b/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs index adbe4913..b9ae375b 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs @@ -17,7 +17,7 @@ namespace NadekoBot.Modules.Gambling public partial class Gambling { [Group] - public class DrawCommands : ModuleBase + public class DrawCommands : NadekoSubmodule { private static readonly ConcurrentDictionary AllDecks = new ConcurrentDictionary(); diff --git a/src/NadekoBot/Modules/Gambling/Commands/FlipCoinCommand.cs b/src/NadekoBot/Modules/Gambling/Commands/FlipCoinCommand.cs index 6ccfe786..973bc90e 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/FlipCoinCommand.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/FlipCoinCommand.cs @@ -1,12 +1,10 @@ using Discord; using Discord.Commands; -using ImageSharp; using NadekoBot.Attributes; using NadekoBot.Extensions; using NadekoBot.Services; using System; using System.Collections.Generic; -using System.IO; using System.Threading.Tasks; using Image = ImageSharp.Image; @@ -15,7 +13,7 @@ namespace NadekoBot.Modules.Gambling public partial class Gambling { [Group] - public class FlipCoinCommands : ModuleBase + public class FlipCoinCommands : NadekoSubmodule { private readonly IImagesService _images; @@ -24,7 +22,7 @@ namespace NadekoBot.Modules.Gambling public FlipCoinCommands() { //todo DI in the future, can't atm - this._images = NadekoBot.Images; + _images = NadekoBot.Images; } [NadekoCommand, Usage, Description, Aliases] @@ -36,21 +34,21 @@ namespace NadekoBot.Modules.Gambling { using (var heads = _images.Heads.ToStream()) { - await Context.Channel.SendFileAsync(heads, "heads.jpg", $"{Context.User.Mention} flipped " + Format.Code("Heads") + ".").ConfigureAwait(false); + await Context.Channel.SendFileAsync(heads, "heads.jpg", Context.User.Mention + " " + GetText("flipped", Format.Bold(GetText("heads"))) + ".").ConfigureAwait(false); } } else { using (var tails = _images.Tails.ToStream()) { - await Context.Channel.SendFileAsync(tails, "tails.jpg", $"{Context.User.Mention} flipped " + Format.Code("Tails") + ".").ConfigureAwait(false); + await Context.Channel.SendFileAsync(tails, "tails.jpg", Context.User.Mention + " " + GetText("flipped", Format.Bold(GetText("tails"))) + ".").ConfigureAwait(false); } } return; } if (count > 10 || count < 1) { - await Context.Channel.SendErrorAsync("`Invalid number specified. You can flip 1 to 10 coins.`").ConfigureAwait(false); + await ReplyErrorLocalized("flip_invalid", 10).ConfigureAwait(false); return; } var imgs = new Image[count]; @@ -76,14 +74,13 @@ namespace NadekoBot.Modules.Gambling if (amount < NadekoBot.BotConfig.MinimumBetAmount) { - await Context.Channel.SendErrorAsync($"You can't bet less than {NadekoBot.BotConfig.MinimumBetAmount}{CurrencySign}.") - .ConfigureAwait(false); + await ReplyErrorLocalized("min_bet_limit", NadekoBot.BotConfig.MinimumBetAmount + CurrencySign).ConfigureAwait(false); return; } var removed = await CurrencyHandler.RemoveCurrencyAsync(Context.User, "Betflip Gamble", amount, false).ConfigureAwait(false); if (!removed) { - await Context.Channel.SendErrorAsync($"{Context.User.Mention} You don't have enough {CurrencyPluralName}.").ConfigureAwait(false); + await ReplyErrorLocalized("not_enough", CurrencyPluralName).ConfigureAwait(false); return; } //heads = true @@ -91,7 +88,7 @@ namespace NadekoBot.Modules.Gambling //todo this seems stinky, no time to look at it right now var isHeads = guessStr == "HEADS" || guessStr == "H"; - bool result = false; + var result = false; IEnumerable imageToSend; if (rng.Next(0, 2) == 1) { @@ -107,12 +104,12 @@ namespace NadekoBot.Modules.Gambling if (isHeads == result) { var toWin = (int)Math.Round(amount * NadekoBot.BotConfig.BetflipMultiplier); - str = $"{Context.User.Mention}`You guessed it!` You won {toWin}{CurrencySign}"; - await CurrencyHandler.AddCurrencyAsync(Context.User, "Betflip Gamble", toWin, false).ConfigureAwait(false); + str = Context.User.Mention + " " + GetText("flip_guess", toWin + CurrencySign); + await CurrencyHandler.AddCurrencyAsync(Context.User, GetText("betflip_gamble"), toWin, false).ConfigureAwait(false); } else { - str = $"{Context.User.Mention}`Better luck next time.`"; + str = Context.User.Mention + " " + GetText("better_luck"); } using (var toSend = imageToSend.ToStream()) { diff --git a/src/NadekoBot/Modules/Gambling/Commands/Slots.cs b/src/NadekoBot/Modules/Gambling/Commands/Slots.cs index bd977e9b..c298a9b4 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/Slots.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/Slots.cs @@ -5,7 +5,6 @@ using NadekoBot.Extensions; using NadekoBot.Services; using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Text; using System.Threading; @@ -16,12 +15,12 @@ namespace NadekoBot.Modules.Gambling public partial class Gambling { [Group] - public class Slots : ModuleBase + public class Slots : NadekoSubmodule { - private static int totalBet = 0; - private static int totalPaidOut = 0; + private static int _totalBet; + private static int _totalPaidOut; - const int alphaCutOut = byte.MaxValue / 3; + private const int _alphaCutOut = byte.MaxValue / 3; //here is a payout chart //https://lh6.googleusercontent.com/-i1hjAJy_kN4/UswKxmhrbPI/AAAAAAAAB1U/82wq_4ZZc-Y/DE6B0895-6FC1-48BE-AC4F-14D1B91AB75B.jpg @@ -31,14 +30,14 @@ namespace NadekoBot.Modules.Gambling public Slots() { - this._images = NadekoBot.Images; + _images = NadekoBot.Images; } public class SlotMachine { public const int MaxValue = 5; - static readonly List> winningCombos = new List>() + static readonly List> _winningCombos = new List>() { //three flowers (arr) => arr.All(a=>a==MaxValue) ? 30 : 0, @@ -53,14 +52,14 @@ namespace NadekoBot.Modules.Gambling public static SlotResult Pull() { var numbers = new int[3]; - for (int i = 0; i < numbers.Length; i++) + for (var i = 0; i < numbers.Length; i++) { numbers[i] = new NadekoRandom().Next(0, MaxValue + 1); } - int multi = 0; - for (int i = 0; i < winningCombos.Count; i++) + var multi = 0; + foreach (var t in _winningCombos) { - multi = winningCombos[i](numbers); + multi = t(numbers); if (multi != 0) break; } @@ -74,8 +73,8 @@ namespace NadekoBot.Modules.Gambling public int Multiplier { get; } public SlotResult(int[] nums, int multi) { - this.Numbers = nums; - this.Multiplier = multi; + Numbers = nums; + Multiplier = multi; } } } @@ -85,8 +84,8 @@ namespace NadekoBot.Modules.Gambling public async Task SlotStats() { //i remembered to not be a moron - var paid = totalPaidOut; - var bet = totalBet; + var paid = _totalPaidOut; + var bet = _totalBet; if (bet <= 0) bet = 1; @@ -130,33 +129,34 @@ namespace NadekoBot.Modules.Gambling footer: $"Total Bet: {tests * bet} | Payout: {payout * bet} | {payout * 1.0f / tests * 100}%"); } - static HashSet runningUsers = new HashSet(); + private static readonly HashSet _runningUsers = new HashSet(); [NadekoCommand, Usage, Description, Aliases] public async Task Slot(int amount = 0) { - if (!runningUsers.Add(Context.User.Id)) + if (!_runningUsers.Add(Context.User.Id)) return; try { if (amount < 1) { - await Context.Channel.SendErrorAsync($"You can't bet less than 1{NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false); + await ReplyErrorLocalized("min_bet_limit", 1 + CurrencySign).ConfigureAwait(false); return; } if (amount > 999) { - await Context.Channel.SendErrorAsync($"You can't bet more than 999{NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false); + GetText("slot_maxbet", 999 + CurrencySign); + await ReplyErrorLocalized("max_bet_limit", 999 + CurrencySign).ConfigureAwait(false); return; } if (!await CurrencyHandler.RemoveCurrencyAsync(Context.User, "Slot Machine", amount, false)) { - await Context.Channel.SendErrorAsync($"You don't have enough {NadekoBot.BotConfig.CurrencySign}.").ConfigureAwait(false); + await ReplyErrorLocalized("not_enough", CurrencySign).ConfigureAwait(false); return; } - Interlocked.Add(ref totalBet, amount); + Interlocked.Add(ref _totalBet, amount); using (var bgFileStream = NadekoBot.Images.SlotBackground.ToStream()) { var bgImage = new ImageSharp.Image(bgFileStream); @@ -179,7 +179,7 @@ namespace NadekoBot.Modules.Gambling var x = 95 + 142 * i + j; int y = 330 + k; var toSet = toAdd[j, k]; - if (toSet.A < alphaCutOut) + if (toSet.A < _alphaCutOut) continue; bgPixels[x, y] = toAdd[j, k]; } @@ -203,7 +203,7 @@ namespace NadekoBot.Modules.Gambling { for (int j = 0; j < pixels.Height; j++) { - if (pixels[i, j].A < alphaCutOut) + if (pixels[i, j].A < _alphaCutOut) continue; var x = 230 - n * 16 + i; bgPixels[x, 462 + j] = pixels[i, j]; @@ -228,7 +228,7 @@ namespace NadekoBot.Modules.Gambling { for (int j = 0; j < pixels.Height; j++) { - if (pixels[i, j].A < alphaCutOut) + if (pixels[i, j].A < _alphaCutOut) continue; var x = 395 - n * 16 + i; bgPixels[x, 462 + j] = pixels[i, j]; @@ -240,22 +240,22 @@ namespace NadekoBot.Modules.Gambling } while ((printAmount /= 10) != 0); } - var msg = "Better luck next time ^_^"; + var msg = GetText("better_luck"); if (result.Multiplier != 0) { await CurrencyHandler.AddCurrencyAsync(Context.User, $"Slot Machine x{result.Multiplier}", amount * result.Multiplier, false); - Interlocked.Add(ref totalPaidOut, amount * result.Multiplier); + Interlocked.Add(ref _totalPaidOut, amount * result.Multiplier); if (result.Multiplier == 1) - msg = $"A single {NadekoBot.BotConfig.CurrencySign}, x1 - Try again!"; + msg = GetText("slot_single", CurrencySign, 1); else if (result.Multiplier == 4) - msg = $"Good job! Two {NadekoBot.BotConfig.CurrencySign} - bet x4"; + msg = GetText("slot_two", CurrencySign, 4); else if (result.Multiplier == 10) - msg = "Wow! Lucky! Three of a kind! x10"; + msg = GetText("slot_three", 10); else if (result.Multiplier == 30) - msg = "WOAAHHHHHH!!! Congratulations!!! x30"; + msg = GetText("slot_jackpot", 30); } - await Context.Channel.SendFileAsync(bgImage.ToStream(), "result.png", Context.User.Mention + " " + msg + $"\n`Bet:`{amount} `Won:` {amount * result.Multiplier}{NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false); + await Context.Channel.SendFileAsync(bgImage.ToStream(), "result.png", Context.User.Mention + " " + msg + $"\n`{GetText("slot_bet")}:`{amount} `{GetText("slot_won")}:` {amount * result.Multiplier}{NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false); } } finally @@ -263,7 +263,7 @@ namespace NadekoBot.Modules.Gambling var _ = Task.Run(async () => { await Task.Delay(2000); - runningUsers.Remove(Context.User.Id); + _runningUsers.Remove(Context.User.Id); }); } } diff --git a/src/NadekoBot/Modules/Gambling/Commands/WaifuClaimCommands.cs b/src/NadekoBot/Modules/Gambling/Commands/WaifuClaimCommands.cs index 8c6cfcd5..6ff7695d 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/WaifuClaimCommands.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/WaifuClaimCommands.cs @@ -47,7 +47,7 @@ namespace NadekoBot.Modules.Gambling } [Group] - public class WaifuClaimCommands : ModuleBase + public class WaifuClaimCommands : NadekoSubmodule { private static ConcurrentDictionary _divorceCooldowns { get; } = new ConcurrentDictionary(); private static ConcurrentDictionary _affinityCooldowns { get; } = new ConcurrentDictionary(); diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index 6bcf5654..6650bee5 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -1,9 +1,9 @@ -using Discord; +using System; +using Discord; using Discord.Commands; using NadekoBot.Attributes; using NadekoBot.Extensions; using System.Linq; -using System.Text; using System.Threading.Tasks; using NadekoBot.Services; using NadekoBot.Services.Database.Models; @@ -42,7 +42,7 @@ namespace NadekoBot.Modules.Gambling var members = role.Members().Where(u => u.Status != UserStatus.Offline && u.Status != UserStatus.Unknown); var membersArray = members as IUser[] ?? members.ToArray(); var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)]; - await Context.Channel.SendConfirmAsync("🎟 Raffled user", $"**{usr.Username}#{usr.Discriminator}**", footer: $"ID: {usr.Id}").ConfigureAwait(false); + await Context.Channel.SendConfirmAsync("🎟 "+ GetText("raffled_user"), $"**{usr.Username}#{usr.Discriminator}**", footer: $"ID: {usr.Id}").ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] @@ -50,15 +50,14 @@ namespace NadekoBot.Modules.Gambling public async Task Cash([Remainder] IUser user = null) { user = user ?? Context.User; - - await Context.Channel.SendConfirmAsync($"{user.Username} has {GetCurrency(user.Id)} {CurrencySign}").ConfigureAwait(false); + await ReplyConfirmLocalized("has", Format.Bold(user.ToString()), $"{GetCurrency(user.Id)} {CurrencySign}").ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] [Priority(1)] public async Task Cash(ulong userId) { - await Context.Channel.SendConfirmAsync($"`{userId}` has {GetCurrency(userId)} {CurrencySign}").ConfigureAwait(false); + await ReplyConfirmLocalized("has", Format.Code(userId.ToString()), $"{GetCurrency(userId)} {CurrencySign}").ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] @@ -70,11 +69,12 @@ namespace NadekoBot.Modules.Gambling var success = await CurrencyHandler.RemoveCurrencyAsync((IGuildUser)Context.User, $"Gift to {receiver.Username} ({receiver.Id}).", amount, false).ConfigureAwait(false); if (!success) { - await Context.Channel.SendErrorAsync($"{Context.User.Mention} You don't have enough {CurrencyPluralName}.").ConfigureAwait(false); + await ReplyErrorLocalized("not_enough", CurrencyPluralName).ConfigureAwait(false); return; } await CurrencyHandler.AddCurrencyAsync(receiver, $"Gift from {Context.User.Username} ({Context.User.Id}).", amount, true).ConfigureAwait(false); - await Context.Channel.SendConfirmAsync($"{Context.User.Mention} gifted {amount}{CurrencySign} to {Format.Bold(receiver.ToString())}!").ConfigureAwait(false); + await ReplyConfirmLocalized("gifted", amount + CurrencySign, Format.Bold(receiver.ToString())) + .ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] @@ -93,8 +93,7 @@ namespace NadekoBot.Modules.Gambling return; await CurrencyHandler.AddCurrencyAsync(usrId, $"Awarded by bot owner. ({Context.User.Username}/{Context.User.Id})", amount).ConfigureAwait(false); - - await Context.Channel.SendConfirmAsync($"{Context.User.Mention} awarded {amount}{CurrencySign} to <@{usrId}>!").ConfigureAwait(false); + await ReplyConfirmLocalized("awarded", amount + CurrencySign, $"<@{usrId}>").ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] @@ -111,9 +110,10 @@ namespace NadekoBot.Modules.Gambling amount))) .ConfigureAwait(false); - await Context.Channel.SendConfirmAsync($"Awarded `{amount}` {CurrencyPluralName} to `{users.Count}` users from `{role.Name}` role.") - .ConfigureAwait(false); - + await ReplyConfirmLocalized("mass_award", + amount + CurrencySign, + Format.Bold(users.Count.ToString()), + Format.Bold(role.Name)).ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] @@ -125,9 +125,9 @@ namespace NadekoBot.Modules.Gambling return; if (await CurrencyHandler.RemoveCurrencyAsync(user, $"Taken by bot owner.({Context.User.Username}/{Context.User.Id})", amount, true).ConfigureAwait(false)) - await Context.Channel.SendConfirmAsync($"{Context.User.Mention} successfully took {amount} {(amount == 1 ? CurrencyName : CurrencyPluralName)} from {user}!").ConfigureAwait(false); + await ReplyConfirmLocalized("take", amount+CurrencySign, Format.Bold(user.ToString())).ConfigureAwait(false); else - await Context.Channel.SendErrorAsync($"{Context.User.Mention} was unable to take {amount} {(amount == 1 ? CurrencyName : CurrencyPluralName)} from {user} because the user doesn't have that much {CurrencyPluralName}!").ConfigureAwait(false); + await ReplyErrorLocalized("take_fail", amount + CurrencySign, Format.Bold(user.ToString()), CurrencyPluralName).ConfigureAwait(false); } @@ -139,9 +139,9 @@ namespace NadekoBot.Modules.Gambling return; if (await CurrencyHandler.RemoveCurrencyAsync(usrId, $"Taken by bot owner.({Context.User.Username}/{Context.User.Id})", amount).ConfigureAwait(false)) - await Context.Channel.SendConfirmAsync($"{Context.User.Mention} successfully took {amount} {(amount == 1 ? CurrencyName : CurrencyPluralName)} from <@{usrId}>!").ConfigureAwait(false); + await ReplyConfirmLocalized("take", amount + CurrencySign, $"<@{usrId}>").ConfigureAwait(false); else - await Context.Channel.SendErrorAsync($"{Context.User.Mention} was unable to take {amount} {(amount == 1 ? CurrencyName : CurrencyPluralName)} from `{usrId}` because the user doesn't have that much {CurrencyPluralName}!").ConfigureAwait(false); + await ReplyErrorLocalized("take_fail", amount + CurrencySign, Format.Code(usrId.ToString()), CurrencyPluralName).ConfigureAwait(false); } //[NadekoCommand, Usage, Description, Aliases] @@ -205,49 +205,48 @@ namespace NadekoBot.Modules.Gambling if (amount < 1) return; - long userFlowers; - using (var uow = DbHandler.UnitOfWork()) + if (!await CurrencyHandler.RemoveCurrencyAsync(Context.User, "Betroll Gamble", amount, false).ConfigureAwait(false)) { - userFlowers = uow.Currency.GetOrCreate(Context.User.Id).Amount; - } - - if (userFlowers < amount) - { - await Context.Channel.SendErrorAsync($"{Context.User.Mention} You don't have enough {CurrencyPluralName}. You only have {userFlowers}{CurrencySign}.").ConfigureAwait(false); + await ReplyErrorLocalized("not_enough", CurrencyPluralName).ConfigureAwait(false); return; } - await CurrencyHandler.RemoveCurrencyAsync(Context.User, "Betroll Gamble", amount, false).ConfigureAwait(false); - - var rng = new NadekoRandom().Next(0, 101); - var str = $"{Context.User.Mention} `You rolled {rng}.` "; - if (rng < 67) + var rnd = new NadekoRandom().Next(0, 101); + var str = Context.User.Mention + Format.Code(GetText("roll", rnd)); + if (rnd < 67) { - str += "Better luck next time."; - } - else if (rng < 91) - { - str += $"Congratulations! You won {amount * NadekoBot.BotConfig.Betroll67Multiplier}{CurrencySign} for rolling above 66"; - await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble", (int)(amount * NadekoBot.BotConfig.Betroll67Multiplier), false).ConfigureAwait(false); - } - else if (rng < 100) - { - str += $"Congratulations! You won {amount * NadekoBot.BotConfig.Betroll91Multiplier}{CurrencySign} for rolling above 90."; - await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble", (int)(amount * NadekoBot.BotConfig.Betroll91Multiplier), false).ConfigureAwait(false); + str += GetText("better_luck"); } else { - str += $"👑 Congratulations! You won {amount * NadekoBot.BotConfig.Betroll100Multiplier}{CurrencySign} for rolling **100**. 👑"; - await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble", (int)(amount * NadekoBot.BotConfig.Betroll100Multiplier), false).ConfigureAwait(false); + if (rnd < 91) + { + str += GetText("br_win", (amount * NadekoBot.BotConfig.Betroll67Multiplier) + CurrencySign, 66); + await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble", + (int) (amount * NadekoBot.BotConfig.Betroll67Multiplier), false).ConfigureAwait(false); + } + else if (rnd < 100) + { + str += GetText("br_win", (amount * NadekoBot.BotConfig.Betroll91Multiplier) + CurrencySign, 90); + await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble", + (int) (amount * NadekoBot.BotConfig.Betroll91Multiplier), false).ConfigureAwait(false); + } + else + { + str += GetText("br_win", (amount * NadekoBot.BotConfig.Betroll100Multiplier) + CurrencySign, 100) + " 👑"; + await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble", + (int) (amount * NadekoBot.BotConfig.Betroll100Multiplier), false).ConfigureAwait(false); + } } - + Console.WriteLine("started sending"); await Context.Channel.SendConfirmAsync(str).ConfigureAwait(false); + Console.WriteLine("done sending"); } [NadekoCommand, Usage, Description, Aliases] public async Task Leaderboard() { - var richest = new List(); + List richest; using (var uow = DbHandler.UnitOfWork()) { richest = uow.Currency.GetTopRichest(9).ToList(); @@ -255,22 +254,22 @@ namespace NadekoBot.Modules.Gambling if (!richest.Any()) return; - var embed = new EmbedBuilder() .WithOkColor() - .WithTitle(NadekoBot.BotConfig.CurrencySign + " Leaderboard"); + .WithTitle(NadekoBot.BotConfig.CurrencySign + " " + GetText("leaderboard")); for (var i = 0; i < richest.Count; i++) { var x = richest[i]; var usr = await Context.Guild.GetUserAsync(x.UserId).ConfigureAwait(false); - var usrStr = ""; - if (usr == null) - usrStr = x.UserId.ToString(); - else - usrStr = usr.Username?.TrimTo(20, true); + var usrStr = usr == null + ? x.UserId.ToString() + : usr.Username?.TrimTo(20, true); - embed.AddField(efb => efb.WithName("#" + (i + 1) + " " + usrStr).WithValue(x.Amount.ToString() + " " + NadekoBot.BotConfig.CurrencySign).WithIsInline(true)); + var j = i; + embed.AddField(efb => efb.WithName("#" + (j + 1) + " " + usrStr) + .WithValue(x.Amount.ToString() + " " + NadekoBot.BotConfig.CurrencySign) + .WithIsInline(true)); } await Context.Channel.EmbedAsync(embed).ConfigureAwait(false); diff --git a/src/NadekoBot/Modules/NadekoModule.cs b/src/NadekoBot/Modules/NadekoModule.cs index 9bb524ec..4c8d17d3 100644 --- a/src/NadekoBot/Modules/NadekoModule.cs +++ b/src/NadekoBot/Modules/NadekoModule.cs @@ -67,14 +67,26 @@ namespace NadekoBot.Modules if (string.IsNullOrWhiteSpace(text)) { LogManager.GetCurrentClassLogger().Warn(lowerModuleTypeName + "_" + key + " key is missing from " + cultureInfo + " response strings. PLEASE REPORT THIS."); - return NadekoBot.ResponsesResourceManager.GetString(lowerModuleTypeName + "_" + key, _usCultureInfo) ?? $"Error: dkey {lowerModuleTypeName + "_" + key} found!"; + text = NadekoBot.ResponsesResourceManager.GetString(lowerModuleTypeName + "_" + key, _usCultureInfo) ?? $"Error: dkey {lowerModuleTypeName + "_" + key} not found!"; + if (string.IsNullOrWhiteSpace(text)) + return "I cant tell if you command is executed, because there was an error printing out the response. Key '" + + lowerModuleTypeName + "_" + key + "' " + "is missing from resources. Please report this."; } return text; } - public static string GetTextStatic(string key, CultureInfo cultureInfo, string lowerModuleTypeName, params object[] replacements) + public static string GetTextStatic(string key, CultureInfo cultureInfo, string lowerModuleTypeName, + params object[] replacements) { - return string.Format(GetTextStatic(key, cultureInfo, lowerModuleTypeName), replacements); + try + { + return string.Format(GetTextStatic(key, cultureInfo, lowerModuleTypeName), replacements); + } + catch (FormatException) + { + return "I cant tell if you command is executed, because there was an error printing out the response. Key '" + + lowerModuleTypeName + "_" + key + "' " + "is not properly formatted. Please report this."; + } } protected string GetText(string key) => @@ -85,26 +97,26 @@ namespace NadekoBot.Modules public Task ErrorLocalized(string textKey, params object[] replacements) { - var text = GetText(textKey); - return Context.Channel.SendErrorAsync(string.Format(text, replacements)); + var text = GetText(textKey, replacements); + return Context.Channel.SendErrorAsync(text); } public Task ReplyErrorLocalized(string textKey, params object[] replacements) { - var text = GetText(textKey); - return Context.Channel.SendErrorAsync(Context.User.Mention + " " + string.Format(text, replacements)); + var text = GetText(textKey, replacements); + return Context.Channel.SendErrorAsync(Context.User.Mention + " " + text); } public Task ConfirmLocalized(string textKey, params object[] replacements) { - var text = GetText(textKey); - return Context.Channel.SendConfirmAsync(string.Format(text, replacements)); + var text = GetText(textKey, replacements); + return Context.Channel.SendConfirmAsync(text); } public Task ReplyConfirmLocalized(string textKey, params object[] replacements) { - var text = GetText(textKey); - return Context.Channel.SendConfirmAsync(Context.User.Mention + " " + string.Format(text, replacements)); + var text = GetText(textKey, replacements); + return Context.Channel.SendConfirmAsync(Context.User.Mention + " " + text); } } diff --git a/src/NadekoBot/NadekoBot.xproj.DotSettings b/src/NadekoBot/NadekoBot.xproj.DotSettings index ae4d5dac..3a1cb1b5 100644 --- a/src/NadekoBot/NadekoBot.xproj.DotSettings +++ b/src/NadekoBot/NadekoBot.xproj.DotSettings @@ -1,2 +1,3 @@  - True \ No newline at end of file + True + True \ No newline at end of file diff --git a/src/NadekoBot/Resources/ResponseStrings.Designer.cs b/src/NadekoBot/Resources/ResponseStrings.Designer.cs index d8db88cd..95a0be9a 100644 --- a/src/NadekoBot/Resources/ResponseStrings.Designer.cs +++ b/src/NadekoBot/Resources/ResponseStrings.Designer.cs @@ -2072,6 +2072,240 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to has awarded {0} to {1}. + /// + public static string gambling_awarded { + get { + return ResourceManager.GetString("gambling_awarded", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Betflip Gamble. + /// + public static string gambling_betflip_gamble { + get { + return ResourceManager.GetString("gambling_betflip_gamble", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Better luck next time ^_^. + /// + public static string gambling_better_luck { + get { + return ResourceManager.GetString("gambling_better_luck", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Congratulations! You won {0} for rolling above {1}. + /// + public static string gambling_br_win { + get { + return ResourceManager.GetString("gambling_br_win", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You guessed it! You won {0}. + /// + public static string gambling_flip_guess { + get { + return ResourceManager.GetString("gambling_flip_guess", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid number specified. You can flip 1 to {0} coins.. + /// + public static string gambling_flip_invalid { + get { + return ResourceManager.GetString("gambling_flip_invalid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to flipped {0}.. + /// + public static string gambling_flipped { + get { + return ResourceManager.GetString("gambling_flipped", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to has gifted {0} to {1}. + /// + public static string gambling_gifted { + get { + return ResourceManager.GetString("gambling_gifted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} has {1}. + /// + public static string gambling_has { + get { + return ResourceManager.GetString("gambling_has", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Heads. + /// + public static string gambling_heads { + get { + return ResourceManager.GetString("gambling_heads", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Leaderboard. + /// + public static string gambling_leaderboard { + get { + return ResourceManager.GetString("gambling_leaderboard", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Awarded {0} to {1} users from {2} role.. + /// + public static string gambling_mass_award { + get { + return ResourceManager.GetString("gambling_mass_award", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You can't bet more than {0}. + /// + public static string gambling_max_bet_limit { + get { + return ResourceManager.GetString("gambling_max_bet_limit", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You can't bet less than {0}. + /// + public static string gambling_min_bet_limit { + get { + return ResourceManager.GetString("gambling_min_bet_limit", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You don't have enough {0}. + /// + public static string gambling_not_enough { + get { + return ResourceManager.GetString("gambling_not_enough", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Raffled User. + /// + public static string gambling_raffled_user { + get { + return ResourceManager.GetString("gambling_raffled_user", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You rolled {0}.. + /// + public static string gambling_roll { + get { + return ResourceManager.GetString("gambling_roll", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bet. + /// + public static string gambling_slot_bet { + get { + return ResourceManager.GetString("gambling_slot_bet", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to WOAAHHHHHH!!! Congratulations!!! x{0}. + /// + public static string gambling_slot_jackpot { + get { + return ResourceManager.GetString("gambling_slot_jackpot", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A single {0}, x{1}. + /// + public static string gambling_slot_single { + get { + return ResourceManager.GetString("gambling_slot_single", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Wow! Lucky! Three of a kind! x{0}. + /// + public static string gambling_slot_three { + get { + return ResourceManager.GetString("gambling_slot_three", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Good job! Two {0} - bet x{1}. + /// + public static string gambling_slot_two { + get { + return ResourceManager.GetString("gambling_slot_two", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Won. + /// + public static string gambling_slot_won { + get { + return ResourceManager.GetString("gambling_slot_won", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Tails. + /// + public static string gambling_tails { + get { + return ResourceManager.GetString("gambling_tails", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to successfully took {0} from {1}. + /// + public static string gambling_take { + get { + return ResourceManager.GetString("gambling_take", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to was unable to take {0} from{1} because the user doesn't have that much {2}!. + /// + public static string gambling_take_fail { + get { + return ResourceManager.GetString("gambling_take_fail", resourceCulture); + } + } + /// /// Looks up a localized string similar to Back to ToC. /// diff --git a/src/NadekoBot/Resources/ResponseStrings.resx b/src/NadekoBot/Resources/ResponseStrings.resx index 7fabfa84..6fee14d7 100644 --- a/src/NadekoBot/Resources/ResponseStrings.resx +++ b/src/NadekoBot/Resources/ResponseStrings.resx @@ -870,6 +870,87 @@ Reason: {1} User Soft-Banned + + has awarded {0} to {1} + + + Betflip Gamble + + + Better luck next time ^_^ + + + Congratulations! You won {0} for rolling above {1} + + + flipped {0}. + User flipped tails. + + + You guessed it! You won {0} + + + Invalid number specified. You can flip 1 to {0} coins. + + + has gifted {0} to {1} + X has gifted 15 flowers to Y + + + {0} has {1} + X has Y flowers + + + Heads + + + Leaderboard + + + Awarded {0} to {1} users from {2} role. + + + You can't bet more than {0} + + + You can't bet less than {0} + + + You don't have enough {0} + + + Raffled User + + + You rolled {0}. + + + Bet + + + WOAAHHHHHH!!! Congratulations!!! x{0} + + + A single {0}, x{1} + + + Wow! Lucky! Three of a kind! x{0} + + + Good job! Two {0} - bet x{1} + + + Won + + + Tails + + + successfully took {0} from {1} + + + was unable to take {0} from{1} because the user doesn't have that much {2}! + Back to ToC