Exemple #1
0
        [Command("wallet")] // Get by mention
        public async Task WalletAsync(SocketUser User, [Remainder] string Remainder = "")
        {
            // Delete original message
            try { await Context.Message.DeleteAsync(); }
            catch { }

            // Try to grab address from the database
            string Address = "";

            if (TrtlBotSharp.CheckUserExists(User.Id))
            {
                Address = TrtlBotSharp.GetAddress(User.Id);
            }

            // Check if result is empty
            if (string.IsNullOrEmpty(Address))
            {
                await Context.Message.Author.SendMessageAsync(string.Format("{0} hasn't registered a wallet!", User.Username));
            }

            // Check if user is requesting their own wallet
            else if (User == null || Context.Message.Author.Id == User.Id)
            {
                await Context.Message.Author.SendMessageAsync(string.Format("**Your wallet:**```{0}```", Address));
            }

            // User is requesting someone else's wallet
            else
            {
                await Context.Message.Author.SendMessageAsync(string.Format("**{0}'s wallet:**```{1}```", User.Username, Address));
            }
        }
Exemple #2
0
        [Command("wallet")] // Get own wallet
        public async Task WalletAsync([Remainder] string Remainder = "")
        {
            // Delete original message
            try { await Context.Message.DeleteAsync(); }
            catch { }

            // Try to grab address from the database
            string Address = "";

            if (TrtlBotSharp.CheckUserExists(Context.Message.Author.Id))
            {
                Address = TrtlBotSharp.GetAddress(Context.Message.Author.Id);
            }

            // Check if result is empty
            if (string.IsNullOrEmpty(Address))
            {
                await Context.Message.Author.SendMessageAsync(string.Format("You haven't registered a wallet! Use {0}help if you need any help.",
                                                                            TrtlBotSharp.botPrefix));
            }

            // Check if user is requesting their own wallet
            else
            {
                await Context.Message.Author.SendMessageAsync(string.Format("**Your wallet:**```{0}```", Address));
            }
        }
Exemple #3
0
        public async Task WithdrawAsync(string Amount, [Remainder] string Remainder = "")
        {
            // Delete original message
            try { await Context.Message.DeleteAsync(); }
            catch { }

            // Check if user exists in user table
            if (!TrtlBotSharp.CheckUserExists(Context.Message.Author.Id))
            {
                await Context.Message.Author.SendMessageAsync(string.Format("You must register a wallet before you can withdraw! Use {0}help if you need any help.", TrtlBotSharp.botPrefix));

                return;
            }

            // Check that amount is over the minimum fee
            else if (Convert.ToDecimal(Amount) < TrtlBotSharp.Minimum)//TrtlBotSharp.Fee)
            {
                await ReplyAsync(string.Format("Amount must be at least {0:N} {1}", TrtlBotSharp.Minimum /*Fee*/, TrtlBotSharp.coinSymbol));

                return;
            }

            // Check if user has enough balance
            else if (TrtlBotSharp.GetBalance(Context.Message.Author.Id) < Convert.ToDecimal(Amount) + TrtlBotSharp.tipFee)
            {
                await Context.Message.Author.SendMessageAsync(string.Format("Your balance is too low! Amount + Fee = **{0:N}** {1}",
                                                                            Convert.ToDecimal(Amount) + TrtlBotSharp.tipFee, TrtlBotSharp.coinSymbol));

                await Context.Message.AddReactionAsync(new Emoji(TrtlBotSharp.tipLowBalanceReact));
            }

            // Send withdrawal
            else if (TrtlBotSharp.Tip(Context.Message.Author.Id, TrtlBotSharp.GetAddress(Context.Message.Author.Id), Convert.ToDecimal(Amount)))
            {
                // Send success react
                await Context.Message.AddReactionAsync(new Emoji(TrtlBotSharp.tipSuccessReact));
            }
        }