Ejemplo n.º 1
0
        public async Task Wire([Summary("The amount of funds you wish to send.")] decimal amount,
                               [Summary("The user you wish to send funds to.")] SocketGuildUser user)
        {
            if (BankingHelpers.IsBelowMinimum(amount))
            {
                await InlineReply(Context.Message, $"The minimum amount you can send is `{_options.Currency}{BankingHelpers.MinimumAmount:N2}`");

                return;
            }

            var payerAccount = await _bankingService.GetOrCreateAccount(Context.User);

            var payeeAccount = await _bankingService.GetOrCreateAccount(user);

            if (!payerAccount.CanAfford(amount))
            {
                await InlineReply(Context.Message, "You don't have enough funds to make that transaction");

                return;
            }

            await _bankingService.Withdraw(payerAccount, amount);

            await _bankingService.Deposit(payeeAccount, amount);

            await ReplyAsync($"Transaction successful! {Context.User.Mention} sent `{_options.Currency}{amount:N2}` to {user.Mention}");
        }
Ejemplo n.º 2
0
        public async Task Wager([Summary("The ID of the bet you're betting on.")] int betId,
                                [Summary("Your stake in the bet")] decimal stake,
                                [Summary("If you're betting in favour or against the bet.")] bool inFavour)
        {
            var bet = await _bettingService.GetActiveBetById(betId);

            if (bet == null)
            {
                await InlineReply(Context.Message, $"There are no active bets with ID: `{betId}`");

                return;
            }

            var account = await _bankingService.GetOrCreateAccount(Context.User);

            if (BankingHelpers.IsBelowMinimum(stake))
            {
                await InlineReply(Context.Message, $"The minimum amount you can stake is `{_options.Currency}{BankingHelpers.MinimumAmount:N2}`");

                return;
            }

            if (!account.CanAfford(stake))
            {
                await InlineReply(Context.Message, "You don't have enough funds to make that bet");

                return;
            }

            await _bankingService.Withdraw(account, stake);

            await _bettingService.CreateWager(Context.User, betId, stake, inFavour);

            await ReplyAsync($"Wager placed! {Context.User.Mention} wagered `{_options.Currency}{stake:N2}` on bet ID: `{bet.Id}`");
        }
Ejemplo n.º 3
0
        public async Task Grant([Summary("The amount of funds you wish to grant.")] decimal amount,
                                [Summary("The user you wish to receive the grant.")] SocketGuildUser user = null)
        {
            if (BankingHelpers.IsBelowMinimum(amount))
            {
                await InlineReply(Context.Message, $"The minimum amount you can grant is `{_options.Currency}{BankingHelpers.MinimumAmount:N2}`");

                return;
            }

            var account = await _bankingService.GetOrCreateAccount(user ?? Context.User);

            await _bankingService.Deposit(account, amount);

            await ReplyAsync($"Grant successful! {(user ?? Context.User).Mention} has been granted `{_options.Currency}{amount:N2}`");
        }
Ejemplo n.º 4
0
        public async Task Fine([Summary("The size of the fine.")] decimal amount,
                               [Summary("The user you wish to fine.")] SocketGuildUser user)
        {
            if (BankingHelpers.IsBelowMinimum(amount))
            {
                await InlineReply(Context.Message, $"The minimum amount you can fine is `{_options.Currency}{BankingHelpers.MinimumAmount:N2}`");

                return;
            }

            var account = await _bankingService.GetOrCreateAccount(user);

            if (!account.CanAfford(amount))
            {
                await InlineReply(Context.Message, "That user can't afford to pay a fine of that size");

                return;
            }

            await _bankingService.Withdraw(account, amount);

            await ReplyAsync($"Fine successful! {user.Mention} has been fined `{_options.Currency}{amount:N2}`");
        }