public async Task Give(IUser recipient, string sAmount, [Remainder] string str = "") { int amount = ToastieUtil.ParseAmount(sAmount, (SocketGuildUser)Context.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(Context.User.Id, -amount, Context.Guild.Id); } catch (Exception ex) { await Context.Channel.SendMessageAsync(ex.Message); return; } await BalanceDb.AddToasties(recipient.Id, amount, Context.Guild.Id); await Context.Channel.SendMessageAsync("", false, ToastieUtil.GiveEmbed(Context.User, recipient, amount).Build()); }
// NAMIKO JOIN private async Task Client_JoinedGuild(SocketGuild arg) { DateTime now = DateTime.Now; Server server = ServerDb.GetServer(arg.Id) ?? new Server { GuildId = arg.Id, JoinDate = now }; server.LeaveDate = null; server.Prefix = AppSettings.DefaultPrefix; await ServerDb.UpdateServer(server); if (server.JoinDate.Equals(now)) { await BalanceDb.SetToasties(Client.CurrentUser.Id, 1000000, arg.Id); } SocketTextChannel ch = arg.SystemChannel ?? arg.DefaultChannel; try { await ch?.SendMessageAsync("Hi! Please take good care of me!", false, BasicUtil.GuildJoinEmbed(server.Prefix).Build()); } catch { } await WebhookClients.GuildJoinLogChannel.SendMessageAsync($"<:TickYes:577838859107303424> {Client.CurrentUser.Username} joined `{arg.Id}` **{arg.Name}**.\nOwner: `{arg.Owner.Id}` **{arg.Owner}**"); }
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 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 RoleShopAddRole([Remainder] string name = "") { var roles = await ShopRoleDb.GetRoles(Context.Guild.Id); var role = await this.SelectRole(name, roles.Select(x => x.RoleId)); if (role == null) { return; } var user = Context.User as SocketGuildUser; if (user.Roles.Contains(role)) { await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared($"You already have **{role.Mention}** !").Build()); return; } int price = roles.FirstOrDefault(x => x.RoleId == role.Id).Price; try { await BalanceDb.AddToasties(Context.User.Id, -price, Context.Guild.Id); await user.AddRoleAsync(role); await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared($"You bought the **{role.Mention}** role!").Build()); } catch (Exception ex) { await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(ex.Message).WithColor(Color.DarkRed).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 BuyWaifu([Remainder] string str = "") { var shopwaifus = (await WaifuShopDb.GetAllShopWaifus(Context.Guild.Id)).DistinctBy(x => x.WaifuName); var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(str, false, shopwaifus.Select(x => x.Waifu)), this); if (waifu == null) { return; } var waifus = UserInventoryDb.GetWaifus(Context.User.Id, Context.Guild.Id); if (waifus.Any(x => x.Name.Equals(waifu.Name))) { await Context.Channel.SendMessageAsync("You already have **" + waifu.Name + "**."); return; } ShopWaifu shopWaifu = shopwaifus.FirstOrDefault(x => x.Waifu.Equals(waifu) && x.Limited != 0); if (shopWaifu == null) { await Context.Channel.SendMessageAsync($"**{waifu.Name}** is not currently for sale! Try the `waifushop` command."); return; } var price = WaifuUtil.GetPrice(waifu.Tier, shopWaifu.Discount); try { await BalanceDb.AddToasties(Context.User.Id, -price, Context.Guild.Id); } catch (Exception ex) { await Context.Channel.SendMessageAsync(ex.Message); return; } await UserInventoryDb.AddWaifu(Context.User.Id, waifu, Context.Guild.Id); await Context.Channel.SendMessageAsync($"Congratulations! You bought **{waifu.Name}**!", false, WaifuUtil.WaifuEmbedBuilder(waifu).Build()); await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, price / 13, Context.Guild.Id); if (shopWaifu.Limited > 0) { shopWaifu.BoughtBy = Context.User.Id; shopWaifu.Limited -= 1; await WaifuShopDb.UpdateItem(shopWaifu); } }
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 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 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 DoubleDown(SocketCommandContext Context, BlackjackGame game) { try { await BalanceDb.AddToasties(Context.User.Id, -game.Toasties, Context.Guild.Id); game.Toasties *= 2; game.Hit(); await Stand(Context, game); } catch (Exception e) { await Context.Channel.SendMessageAsync(e.Message); } }
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 async Task BRRewardPool(string amountStr) { int amount = ToastieUtil.ParseAmount(amountStr, (SocketGuildUser)Context.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; } var banroulette = BanrouletteDb.GetBanroulette(Context.Channel.Id); if (banroulette == null) { await Context.Channel.SendMessageAsync(":x: There is no running Ban Roulette in this channel."); return; } try { await BalanceDb.AddToasties(Context.User.Id, -amount, Context.Guild.Id); } catch (Exception ex) { await Context.Channel.SendMessageAsync(ex.Message); return; } banroulette.RewardPool += amount; await BanrouletteDb.UpdateBanroulette(banroulette); await Context.Channel.SendMessageAsync($"Added {amount} to the reward pool!"); }
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 SetPersonalColour(string shade = "", string colour = "", [Remainder] string str = "") { // //way to set it back to default if (shade.Equals("")) { await ProfileDb.HexDefault(Context.User.Id); //sending embed + exception & error confermations EmbedBuilder embed = UserUtil.SetColourEmbed(Context.User); embed.WithDescription($"{ Context.User.Username } set colour to **Default**"); await Context.Channel.SendMessageAsync("", false, embed.Build()); return; //if no shade specified but colour value exists } if (colour.Equals("")) { colour = shade; } // //setting start values & checking for possible name or hex value System.Drawing.Color color = System.Drawing.Color.White; if (UserUtil.GetNamedColour(ref color, colour, shade) || UserUtil.GetHexColour(ref color, colour)) { //toastie + saving hex colour try { await BalanceDb.AddToasties(Context.User.Id, -Constants.colour, Context.Guild.Id); await ProfileDb.SetHex(color, Context.User.Id); await Context.Channel.SendMessageAsync("", false, UserUtil.SetColourEmbed(Context.User).Build()); } catch (Exception ex) { await Context.Channel.SendMessageAsync(ex.Message); } } }
private static async Task <int> CheckJoinedGuilds(DiscordSocketClient shard = null) { IReadOnlyCollection <SocketGuild> guilds; if (shard == null) { guilds = Client.Guilds; } else { guilds = shard.Guilds; } var existingIds = ServerDb.GetNotLeft(); var newIds = guilds.Where(x => !existingIds.Contains(x.Id)).Select(x => x.Id); int addedBal = await BalanceDb.AddNewServerBotBalance(newIds, Client.CurrentUser.Id); int added = await ServerDb.AddNewServers(newIds, AppSettings.DefaultPrefix); return(added); }
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()); }
private static async Task <bool> EndBanroyale(BanroyaleGame br, IEnumerable <SocketGuildUser> users) { if (users.Count() <= br.Banroyale.WinnerAmount) { br.Timer.Stop(); br.Timer.Close(); await BanroyaleDb.EndBanroyale(br.Banroyale.Id); string desc = "Winners: "; int split = 0; if (br.Role.Members.Count() == 0) { desc += "Everyone lost! Well done guys, I'm proud of you."; } else { split = br.Banroyale.RewardPool / users.Count(); foreach (var user in users) { _ = BalanceDb.AddToasties(user.Id, split, br.Banroyale.GuildId); _ = user.RemoveRoleAsync(br.Role); desc += user.Mention + " "; } } if (split > 0) { desc += $"\nSplitting **{br.Banroyale.RewardPool}** toasties from the reward pool! ({split} each)"; } await br.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(desc).WithTitle("Ban Royale Over!") .WithColor(Color.Gold) .Build()); return(true); } return(false); }
public async Task ToastieLeaderboard([Remainder] string str = "") { var toasties = await BalanceDb.GetAllToasties(Context.Guild.Id); var parsed = toasties.Select(x => { try { return(new UserAmountView() { User = Context.Guild.GetUser(x.Id), Amount = x.Count }); } catch { return(null); } }) .Where(x => x != null && x.User != null); var msg = new CustomPaginatedMessage(); msg.Title = "User Leaderboards"; var fields = new List <FieldPages> { new FieldPages { Title = "Toasties <:toastie3:454441133876183060>", Pages = CustomPaginatedMessage.PagesArray(parsed, 10), Inline = true } }; msg.Fields = fields; await PagedReplyAsync(msg); }
public async Task EndBanroulette() { var banroulette = BanrouletteDb.GetBanroulette(Context.Channel.Id); if (banroulette == null) { await Context.Channel.SendMessageAsync(":x: There is no running Ban Roulette in this channel."); return; } var userIds = BanrouletteDb.GetParticipants(banroulette); if (userIds.Count < banroulette.MinParticipants) { await Context.Channel.SendMessageAsync($"Not enough participants! {userIds.Count}/{banroulette.MinParticipants}"); return; } var users = BasicUtil.UserList(Context.Client, userIds); var user = users[new Random().Next(users.Count)]; var ban = new BannedUser { Active = true, ServerId = Context.Guild.Id, UserId = user.Id, DateBanStart = DateTime.UtcNow, DateBanEnd = DateTime.UtcNow.AddHours(banroulette.BanLengthHours) }; string msg = $"{user.Mention} won! Bai baaaaaai! See you in {banroulette.BanLengthHours} hours!\n\n"; users.Remove(user); if (users.Count > 0 && banroulette.RewardPool > 0) { int prize = banroulette.RewardPool / users.Count; msg += $"Prize pool of {banroulette.RewardPool} ({prize} each) split between: "; foreach (var x in users) { await BalanceDb.AddToasties(x.Id, prize, Context.Guild.Id); msg += x.Mention + " "; } } await Context.Channel.SendMessageAsync(msg); await user.SendMessageAsync($"You won the ban roulette! You are banned from **{Context.Guild.Name}** for {banroulette.BanLengthHours} hours! Bai baaaai!"); await BanrouletteDb.EndBanroulette(banroulette.Id); if (banroulette.BanLengthHours > 0) { await BanDb.AddBan(ban); try { await Context.Guild.AddBanAsync(user, 0, $"Banroulette {banroulette.Id}, {banroulette.BanLengthHours} hours."); } catch { } { await Context.Channel.SendMessageAsync($"I couldn't ban {user}, they are too powerful. *Wipes off blood.* This usually means that their role is higher than mine."); } } }
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); }
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 BuyLootbox([Remainder] string str = "") { var prefix = Program.GetPrefix(Context); if (!PremiumDb.IsPremium(Context.Guild.Id, ProType.GuildPlus)) { await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User) .WithDescription($"*~ This command requires Pro Guild+ ~*\n" + $"Try `{prefix}lootboxstats` to see drop rates.") .WithFooter($"`{prefix}pro`") .Build()); return; } LootboxStat box = null; var boxes = LootboxStats.Lootboxes.Where(x => x.Value.Price >= 0).Select(x => x.Value).ToList(); if (str != "") { var matches = boxes.Where(x => x.Name.Contains(str, StringComparison.OrdinalIgnoreCase)); if (matches.Count() == 1) { box = matches.First(); } } if (box == null) { var listMsg = await Context.Channel.SendMessageAsync(embed : ToastieUtil.BoxShopEmbed(Context.User) .WithFooter("Times out in 23 seconds. Try the `lootboxstats` command") .WithDescription("Enter the number of the lootbox you wish to purchase.") .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 msg = await Context.Channel.SendMessageAsync($"How many **{box.Name}** lootboxes do you wish to buy? (max 100)"); var resp = await NextMessageAsync( new Criteria <IMessage>() .AddCriterion(new EnsureSourceUserCriterion()) .AddCriterion(new EnsureSourceChannelCriterion()) .AddCriterion(new EnsureRangeCriterion(100, Program.GetPrefix(Context))), new TimeSpan(0, 0, 23)); _ = msg.DeleteAsync(); int amount = 0; try { amount = int.Parse(resp.Content); } catch { _ = Context.Message.DeleteAsync(); return; } _ = resp.DeleteAsync(); try { await BalanceDb.AddToasties(Context.User.Id, -box.Price *amount, Context.Guild.Id); } catch (Exception ex) { await Context.Channel.SendMessageAsync(ex.Message); return; } await LootBoxDb.AddLootbox(Context.User.Id, (LootBoxType)box.TypeId, amount, Context.Guild.Id); await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User) .WithDescription($"You bought {amount}x **{box.Name}**!\nType `{Program.GetPrefix(Context)}open` to open it!") .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 <IActionResult> GetGuildUser([FromRoute] ulong guildId, [FromRoute] ulong userId) { var client = await HttpContext.GetBotClient(); Task <RestGuildUser> currentUser = client.GetGuildUserAsync(guildId, HttpContext.GetUserId()); Task <RestGuildUser> searchUser = client.GetGuildUserAsync(guildId, userId); var guild = client.GetGuildAsync(guildId); var tasks = new List <Task>(); try { tasks.Add(currentUser); tasks.Add(searchUser); tasks.Add(guild); await Task.WhenAll(tasks); } catch (HttpException) { return(StatusCode(412, "Bot not in guild")); } if (currentUser.Result == null) { return(StatusCode(403, "Unauthorized")); } if (searchUser.Result == null) { return(StatusCode(404, "No user in guild")); } var profile = await ProfileDb.GetProfile(searchUser.Result.Id); var bal = await BalanceDb.GetToastiesAsync(userId, guildId); var dailyRes = await DailyDb.GetDailyAsync(userId, guildId); var daily = dailyRes == null ? 0 : dailyRes.Streak; var waifus = (await UserInventoryDb.GetWaifusAsync(userId, guildId)).OrderBy(x => x.Source).ThenBy(x => x.Name).ToView(); var waifu = FeaturedWaifuDb.GetFeaturedWaifu(userId, guildId).ToView(); var user = new GuildUserView { AvatarUrl = searchUser.Result.GetAvatarUrl(size: 256), Id = searchUser.Result.Id.ToString(), Name = searchUser.Result.Username, Discriminator = searchUser.Result.Discriminator, ImageUrl = profile.Image, Quote = profile.Quote.CleanQuote(), LootboxesOpened = profile.LootboxesOpened, Rep = profile.Rep, Balance = bal, Daily = daily, Waifus = waifus, JoinedAt = searchUser.Result.JoinedAt, Waifu = waifu, Guild = new GuildSummaryView { ImageUrl = guild.Result.IconUrl, Id = guild.Result.Id.ToString(), Name = guild.Result.Name } }; return(Ok(user)); }
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); }