public async Task Tip(string amount, SocketUser user) { if (CanRunTipCommands) { if (decimal.TryParse(amount, out var decAmount)) { if (decAmount < MinimumTipValue) { await ReplyAsync($"Minimum tip amount is {MinimumTipValue}"); return; } if (QTCommands.CheckBalance(Context.User.Id, decAmount)) { QTCommands.SendTip(Context.User.Id, user.Id, decAmount); await ReplyAsync($"{Context.User.Mention} tipped {user.Username} {amount} {Preferences.BaseCurrency}"); } else { await ReplyAsync("You do not have enough balance to tip that much!"); } } } else { await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel"); } }
public async Task DonateAsync(decimal amount, string pot) { if (QTCommands.CheckBalance(Context.User.Id, amount)) { if (pot.Contains("dev")) { var resp = QTCommands.Withdraw(Context.User.Id, "FWN1qdiRrymSR6jbpbanLYqZpjkEaZouHN", amount); if (string.IsNullOrEmpty(resp.Error)) { await ReplyAsync($"Donation successful! The {Preferences.BaseCurrency} Team thanks you! Transaction: {Preferences.ExplorerPrefix}{resp.Result}{Preferences.ExplorerSuffix}"); } } else if (pot.Contains("market")) { var resp = QTCommands.Withdraw(Context.User.Id, "FqkPKgvb2jFv6GdVphgyVY2iFPcHHi3dx7", amount); if (string.IsNullOrEmpty(resp.Error)) { await ReplyAsync($"Donation successful! The {Preferences.BaseCurrency} Team thanks you! Transaction: {Preferences.ExplorerPrefix}{resp.Result}{Preferences.ExplorerSuffix}"); } } else { await ReplyAsync($"No Donation Fund found for {pot}! Options: `dev`, `marketing`"); } } else { await ReplyAsync("Not enough balance!"); } }
public async Task DonateAsync(decimal amount) { if (QTCommands.CheckBalance(Context.User.Id, amount)) { var resp = QTCommands.Withdraw(Context.User.Id, "FWN1qdiRrymSR6jbpbanLYqZpjkEaZouHN", amount); if (string.IsNullOrEmpty(resp.Error)) { await ReplyAsync($"Donation successful! The {Preferences.BaseCurrency} Team thanks you! Transaction: {Preferences.ExplorerPrefix}{resp.Result}{Preferences.ExplorerSuffix}"); } } else { await ReplyAsync("Not enough balance!"); } }
private string SendRain(SocketUser fromUser, List <SocketGuildUser> tipUsers, decimal amount) { if (QTCommands.CheckBalance(fromUser.Id, amount)) { if (amount / tipUsers.Count < (decimal)0.01) { return($"Rain amount must be at least 0.01 {Preferences.BaseCurrency} per person"); } foreach (var person in tipUsers) { QTCommands.SendTip(Context.User.Id, person.Id, Math.Round(amount / tipUsers.Count, 7)); } var mentionList = new List <string>(); foreach (var users in tipUsers) { mentionList.Add($"{DiscordClientNew._client.GetUser(users.Id).Mention}"); } return($"{fromUser.Mention} made it rain :cloud_rain:! Congratulations to {(mentionList.Count == 2 ? string.Join(" and ", mentionList) : string.Join(", ", mentionList))} who {(mentionList.Count > 1 ? "have" : "has")} been awarded {Math.Round(amount / mentionList.Count, 7)} {Preferences.BaseCurrency} {(mentionList.Count > 1 ? "each" : "")}"); } return("You do not have enough balance to perform this rain"); }
public async Task Join() { if (FantasyPortfolioModule.EntryFee == 0 || QTCommands.CheckBalance(Context.User.Id, FantasyPortfolioModule.EntryFee)) { if (FantasyPortfolioModule.EntryFee > 0) { QTCommands.SendTip(Context.User.Id, DiscordClientNew._client.CurrentUser.Id, FantasyPortfolioModule.EntryFee); } if (Portfolio.Join(Context.User.Id.ToString())) { await ReplyAsync($"You have joined round {Round.CurrentRound}. An entry fee of {FantasyPortfolioModule.EntryFee} {Preferences.BaseCurrency} has been taken."); } else { await ReplyAsync("You have already joined this round!"); } } else { await ReplyAsync($"You do not have the required entry fee of {FantasyPortfolioModule.EntryFee} {Preferences.BaseCurrency}. Please send some {Preferences.BaseCurrency} to your tipping account and try again."); } }
public async Task WithdrawAsync(string address, decimal amount) { if (CanRunTipCommands) { if (address.StartsWith("F") || address.StartsWith("3") || address.StartsWith("grs1")) { if (QTCommands.CheckBalance(Context.User.Id, amount)) { if (amount <= QTCommands.MinimumWithdraw) { await ReplyAsync($"Minimum Withdrawal: {QTCommands.MinimumWithdraw:N8}"); return; } var resp = QTCommands.Withdraw(Context.User.Id, address, amount); if (string.IsNullOrEmpty(resp.Error)) { await ReplyAsync($"Withdrawn successfully! Transaction: {Preferences.ExplorerPrefix}{resp.Result}{Preferences.ExplorerSuffix}"); } else { await ReplyAsync(resp.Error); } } else { await ReplyAsync("Not enough balance!"); } } else { await ReplyAsync("Invalid Address"); } } else { await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel"); } }
public async Task RockPaperScissorsGame(string rps, string amount) { if (CanRunTipCommands) { if (Enum.TryParse(rps.ToLower(), out RockPaperScissors userDecision)) { if (decimal.TryParse(amount, out var betAmount)) { if (QTCommands.CheckBalance(Context.User.Id, betAmount)) { if (betAmount < MinBetAmount) { await ReplyAsync($"Minimum bet {MinBetAmount} {Preferences.BaseCurrency}"); return; } decimal balance = 0; var houseBalanceCall = QTCommands.GetBalance(Context.Client.CurrentUser.Id).Result; decimal.TryParse(houseBalanceCall, out balance); decimal maxBet = balance / 10; if (betAmount > maxBet) { await ReplyAsync($"Maximum bet exceeded. Max: {maxBet} {Preferences.BaseCurrency}"); return; } var rewardValue = betAmount * (decimal)BetWin; if (QTCommands.CheckBalance(DiscordClientNew._client.CurrentUser.Id, rewardValue + FantasyPortfolioModule.PrizePool)) { QTCommands.SendTip(Context.User.Id, DiscordClientNew._client.CurrentUser.Id, betAmount); try { var botDecision = (RockPaperScissors)RandomInteger(0, 3); var embed = new EmbedBuilder(); string message = ""; var userOutcome = new Outcome(); switch (botDecision) { case RockPaperScissors.rock: { switch (userDecision) { case RockPaperScissors.rock: userOutcome = Outcome.draw; break; case RockPaperScissors.paper: userOutcome = Outcome.win; break; case RockPaperScissors.scissors: userOutcome = Outcome.lose; break; } break; } case RockPaperScissors.paper: { switch (userDecision) { case RockPaperScissors.rock: userOutcome = Outcome.lose; break; case RockPaperScissors.paper: userOutcome = Outcome.draw; break; case RockPaperScissors.scissors: userOutcome = Outcome.win; break; } break; } case RockPaperScissors.scissors: { switch (userDecision) { case RockPaperScissors.rock: userOutcome = Outcome.win; break; case RockPaperScissors.paper: userOutcome = Outcome.lose; break; case RockPaperScissors.scissors: userOutcome = Outcome.draw; break; } break; } } switch (userOutcome) { case Outcome.win: QTCommands.SendTip(DiscordClientNew._client.CurrentUser.Id, Context.User.Id, rewardValue); embed.AddInlineField("Outcome", $"Bot opted for {botDecision.ToString()} whereas you opted for {userDecision.ToString()}"); embed.AddInlineField("Prize", $"{rewardValue} {Preferences.BaseCurrency}"); embed.AddInlineField("Profit", $"{(rewardValue - betAmount)} {Preferences.BaseCurrency}"); embed.WithColor(Discord.Color.Green); message = $"You won! Congratulations {Context.User.Mention}!"; break; case Outcome.draw: QTCommands.SendTip(DiscordClientNew._client.CurrentUser.Id, Context.User.Id, betAmount); embed.AddInlineField("Outcome", $"Bot opted for {botDecision.ToString()} whereas you opted for {userDecision.ToString()}"); embed.WithColor(Discord.Color.Gold); message = "It was a draw! Bet refunded"; break; case Outcome.lose: QTCommands.SendTip(DiscordClientNew._client.CurrentUser.Id, Context.User.Id, betAmount); embed.AddInlineField("Outcome", $"Bot opted for {botDecision.ToString()} whereas you opted for {userDecision.ToString()}"); embed.AddInlineField("Prize", $"{rewardValue} {Preferences.BaseCurrency}"); embed.AddInlineField("Profit", $"{(rewardValue - betAmount)} {Preferences.BaseCurrency}"); embed.WithColor(Discord.Color.Red); message = "Unlucky! You lose! Bot won"; break; } embed.WithFooter(Preferences.FooterText); await ReplyAsync(message, false, embed); Console.WriteLine($"{Context.User.Id} ({Context.User.Username}) opted for {userDecision} and bot opted for {botDecision}"); } catch (Exception e) { Console.WriteLine(e.Message); QTCommands.SendTip(DiscordClientNew._client.CurrentUser.Id, Context.User.Id, betAmount); await ReplyAsync("Sorry something went wrong. You have been refunded your bet."); } } else { await ReplyAsync("Sorry, the bot is too poor to reward you if you won :("); } } else { await ReplyAsync("You do not have enough balance to perform this action"); } } } } else { await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel"); } }
public async Task Flip(string side, string amount) { if (CanRunTipCommands) { if (Enum.TryParse(side.ToLower(), out CoinSide coinSide)) { if (decimal.TryParse(amount, out var betAmount)) { if (QTCommands.CheckBalance(Context.User.Id, betAmount)) { if (betAmount < MinBetAmount) { await ReplyAsync($"Minimum bet {MinBetAmount} {Preferences.BaseCurrency}"); return; } decimal balance = 0; var houseBalanceCall = QTCommands.GetBalance(Context.Client.CurrentUser.Id).Result; decimal.TryParse(houseBalanceCall, out balance); decimal maxBet = balance / 10; if (betAmount > maxBet) { await ReplyAsync($"Maximum bet exceeded. Max: {maxBet} {Preferences.BaseCurrency}"); return; } var rewardValue = betAmount * (decimal)BetWin; if (QTCommands.CheckBalance(Context.Client.CurrentUser.Id, rewardValue + FantasyPortfolioModule.PrizePool)) { QTCommands.SendTip(Context.User.Id, Context.Client.CurrentUser.Id, betAmount); try { var coin = (CoinSide)RandomInteger(0, 2); //var coin = (CoinSide)Generator.Next(0, 2); var embed = new EmbedBuilder(); string message; if (coin == coinSide) { QTCommands.SendTip(DiscordClientNew._client.CurrentUser.Id, Context.User.Id, rewardValue); embed.AddInlineField("Flipped", FirstCharToUpper(coin.ToString())); embed.AddInlineField("Prize", $"{rewardValue} {Preferences.BaseCurrency}"); embed.AddInlineField("Profit", $"{(rewardValue - betAmount)} {Preferences.BaseCurrency}"); embed.WithColor(Discord.Color.Green); message = $"You won! Congratulations {Context.User.Mention}!"; } else { embed.AddInlineField("Flipped", FirstCharToUpper(coin.ToString())); embed.AddInlineField("Lost", $"{betAmount} {Preferences.BaseCurrency}"); embed.WithColor(Discord.Color.Red); message = $"Unlucky {Context.User.Mention}, you lost :("; } embed.WithFooter(Preferences.FooterText); await ReplyAsync(message, false, embed); using (var context = new FantasyPortfolio_DBEntities()) { var result = new FlipResults(); result.DateTime = DateTime.Now; result.UserId = Context.User.Id.ToString(); result.FlipResult = (byte)coin; result.UserFlip = (byte)coinSide; result.FlipValue = betAmount; context.FlipResults.Add(result); context.SaveChanges(); } Console.WriteLine($"{Context.User.Id} ({Context.User.Username}) bet on {side} and flipped {coin}"); } catch (Exception e) { Console.WriteLine(e.Message); QTCommands.SendTip(DiscordClientNew._client.CurrentUser.Id, Context.User.Id, betAmount); await ReplyAsync("Sorry something went wrong. You have been refunded your bet."); } } else { await ReplyAsync("Sorry, the bot is too poor to reward you if you won :("); } } else { await ReplyAsync("You do not have enough balance to perform this action"); } } } } else { await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel"); } }