public async Task GetCoinAmount([Summary("The @user you want to check. Leave blank to get your own balance")] DiscordGuildUser userT = null) { var user = userT?.GuildUser ?? (IGuildUser)Context.User; // We dont care if the user exists. So we take the easy way out var amount = _coinRepo.GetCoins(user.Id); await ReplyAsync("", embed : SimpleEmbed(Blue, $"💰 {(user.Id == Context.User.Id ? "You have" : $"{Formatter.UsernameDiscrim(user)} has")} {amount.ToString()} Sora Coins.") .Build()); }
public async Task RollDice(int bet, int side) { if (side < 1 || side > 6) { await ReplyFailureEmbed("Please choose a side between 1-6"); return; } if (bet <= 0) { await ReplyFailureEmbed("Please specify a bet larger than 0."); return; } var availableCoins = _coinRepository.GetCoins(Context.User.Id); if (bet > availableCoins) { await ReplyFailureEmbed( $"Please specify a bet smaller or equal to your total Sora coin amount ({availableCoins.ToString()} SC)."); return; } int roll = _rand.GetRandomNext(1, 7); bool won = roll == side; if (won) { await _coinRepository.GiveAmount(Context.User.Id, (uint)(bet * 5)); // *5 since we never take away the initial bet } else if (!await _coinRepository.TryTakeAmount(Context.User.Id, (uint)bet)) { await ReplyFailureEmbed("You didn't have enough Sora coins for the transfer. Try again"); return; } if (won) { await ReplyMoneyEmbed($"Congratulations! You won {(bet * 6).ToString()} Sora Coins!"); } else { await ReplyMoneyLostEmbed($"You lost :( The dice was {roll.ToString()}. Better luck next time!"); } }
public async Task OpenSpecialWaifuBox() { if (!_config.SpecialWaifuActive) { await ReplyFailureEmbed("There are no special waifus active right now :/"); return; } // Check user cash var sc = _coinRepo.GetCoins(Context.User.Id); if (sc < _WAIFU_BOX_SPECIAL_COST) { await ReplyFailureEmbed($"You don't have enough Sora Coins! You need {_WAIFU_BOX_SPECIAL_COST.ToString()} SC."); return; } var special = await _waifuService.GetRandomSpecialWaifu(Context.User.Id, _config.SpecialWaifuType).ConfigureAwait(false); if (special == null) { await ReplyFailureEmbed("You already have all the special waifus. Pls try again another time."); return; } List <Waifu> waifusUnboxed = new List <Waifu>(); waifusUnboxed.Add(special); int additional = _WAIFU_AMOUNT_IN_BOX - 1; for (int i = 0; i < additional; i++) { waifusUnboxed.Add(await _waifuService.GetRandomWaifu().ConfigureAwait(false)); } if (waifusUnboxed.Count != _WAIFU_AMOUNT_IN_BOX) { await ReplyFailureEmbed("There don't seem to be Waifus to unbox at the moment. Sorry :/"); return; } // Now lets try to give everything to the user before we continue doing anything else if (!await _waifuService.TryGiveWaifusToUser(Context.User.Id, waifusUnboxed, _WAIFU_BOX_SPECIAL_COST).ConfigureAwait(false)) { await ReplyFailureEmbed("Failed to give Waifus :( Please try again"); return; } // We gave him the waifus. Now we just have to tell him :) waifusUnboxed.Sort((x, y) => - x.Rarity.CompareTo(y.Rarity)); var eb = new EmbedBuilder() { Title = "Congrats! You've got some nice waifus", Description = $"You opened a {WaifuFormatter.GetRarityString(_config.SpecialWaifuType)} WaifuBox for {_WAIFU_BOX_SPECIAL_COST.ToString()} SC.", Footer = RequestedByFooter(Context.User), Color = Purple, ImageUrl = waifusUnboxed[0].ImageUrl }; foreach (var waifu in waifusUnboxed) { eb.AddField(x => { x.IsInline = true; x.Name = waifu.Name; x.Value = $"Rarity: {WaifuFormatter.GetRarityString(waifu.Rarity)}\n" + $"[Image Url]({waifu.ImageUrl})\n" + $"*ID: {waifu.Id}*"; }); } await ReplyAsync("", embed : eb.Build()); }