public async Task LinkEth([Remainder] string address) { NanoPool.UserAccount account = NanoPool.GetUser(Context.User, address); string msg = ""; if (account == null) { msg = "Account **" + address + "**\nNot Found!"; await PrintEmbedMessage("ETH Link Failed", msg); return; } if (account.discordID != Context.User.Id) { msg += "**Address:** " + account.address; msg += "\n**Already Linked:** " + account.discordUsername; } else { msg += "**Address:** " + account.address; msg += "\n**Now Linked:** " + account.discordUsername; } await PrintEmbedMessage("ETH Address Linked", msg); //await Context.Channel.SendMessageAsync(msg); }
public async Task Nanopool(SocketUser user) { NanoPool.UserAccount userAccount = NanoPool.GetUser(user); string address = userAccount.address; await PrintEmbedMessage("NanoPool Account", GetNanoPoolInfo(address, user)); }
public async Task Ethbal([Remainder] string address = null) { NanoPool.UserAccount account = NanoPool.GetUser(Context.User, address); string msg = ""; if (account == null) { msg = "Account **" + address + "**\nNot Found! Please use linketh cmd or enter an address to link!"; await PrintEmbedMessage("Account Retrieval Failed", msg); return; } if (address == null) { address = account.address; } double balance = double.Parse(EtherScan.GetBalance(address)) / 1000000000000000000d; NanoPool.Prices prices = NanoPool.GetPrices(); double usdBal = prices.price_usd * balance; double btcBal = prices.price_btc * balance; double gbpBal = prices.price_gbp * balance; double eurBal = prices.price_eur * balance; msg += "**Account:** " + address; msg += "\n**Balance:** " + string.Format("{0:N15} ETH", balance); msg += "\n**USD Value:** " + string.Format("${0:N2}", usdBal); msg += "\n**BTC Value:** " + string.Format("{0:N8} BTC", btcBal); await PrintEmbedMessage("Ethereum Balance", msg); //await Context.Channel.SendMessageAsync(msg); }
public async Task EthTokens([Remainder] string address = null) { NanoPool.UserAccount account = NanoPool.GetUser(Context.User, address); string msg = ""; if (account == null) { msg = "Account **" + address + "**\nNot Found! Please use linketh cmd or enter an address to link!"; await PrintEmbedMessage("Account Retrieval Failed", msg); return; } if (address == null) { address = account.address; } List <EtherScan.Token> tokens = EtherScan.GetTokens(address); string symbols = ""; int count = 0; foreach (EtherScan.Token token in tokens) { if (token.tokenSymbol != "" && !token.tokenName.ToLower().Contains("promo")) { if (count == 1) { symbols += ","; count = 0; } symbols += token.tokenSymbol; count++; } } Dictionary <string, CoinMarketCap.Currency> currencies = CoinMarketCap.GetTokens(symbols); count = 0; int num = 0; msg += "**Account:** " + address; double totalValue = 0; foreach (EtherScan.Token token in tokens) { int decPlace = 0; if (token.tokenDecimal != "0" && token.tokenDecimal != "") { decPlace = int.Parse(token.tokenDecimal); } double div = 1; for (int i = 0; i < decPlace; i++) { div *= 10d; } double balance = double.Parse(token.value) / div; if (currencies.ContainsKey(token.tokenSymbol)) { totalValue += currencies[token.tokenSymbol].quote.USD.price * balance; } } msg += string.Format("\n**Total Value:** ${0:N5}", totalValue); foreach (EtherScan.Token token in tokens) { int decPlace = 0; if (token.tokenDecimal != "0" && token.tokenDecimal != "") { decPlace = int.Parse(token.tokenDecimal); } double div = 1; for (int i = 0; i < decPlace; i++) { div *= 10d; } msg += "\n\n**Name:** " + token.tokenName; msg += "\n**Symbol:** " + token.tokenSymbol; double balance = double.Parse(token.value) / div; if (decPlace == 0) { msg += "\n**Balance:** " + string.Format("{0:N0} " + token.tokenSymbol, balance); } if (decPlace == 8) { msg += "\n**Balance:** " + string.Format("{0:N8} " + token.tokenSymbol, balance); } if (decPlace == 18) { msg += "\n**Balance:** " + string.Format("{0:N15} " + token.tokenSymbol, balance); } if (currencies.ContainsKey(token.tokenSymbol)) { msg += string.Format("\n**USD Value:** ${0:N15}", currencies[token.tokenSymbol].quote.USD.price * balance); } msg += "\n**Date:** " + SteamAccounts.UnixTimeStampToDateTime(double.Parse(token.timeStamp)); msg += "\n**Confirmations:** " + string.Format("{0:N0}", ulong.Parse(token.confirmations)); if (count > 8) { msg += "|"; count = 0; } count++; num++; } string[] split = msg.Split('|'); for (int i = 0; i < split.Length; i++) { await PrintEmbedMessage("ETH Tokens", split[i]); } //await Context.Channel.SendMessageAsync(msg); }