private async Task BankTransferAsync(IUser user = null, float amount = 0) { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); if (user == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}bank transfer <@user> <amount>`", false); return; } if (amount <= 0) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", $"The amount must be greater than 0."); return; } LoriUser profile = ProfileDatabase.GetUser(Context.User.Id); if (profile == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", $"We could not find your bank account."); return; } LoriUser profile2 = ProfileDatabase.GetUser(user.Id); if (profile2 == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", $"We could not find {user.Username}'s bank account."); return; } if (profile.GetCurrency() >= amount) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", "You can not afford this transfer."); return; } ProfileDatabase.AddCurrency(Context.User.Id, -amount); ProfileDatabase.AddCurrency(user.Id, amount); float newAmt = profile.GetCurrency(); EmbedBuilder embed = new EmbedBuilder() { Color = Color.DarkPurple, Title = "Transfer successful", Description = $"Successfully transferred ${amount} to {user.Username}.\nNew balance: ${newAmt}" }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
private async Task SetMottoAsync([Remainder] string motto = null) { await Context.Message.DeleteAsync(); while (!ProfileDatabase.Ready()) { await Task.Delay(50); } LoriUser profile = ProfileDatabase.GetUser(Context.User.Id); if (profile == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Profile Not Found", $"That users profile could not be found?", false); return; } if (motto == null) { motto = ""; } ProfileDatabase.SetUserMotto(Context.User.Id, motto); await ViewProfileAsync(Context, (Context.User as IUser)); }
private async Task DailyAsync() { await Context.Message.DeleteAsync(); LoriUser profile = ProfileDatabase.GetUser(Context.User.Id); if (profile == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", $"We could not find your bank account."); return; } var tgg = LCommandHandler.GetTopGGClient(); bool hasVoted = await tgg.HasVoted(Context.User.Id); if (hasVoted) { // check if already claimed if (ProfileDatabase.HasClaimedDaily(Context.User.Id)) { DateTime claimAt = profile.Claimed.AddHours(12.0); var timeToClaim = claimAt - DateTime.Now; await MessageUtil.SendErrorAsync(Context.Channel as ITextChannel, "Already Claimed", $"You can claim your daily in {timeToClaim.Hours} hours and {timeToClaim.Minutes} minutes.", false); } else { ProfileDatabase.ClaimDaily(Context.User.Id); float newAmt = profile.GetCurrency(); EmbedBuilder embed = new EmbedBuilder() { Color = Color.DarkPurple, Title = "Daily Bonus Claimed", Description = $"New bank balance: ${newAmt}" }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); } } else { EmbedBuilder embed = new EmbedBuilder() { Color = Color.DarkPurple, Author = new EmbedAuthorBuilder() { Name = "Click here to vote!", Url = "https://top.gg/bot/729696788097007717/vote" }, Description = $"Vote on TopGG and then claim your daily!", Footer = new EmbedFooterBuilder() { Text = "If you can't click above, head to this url https://top.gg/bot/729696788097007717/vote" } }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); } }
private async Task BankAsync() { await Context.Message.DeleteAsync(); LoriUser profile = ProfileDatabase.GetUser(Context.User.Id); if (profile == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", $"We could not find your bank account."); return; } float amount = profile.GetCurrency(); EmbedBuilder embed = new EmbedBuilder() { Color = Color.DarkPurple, Title = "Transfer successful", Description = $"Bank balance: ${amount}" }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
private async Task ConnectTurnAsunc(int column = -1) { await Context.Message.DeleteAsync(); if (column < 1 || column > 7) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}c4 <column>` - Column must be 1 - 7", false); return; } if (!GameHandler.DoesGameExist(Context.Guild.Id, GameType.CONNECT)) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Connect4 Error", "There is not a game in this guild.", false); return; } ConnectGame game = (ConnectGame)GameHandler.GetGame(Context.Guild.Id, GameType.CONNECT); if (game == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Connect4 Error", "The game could not be found.", false); return; } if (game.Players[0] != Context.User.Id && game.Players[1] != Context.User.Id) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Connect4 Error", "You are not part of this game..."); return; } if (game.Players[game.Turn] != Context.User.Id) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Connect4 Error", "It is not your turn..."); return; } GameHandler.TakeTurn(Context.Guild.Id, GameType.CONNECT, Context.User.Id, column); ulong winner = GameHandler.CheckForWinner(Context.Guild.Id, GameType.CONNECT); bool draw = GameHandler.CheckForDraw(Context.Guild.Id, GameType.CONNECT); IMessage oldMsg = await Context.Channel.GetMessageAsync(game.RenderId); await oldMsg.DeleteAsync(); if (winner == 0L) { if (!draw) { var nextUp = await Context.Guild.GetUserAsync(game.Players[game.Turn]); string render = game.RenderGame(); var msg = await Context.Channel.SendFileAsync(render, $"**Connect 4**\n" + $"Next Up: {nextUp.Mention}\n" + $"`{CommandHandler.GetPrefix(Context.Guild.Id)}c4 <column>` to take your turn\n`{CommandHandler.GetPrefix(Context.Guild.Id)}c4 end` to end the game"); game.RenderId = msg.Id; } else { string render = game.RenderGame(); await Context.Channel.SendFileAsync(render, $"**Connect 4**\n" + $"DRAW ({(await Context.Guild.GetUserAsync(game.Players[0])).Mention} v {(await Context.Guild.GetUserAsync(game.Players[1])).Mention})"); if (ProfileDatabase.GetUser(game.Players[0]) != null) { ProfileDatabase.AddCurrency(game.Players[0], 100); } if (ProfileDatabase.GetUser(game.Players[1]) != null) { ProfileDatabase.AddCurrency(game.Players[1], 100); } GameHandler.EndGame(game); } } else { string render = game.RenderGame(); await Context.Channel.SendFileAsync(render, $"**Connect 4**\n" + $"Game Won by " + (await Context.Guild.GetUserAsync(winner)).Mention); var winwin = ProfileDatabase.GetUser(winner); if (winwin != null) { ProfileDatabase.AddCurrency(winner, 250); await LeaderboardDatabase.CheckAsync(winner, winwin.Name, "Connect 4"); await LeaderboardDatabase.AddScoreAsync(winner, "Connect 4"); } GameHandler.EndGame(game); } }
private async Task TicTacToeTurnAsync(int x = -1, int y = -1) { await Context.Message.DeleteAsync(); if (!GameHandler.DoesGameExist(Context.Guild.Id, GameType.TICTACTOE)) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "TicTacToe Error", "No game could be found here..."); return; } TicTacToeGame game = (TicTacToeGame)GameHandler.GetGame(Context.Guild.Id, GameType.TICTACTOE); if (game == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "TicTacToe Error", "No game could be found here..."); return; } if (game.Players[0] != Context.User.Id && game.Players[1] != Context.User.Id) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "TicTacToe Error", "You are not part of this game..."); return; } if (game.Players[game.Turn] != Context.User.Id) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "TicTacToe Error", "It is not your turn..."); return; } if (x <= 0 || y <= 0 || x > 3 || y > 3) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "TicTacToe Error", "You need to choose and x and y between of 1, 2 or 3..."); return; } GameHandler.TakeTurn(Context.Guild.Id, GameType.TICTACTOE, Context.User.Id, x, y); ulong winner = GameHandler.CheckForWinner(Context.Guild.Id, GameType.TICTACTOE); if (winner == 0L) { var oldMsg = await Context.Channel.GetMessageAsync(game.RenderId); await oldMsg.DeleteAsync(); var nextUp = await Context.Guild.GetUserAsync(game.Players[game.Turn]); string render = game.RenderGame(); var msg = await Context.Channel.SendFileAsync(render, $"**TicTacToe**\n" + $"Next Up: {nextUp.Mention}\n" + $"`{CommandHandler.GetPrefix(Context.Guild.Id)}t <x> <y>` to take your turn\n`{CommandHandler.GetPrefix(Context.Guild.Id)}t end` to end the game"); game.RenderId = msg.Id; } else { IMessage msg = await Context.Channel.GetMessageAsync(game.RenderId); await msg.DeleteAsync(); string render = game.RenderGame(); await Context.Channel.SendFileAsync(render, $"**TicTacToe**\n" + $"Game Won by " + (await Context.Guild.GetUserAsync(winner)).Mention); var winwin = ProfileDatabase.GetUser(winner); if (winwin != null) { ProfileDatabase.AddCurrency(winner, 100); await LeaderboardDatabase.CheckAsync(winner, winwin.Name, "Tic Tac Toe"); await LeaderboardDatabase.AddScoreAsync(winner, "Tic Tac Toe"); } GameHandler.EndGame(game); } }
private async Task ViewProfileAsync(ICommandContext Context, IUser User) { if (User.IsBot) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Profile Not Found", $"You can not use this command on bots!", false); return; } while (!ProfileDatabase.Ready()) { await Task.Delay(50); } LoriUser profile = ProfileDatabase.GetUser(User.Id); if (profile == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Profile Not Found", $"That users profile could not be found?", false); return; } string avatar = User.GetAvatarUrl(size: 2048); string status = "**" + User.Status.ToString() + " for "; Color color; switch (User.Status) { case UserStatus.Offline: color = Color.LightGrey; break; case UserStatus.Online: color = Color.Green; break; case UserStatus.Idle: color = Color.Orange; break; case UserStatus.AFK: color = Color.Orange; break; case UserStatus.DoNotDisturb: color = Color.Red; break; case UserStatus.Invisible: color = Color.LightGrey; break; default: color = Color.LightGrey; break; } DateTime now = DateTime.Now; int seconds = (int)((now - profile.LastSeen).TotalSeconds); int minutes = (int)((now - profile.LastSeen).TotalMinutes); int hours = (int)((now - profile.LastSeen).TotalHours); int days = (int)((now - profile.LastSeen).TotalDays); if (days > 0) { status += $"{days} Days and {hours - (days * 24)} Hours**"; } else if (hours > 0) { status += $"{hours} Hours and {minutes - (hours * 60)} Minutes**"; } else if (minutes > 0) { status += $"{minutes} Minutes and {seconds - (minutes * 60)} Seconds**"; } else { status += $"{seconds} Seconds**"; } if (User.Status == UserStatus.Offline || User.Status == UserStatus.Invisible) { status += $"\n _{profile.Activity}_"; } else { status += $"\n {profile.Activity}"; } if (profile.Motto.Length > 0) { status += $"\n**Motto:** {profile.Motto}"; } EmbedBuilder embed = new EmbedBuilder() { Author = new EmbedAuthorBuilder() { IconUrl = avatar, Name = $"{User.Username}#{User.Discriminator}" }, Description = status, Color = color, Footer = new EmbedFooterBuilder() { Text = $"{EmojiUtil.GetRandomEmoji()} This is a temporary look for profiles..." }, }; embed.AddField(new EmbedFieldBuilder() { Name = "Account Created On: ", Value = profile.CreatedOn.ToShortDateString(), IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Profile Created On: ", Value = profile.JoinedOn.ToShortDateString(), IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Last Updated On: ", Value = profile.LastUpdated.ToShortDateString(), IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Unique Identifier: ", Value = profile.Id, IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Username: "******"#" + User.Discriminator, IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Lori's Angel Guilds: ", Value = LCommandHandler.GetUserGuildCount(User.Id), IsInline = true }); ProfileRenderer renderer = new ProfileRenderer(User.Id, profile); renderer.Render(); await Context.Channel.SendFileAsync(renderer.GetPath()); renderer.Dispose(); await Context.Channel.SendMessageAsync(null, false, embed.Build()); }