public static int ParseAmount(string sAmount, SocketGuildUser user) { int amount; if (sAmount.Equals("all", StringComparison.OrdinalIgnoreCase) || sAmount.Equals("aww", StringComparison.OrdinalIgnoreCase)) { return(BalanceDb.GetToasties(user.Id, user.Guild.Id)); } if (sAmount.Equals("half", StringComparison.OrdinalIgnoreCase)) { return(BalanceDb.GetToasties(user.Id, user.Guild.Id) / 2); } var div = sAmount.Split('/'); if (div.Length == 2) { try { double x = double.Parse(div[0]); double y = double.Parse(div[1]); if (x / y > 0 && x / y <= 1) { amount = (int)(BalanceDb.GetToasties(user.Id, user.Guild.Id) * x / y); return(amount); } } catch { } } if (!Int32.TryParse(sAmount, out amount)) { amount = -1; } return(amount == 0 ? -1 : amount); }
public async Task DailyCmd() { bool newDaily = false; Daily daily = DailyDb.GetDaily(Context.User.Id, Context.Guild.Id); if (daily == null) { daily = new Daily { UserId = Context.User.Id, GuildId = Context.Guild.Id, Date = 0 }; newDaily = true; } long timeNow = DateTimeOffset.Now.ToUnixTimeMilliseconds(); int ms = 72000000; if (PremiumDb.IsPremium(Context.User.Id, ProType.ProPlus)) { ms /= 2; } if ((daily.Date + ms) < timeNow) { if ((daily.Date + 172800000) < timeNow && !newDaily) { long mslate = timeNow - (daily.Date + 172800000); long dayslate = (mslate / (1000 * 60 * 60 * 24)) + 1; double multiplier = dayslate > 3 ? 0 : 1 - dayslate * 0.25; daily.Streak = (int)(daily.Streak * multiplier); await ReplyAsync($"You are **{dayslate}** days late to claim your daily. For every day missed, you lose 25% of your streak."); } daily.Streak++; daily.Date = timeNow; int amount = ToastieUtil.DailyAmount(daily.Streak); int tax = ToastieUtil.DailyTax(amount, BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id), BalanceDb.GetToasties(Context.Client.CurrentUser.Id, Context.Guild.Id), await BalanceDb.TotalToasties(Context.Guild.Id)); amount -= tax / 2; //int cap = Constants.dailycap; //amount = amount > cap ? cap : amount; await DailyDb.SetDaily(daily); await BalanceDb.AddToasties(Context.User.Id, amount, Context.Guild.Id); await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, tax, Context.Guild.Id); await Context.Channel.SendMessageAsync("", false, ToastieUtil.DailyGetEmbed(Context.User, daily.Streak, amount, BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id), Program.GetPrefix(Context)).Build()); } else { long wait = (daily.Date + ms - timeNow) / 1000; int hours = (int)wait / 3600; int minutes = (int)wait % 3600 / 60; int seconds = (int)wait % 60; await Context.Channel.SendMessageAsync("", false, ToastieUtil.DailyWaitEmbed(Context.User, hours, minutes, seconds, Program.GetPrefix(Context)).Build()); } }
public static async Task GameTimeout(SocketUser user, BlackjackGame game) { { EmbedBuilder eb = new EmbedBuilder(); var bot = game.Message.Author.Id; game.Stand(); if (game.SumHand(game.Hand) > 21) { await BalanceDb.AddToasties(bot, game.Toasties, game.Channel.Guild.Id); eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl()); eb.WithDescription("Your hand is a bust. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkRed); } else if (game.SumHand(game.Hand) > game.SumHand(game.Dealer) || game.SumHand(game.Dealer) > 21) { await BalanceDb.AddToasties(user.Id, game.Toasties * 2, game.Channel.Guild.Id); await BalanceDb.AddToasties(bot, -game.Toasties, game.Channel.Guild.Id); eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl()); eb.WithDescription("Your score is higher than Namiko's. You win `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.Gold); } else if (game.SumHand(game.Hand) == game.SumHand(game.Dealer)) { await BalanceDb.AddToasties(user.Id, game.Toasties, game.Channel.Guild.Id); eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl()); eb.WithDescription("Your score is tied with Namiko's. You get your " + ToastieUtil.RandomEmote() + " back!\n" + "Your balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkGreen); } else { await BalanceDb.AddToasties(bot, game.Toasties, game.Channel.Guild.Id); eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl()); eb.WithDescription("Namiko's score is higher. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkRed); } eb.AddField("Your hand (" + game.SumHand(game.Hand) + ")", HandToString(game.Hand, false), true); eb.AddField("Namiko's hand (" + game.SumHand(game.Dealer) + ")", HandToString(game.Dealer, false), true); await Send(game, eb); games.Remove(user); } }
public async Task SellWaifu([Remainder] string str = "") { var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(str, false, UserInventoryDb.GetWaifus(Context.User.Id, Context.Guild.Id)), this); //waifus existance if (waifu == null) { return; } int worth = WaifuUtil.GetSalePrice(waifu.Tier); var sell = new DialogueBoxOption(); sell.Action = async(IUserMessage message) => { if (!UserInventoryDb.OwnsWaifu(Context.User.Id, waifu, Context.Guild.Id)) { await message.ModifyAsync(x => { x.Embed = new EmbedBuilderPrepared(Context.User).WithDescription("You tried :star:").Build(); }); return; } try { await BalanceDb.AddToasties(Context.User.Id, worth, Context.Guild.Id); } catch (Exception ex) { await Context.Channel.SendMessageAsync(ex.Message); } //removing waifu + confirmation await UserInventoryDb.DeleteWaifu(Context.User.Id, waifu, Context.Guild.Id); await message.ModifyAsync(x => { x.Content = $"You sold **{waifu.Name}** for **{worth.ToString("n0")}** toasties."; x.Embed = ToastieUtil.ToastieEmbed(Context.User, BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id)).Build(); }); }; sell.After = OnExecute.RemoveReactions; var cancel = new DialogueBoxOption(); cancel.After = OnExecute.Delete; var dia = new DialogueBox(); dia.Options.Add(Emote.Parse("<:TickYes:577838859107303424>"), sell); dia.Options.Add(Emote.Parse("<:TickNo:577838859077943306>"), cancel); dia.Timeout = new TimeSpan(0, 1, 0); dia.Embed = new EmbedBuilder() .WithAuthor(Context.User) .WithColor(BasicUtil.RandomColor()) .WithDescription($"Sell **{waifu.Name}** for **{worth.ToString("n0")}** toasties?").Build(); await DialogueReplyAsync(dia); return; }
public async Task BlackjackCommand(string sAmount, [Remainder] string str = "") { var user = (SocketGuildUser)Context.User; var ch = (SocketTextChannel)Context.Channel; if (Blackjack.games.ContainsKey(Context.User)) { await Context.Channel.SendMessageAsync("You are already in a game of blackjack. #" + Blackjack.games[user].Channel.Name); return; } int amount = ToastieUtil.ParseAmount(sAmount, user); if (amount < 0) { await Context.Channel.SendMessageAsync("Pick an amount! number, all, half, or x/y."); return; } if (amount == 0) { await Context.Channel.SendMessageAsync("You have no toasties..."); return; } try { await BalanceDb.AddToasties(user.Id, -amount, Context.Guild.Id); } catch (Exception e) { await ch.SendMessageAsync(e.Message); return; } if (BalanceDb.GetToasties(Context.Client.CurrentUser.Id, Context.Guild.Id) < amount) { string prefix = Program.GetPrefix(Context); await Context.Channel.SendMessageAsync("Tch, I don't have enough toasties... I will recover eventually by stealing toasties from all of you. :fox:" + $"But if you want to speed up the process you can give me some using the `{prefix}give` or `{prefix}at` commands."); await BalanceDb.AddToasties(user.Id, amount, Context.Guild.Id); return; } BlackjackGame game = new BlackjackGame(amount, ch); Blackjack.games[user] = game; await Blackjack.GameContinue(Context, game); }
public async Task Weekly() { var weekly = WeeklyDb.GetWeekly(Context.User.Id, Context.Guild.Id); if (weekly == null) { weekly = new Weekly { GuildId = Context.Guild.Id, UserId = Context.User.Id }; } int hours = 164; if (PremiumDb.IsPremium(Context.Guild.Id, ProType.Guild) || PremiumDb.IsPremium(Context.Guild.Id, ProType.GuildPlus)) { hours /= 2; } if (weekly.Date.AddHours(hours).CompareTo(DateTime.Now) < 0) { int streak = await DailyDb.GetHighest(Context.Guild.Id) + 15; int amount = ToastieUtil.DailyAmount(streak); int tax = ToastieUtil.DailyTax(amount, BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id), BalanceDb.GetToasties(Context.Client.CurrentUser.Id, Context.Guild.Id), await BalanceDb.TotalToasties(Context.Guild.Id)); amount -= tax / 2; if (PremiumDb.IsPremium(Context.Guild.Id, ProType.GuildPlus)) { amount += 1000; } string text = ""; if (PremiumDb.IsPremium(Context.User.Id, ProType.ProPlus)) { await LootBoxDb.AddLootbox(Context.User.Id, LootBoxType.WaifuT1, 1, Context.Guild.Id); text = "You receive a T1 Waifu lootbox! :star2:"; } await BalanceDb.AddToasties(Context.User.Id, amount, Context.Guild.Id); await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, tax / 2, Context.Guild.Id); weekly.Date = DateTime.Now; await WeeklyDb.SetWeekly(weekly); await Context.Channel.SendMessageAsync(text, false, ToastieUtil.WeeklyGetEmbed(amount, BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id), Context.User, Program.GetPrefix(Context)).Build()); return; } await Context.Channel.SendMessageAsync("", false, ToastieUtil.WeeklyWaitEmbed(weekly.Date.AddHours(hours), Context.User, Program.GetPrefix(Context)).Build()); }
public static async Task GameEnd(SocketCommandContext Context, BlackjackGame game) { EmbedBuilder eb = new EmbedBuilder(); var user = Context.User; if (game.SumHand(game.Hand) > 21) { await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, game.Toasties, Context.Guild.Id); eb.WithAuthor(user.Username + " | You Lose", user.GetAvatarUrl()); eb.WithDescription("Your hand is a bust. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkRed); } else if (game.SumHand(game.Hand) > game.SumHand(game.Dealer) || game.SumHand(game.Dealer) > 21) { await BalanceDb.AddToasties(user.Id, game.Toasties * 2, Context.Guild.Id); await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, -game.Toasties, Context.Guild.Id); eb.WithAuthor(user.Username + " | You Win", user.GetAvatarUrl()); eb.WithDescription("Your score is higher than Namiko's. You win `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.Gold); } else if (game.SumHand(game.Hand) == game.SumHand(game.Dealer)) { await BalanceDb.AddToasties(user.Id, game.Toasties, Context.Guild.Id); eb.WithAuthor(user.Username + " | Tie", user.GetAvatarUrl()); eb.WithDescription("Your score is tied with Namiko's. You get your " + ToastieUtil.RandomEmote() + " back!\n" + "Your balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkGreen); } else { await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, game.Toasties, Context.Guild.Id); eb.WithAuthor(user.Username + " | You Lose", user.GetAvatarUrl()); eb.WithDescription("Namiko's score is higher. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote()); eb.WithColor(Color.DarkRed); } eb.AddField("Your hand (" + game.SumHand(game.Hand) + ")", HandToString(game.Hand, false), true); eb.AddField("Namiko's hand (" + game.SumHand(game.Dealer) + ")", HandToString(game.Dealer, false), true); await Send(game, eb); games.Remove(user); }
public static EmbedBuilder TeamEmbed(SocketRole teamRole, SocketRole leaderRole) { var eb = new EmbedBuilder(); List <SocketGuildUser> leaderUsers = new List <SocketGuildUser>(leaderRole.Members); List <SocketGuildUser> teamUsers = new List <SocketGuildUser>(teamRole.Members); teamUsers.RemoveAll(x => leaderUsers.Any(y => y.Equals(x))); int totalToasties = 0; int totalWaifus = 0; int totalWaifuValue = 0; string memberList = ""; foreach (var x in teamUsers) { memberList += $"\n`{x.Username}`"; totalToasties += BalanceDb.GetToasties(x.Id, x.Guild.Id); var waifus = UserInventoryDb.GetWaifus(x.Id, x.Guild.Id); totalWaifus += waifus.Count; totalWaifuValue += WaifuUtil.WaifuValue(waifus); } string leaderList = ""; foreach (var x in leaderUsers) { leaderList += $"\n`{x.Username}`"; totalToasties += BalanceDb.GetToasties(x.Id, x.Guild.Id); var waifus = UserInventoryDb.GetWaifus(x.Id, x.Guild.Id); totalWaifus += waifus.Count; totalWaifuValue += WaifuUtil.WaifuValue(waifus); } eb.WithDescription($"Total Toasties: {totalToasties.ToString("n0")} <:toastie3:454441133876183060>\n" + $"Total Waifus: {totalWaifus.ToString("n0")} :two_hearts:\n" + $"Waifu Value: {totalWaifuValue.ToString("n0")} <:toastie3:454441133876183060>"); eb.AddField($":shield: Members - {teamUsers.Count}", memberList == "" ? "-" : memberList, true); eb.AddField($":crown: Leaders - {leaderUsers.Count}", leaderList == "" ? "-" : leaderList, true); eb.WithColor(BasicUtil.RandomColor()); eb.WithTitle(teamRole.Name); return(eb); }
public static async Task Forfeit(SocketCommandContext Context, BlackjackGame game) { var user = Context.User; await BalanceDb.AddToasties(user.Id, game.Toasties / 2, Context.Guild.Id); await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, game.Toasties / 2, Context.Guild.Id); EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor(user.Username + " | You Lose", null, user.GetAvatarUrl()); eb.WithDescription("You forfeit. You get half your toasties back. Lost `" + game.Toasties / 2 + "`" + ToastieUtil.RandomEmote() + "\n" + "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "`" + ToastieUtil.RandomEmote()); eb.AddField("Your hand (" + game.SumHand(game.Hand) + ")", HandToString(game.Hand, false), true); eb.AddField("Namiko's hand (" + game.SumHand(game.Dealer) + ")", HandToString(game.Dealer, false), true); eb.WithColor(Color.DarkBlue); await Send(game, eb); games.Remove(user); }
public async Task Beg([Remainder] string str = "") { var amount = BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id); if (amount > 0) { await Context.Channel.SendMessageAsync("You already have toasties, you snob."); return; } if (!Constants.beg) { await Context.Channel.SendMessageAsync(ToastieUtil.GetFalseBegMessage()); return; } amount = Constants.begAmount; await BalanceDb.AddToasties(Context.User.Id, amount, Context.Guild.Id); await Context.Channel.SendMessageAsync("Fine. Just leave me alone.", false, ToastieUtil.GiveEmbed(Context.Client.CurrentUser, Context.User, amount).Build()); }
public async Task BulkOpen([Remainder] string str = "") { var boxes = await LootBoxDb.GetAll(Context.User.Id, Context.Guild.Id); if (boxes.Count == 0) { await Context.Channel.SendMessageAsync("", false, ToastieUtil.NoBoxEmbed(Context.User).Build()); return; } LootBox box = null; if (boxes.Count == 1) { box = boxes[0]; } else { var listMsg = await Context.Channel.SendMessageAsync(embed : ToastieUtil.BoxListEmbed(boxes, Context.User) .WithFooter("Times out in 23 seconds") .WithDescription("Enter the number of the Lootbox type you wish to open.") .Build()); var response = await NextMessageAsync( new Criteria <IMessage>() .AddCriterion(new EnsureSourceUserCriterion()) .AddCriterion(new EnsureSourceChannelCriterion()) .AddCriterion(new EnsureRangeCriterion(boxes.Count, Program.GetPrefix(Context))), new TimeSpan(0, 0, 23)); _ = listMsg.DeleteAsync(); int i = 0; try { i = int.Parse(response.Content); } catch { _ = Context.Message.DeleteAsync(); return; } _ = response.DeleteAsync(); box = boxes[i - 1]; } var type = LootboxStats.Lootboxes[box.Type]; var dialoague = await ReplyAsync(embed : new EmbedBuilderPrepared(Context.User).WithDescription($"How many {type.Emote} **{type.Name}** lootboxes do you wish to open?").Build()); var amountMsg = await NextMessageAsync( new Criteria <IMessage>() .AddCriterion(new EnsureSourceUserCriterion()) .AddCriterion(new EnsureSourceChannelCriterion()) .AddCriterion(new EnsureRangeCriterion(int.MaxValue, Program.GetPrefix(Context))), new TimeSpan(0, 0, 23)); int amount; try { amount = int.Parse(amountMsg.Content); } catch { _ = Context.Message.DeleteAsync(); return; } _ = dialoague.DeleteAsync(); try { await LootBoxDb.AddLootbox(Context.User.Id, box.Type, -amount, box.GuildId); } catch { await Context.Channel.SendMessageAsync("You tried."); return; } _ = amountMsg.DeleteAsync(); var msg = await Context.Channel.SendMessageAsync("", false, ToastieUtil.BoxOpeningEmbed(Context.User).Build()); await ProfileDb.IncrementLootboxOpened(Context.User.Id, amount); int waitms = 4200; int toasties = 0; var waifusFound = new List <Waifu>(); var waifus = UserInventoryDb.GetWaifus(Context.User.Id, Context.Guild.Id); bool isPremium = PremiumDb.IsPremium(Context.User.Id, ProType.Pro); for (int i = 0; i < amount; i++) { if (type.IsWaifu()) { var waifu = await ToastieUtil.UnboxWaifu(type, isPremium, Context.User.Id, Context.Guild.Id); while (waifu == null || waifus.Any(x => x.Name.Equals(waifu.Name)) || waifusFound.Any(x => x.Name.Equals(waifu.Name))) { waifu = await ToastieUtil.UnboxWaifu(type, isPremium, Context.User.Id, Context.Guild.Id); } waifusFound.Add(waifu); await UserInventoryDb.AddWaifu(Context.User.Id, waifu, Context.Guild.Id); } else { toasties += type.GetRandomToasties(); } } await BalanceDb.AddToasties(Context.User.Id, toasties, Context.Guild.Id); var bal = BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id); await Task.Delay(waitms); var eb = new EmbedBuilder() .WithAuthor($"{Context.User} | {box.Type.ToString()} x{amount}", Context.User.GetAvatarUrl(), LinkHelper.GetRedirectUrl(LinkHelper.Patreon, "Patreon", "cmd-embed-lootbox")) .WithColor(BasicUtil.RandomColor()) .WithThumbnailUrl("https://i.imgur.com/4JQmxa6.png"); string desc = $"You found **{toasties.ToString("n0")}** {ToastieUtil.RandomEmote()}!\nNow you have **{bal.ToString("n0")}** {ToastieUtil.RandomEmote()}!\n\n"; if (waifusFound.Any()) { desc += "**Waifus Found:**\n"; foreach (var w in waifusFound) { desc += $"`T{w.Tier}` **{w.Name}** - *{(w.Source.Length > 37 ? w.Source.Substring(0, 33) + "..." : w.Source)}*\n"; } } eb.WithDescription(desc.Length > 2000 ? desc.Substring(0, 1970) + "\n*And more...*" : desc); await msg.ModifyAsync(x => { x.Embed = eb.Build(); }); }
public async Task Open([Remainder] string str = "") { var boxes = await LootBoxDb.GetAll(Context.User.Id, Context.Guild.Id); if (boxes.Count == 0) { await Context.Channel.SendMessageAsync("", false, ToastieUtil.NoBoxEmbed(Context.User).Build()); return; } LootBox box = null; if (boxes.Count == 1) { box = boxes[0]; } else { var listMsg = await Context.Channel.SendMessageAsync(embed : ToastieUtil.BoxListEmbed(boxes, Context.User) .WithFooter("Times out in 23 seconds") .WithDescription("Enter the number of the Lootbox you wish to open.") .Build()); var response = await NextMessageAsync( new Criteria <IMessage>() .AddCriterion(new EnsureSourceUserCriterion()) .AddCriterion(new EnsureSourceChannelCriterion()) .AddCriterion(new EnsureRangeCriterion(boxes.Count, Program.GetPrefix(Context))), new TimeSpan(0, 0, 23)); _ = listMsg.DeleteAsync(); int i = 0; try { i = int.Parse(response.Content); } catch { _ = Context.Message.DeleteAsync(); return; } _ = response.DeleteAsync(); box = boxes[i - 1]; } var type = LootboxStats.Lootboxes[box.Type]; try { await LootBoxDb.AddLootbox(Context.User.Id, box.Type, -1, box.GuildId); } catch { await Context.Channel.SendMessageAsync("You tried."); return; } var msg = await Context.Channel.SendMessageAsync("", false, ToastieUtil.BoxOpeningEmbed(Context.User).Build()); await ProfileDb.IncrementLootboxOpened(Context.User.Id); int waitms = 4200; if (type.IsWaifu()) { bool isPremium = PremiumDb.IsPremium(Context.User.Id, ProType.Pro); var waifu = await ToastieUtil.UnboxWaifu(type, isPremium, Context.User.Id, Context.Guild.Id); while (UserInventoryDb.OwnsWaifu(Context.User.Id, waifu, Context.Guild.Id)) { waifu = await ToastieUtil.UnboxWaifu(type, isPremium, Context.User.Id, Context.Guild.Id); } await UserInventoryDb.AddWaifu(Context.User.Id, waifu, Context.Guild.Id); await Task.Delay(waitms); var embed = WaifuUtil.WaifuEmbedBuilder(waifu, Context).Build(); await msg.ModifyAsync(x => { x.Embed = embed; x.Content = $"{Context.User.Mention} Congratulations! You found **{waifu.Name}**!"; }); return; } var amountWon = type.GetRandomToasties(); await BalanceDb.AddToasties(Context.User.Id, amountWon, Context.Guild.Id); var bal = BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id); await Task.Delay(waitms); await msg.ModifyAsync(x => { x.Embed = new EmbedBuilder() .WithAuthor($"{Context.User} | {box.Type.ToString()}", Context.User.GetAvatarUrl(), LinkHelper.GetRedirectUrl(LinkHelper.Patreon, "Patreon", "cmd-embed-lootbox")) .WithColor(BasicUtil.RandomColor()) .WithThumbnailUrl("https://i.imgur.com/4JQmxa6.png") .WithDescription($"Congratulations! You found **{amountWon.ToString("n0")}** {ToastieUtil.RandomEmote()}!\nNow you have **{bal.ToString("n0")}** {ToastieUtil.RandomEmote()}!") .Build(); }); }
public async Task Add(IUser user, int amount, [Remainder] string str = "") { await BalanceDb.AddToasties(user.Id, amount, Context.Guild.Id); await Context.Channel.SendMessageAsync("", false, ToastieUtil.ToastieEmbed(user, BalanceDb.GetToasties(user.Id, Context.Guild.Id)).Build()); }
public async Task Toastie([Remainder] IUser user = null) { if (user == null) { user = Context.User; } await Context.Channel.SendMessageAsync("", false, ToastieUtil.ToastieEmbed(user, BalanceDb.GetToasties(user.Id, Context.Guild.Id)).Build()); }
public async Task Flip(string sAmount, string side = "t", [Remainder] string str = "") { var user = (SocketGuildUser)Context.User; var rnd = new Random(); side = side.ToLower(); if (!(side.Equals("t") || side.Equals("h") || side.Equals("tails") || side.Equals("heads"))) { await Context.Channel.SendMessageAsync("Pick heads or tails!"); return; } int amount = ToastieUtil.ParseAmount(sAmount, user); if (amount < 0) { await Context.Channel.SendMessageAsync("Pick an amount! number, all, half, or x/y."); return; } if (amount == 0) { await Context.Channel.SendMessageAsync("You have no toasties..."); return; } try { await BalanceDb.AddToasties(user.Id, -amount, Context.Guild.Id); } catch (Exception ex) { await Context.Channel.SendMessageAsync(ex.Message); return; } if (BalanceDb.GetToasties(Context.Client.CurrentUser.Id, Context.Guild.Id) < amount) { string prefix = Program.GetPrefix(Context); await Context.Channel.SendMessageAsync("Tch, I don't have enough toasties... I will recover eventually by stealing toasties from all of you. :fox:" + $"But if you want to speed up the process you can give me some using the `{prefix}give` or `{prefix}at` commands."); await BalanceDb.AddToasties(user.Id, amount, Context.Guild.Id); return; } if (ToastieUtil.FiftyFifty()) { await BalanceDb.AddToasties(user.Id, amount * 2, Context.Guild.Id); await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, -amount, Context.Guild.Id); string resp = ""; if (amount >= 50000 && rnd.Next(5) == 1) { resp = "Tch... I'll get you next time."; } await Context.Channel.SendMessageAsync(resp, false, ToastieUtil.FlipWinEmbed(user, amount).Build()); } else { await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, amount, Context.Guild.Id); string resp = ""; if (amount >= 50000 && rnd.Next(5) == 1) { resp = "I'll take those."; } await Context.Channel.SendMessageAsync(resp, false, ToastieUtil.FlipLoseEmbed(user, amount).Build()); } }
// Embeds //Embed Method: profile public static async Task <EmbedBuilder> ProfileEmbed(SocketGuildUser user) { var eb = new EmbedBuilder(); string name = user.Username; var role = RoleUtil.GetMemberRole(user.Guild, user) ?? RoleUtil.GetLeaderRole(user.Guild, user); if (role != null) { var team = TeamDb.TeamByMember(role.Id) ?? TeamDb.TeamByLeader(role.Id); if (team != null) { role = user.Roles.FirstOrDefault(x => x.Id == team.LeaderRoleId); if (role == null) { role = user.Roles.FirstOrDefault(x => x.Id == team.MemberRoleId); } name += $" | {role.Name}"; } } if (PremiumDb.IsPremium(user.Id, ProType.ProPlus)) { name += " | Pro+ 🌟"; } else if (PremiumDb.IsPremium(user.Id, ProType.Pro)) { name += " | Pro ⭐"; } eb.WithAuthor(name, user.GetAvatarUrl(), $"https://namiko.moe/Guild/{user.Guild.Id}/{user.Id}"); var waifus = UserInventoryDb.GetWaifus(user.Id, user.Guild.Id); int waifucount = waifus.Count(); int waifuprice = WaifuUtil.WaifuValue(waifus); var daily = DailyDb.GetDaily(user.Id, user.Guild.Id); long timeNow = DateTimeOffset.Now.ToUnixTimeMilliseconds(); string text = ""; text += $"Amount: {BalanceDb.GetToasties(user.Id, user.Guild.Id).ToString("n0")}\n" + $"Daily: {(daily == null ? "0" : ((daily.Date + 172800000) < timeNow ? "0" : daily.Streak.ToString()))}\n" + $"Boxes Opened: {ProfileDb.GetLootboxOpenedAmount(user.Id)}\n"; eb.AddField("Toasties <:toastie3:454441133876183060>", text, true); text = $"Amount: {waifucount}\n" + $"Value: {waifuprice.ToString("n0")}\n"; foreach (var x in MarriageDb.GetMarriages(user.Id, user.Guild.Id)) { try { if (!text.Contains("Married: ")) { text += "Married: "; } text += $"{BasicUtil.IdToMention(GetWifeId(x, user.Id))}\n"; } catch { } } eb.AddField("Waifus :two_hearts:", text, true); var waifu = FeaturedWaifuDb.GetFeaturedWaifu(user.Id, user.Guild.Id); if (waifu != null) { eb.WithImageUrl(waifu.HostImageUrl); eb.AddField("Featured Waifu <:MiaHug:536580304018735135>", $"**{waifu.Name}** - *{waifu.Source}*"); } var rep = ProfileDb.GetRepAmount(user.Id); string footer = $"Votes: {await VoteDb.VoteCount(user.Id)} • "; footer += $"Rep: {rep} • "; // Activities require guildpresence //footer += $"Status: '{user.Status}'"; //var activity = user.Activities.FirstOrDefault(); //if (activity != null) // footer += $", {activity.Type}: '{activity.Name}'"; eb.WithFooter(footer); //quote string quote = ProfileDb.GetQuote(user.Id); if (!String.IsNullOrEmpty(quote) & !WebUtil.IsValidUrl(quote)) { eb.WithDescription(quote); } //image string image = ProfileDb.GetImage(user.Id); if (WebUtil.IsValidUrl(image)) { eb.WithThumbnailUrl(image); } eb.Color = ProfileDb.GetHex(out string colour, user.Id)? (Discord.Color)HexToColor(colour) : BasicUtil.RandomColor(); return(eb); }
public static EmbedBuilder FlipLoseEmbed(SocketGuildUser user, int amount) { var eb = new EmbedBuilder(); eb.WithAuthor(user); eb.WithDescription($"**You lose!** {amount.ToString("n0")} {ToastieUtil.RandomEmote()} lost...\nNow you have {BalanceDb.GetToasties(user.Id, user.Guild.Id).ToString("n0")} {ToastieUtil.RandomEmote()}!"); eb.WithColor(Color.DarkRed); return(eb); }