Example #1
0
 public static async Task <string> Format(this IPendingTransaction transaction, IUserService users, bool mention = false)
 {
     return(await TransactionFormatting.FormatTransaction(
                users,
                transaction.FromId,
                transaction.ToId,
                transaction.Note,
                transaction.Instant,
                transaction.Amount,
                transaction.Unit,
                mention
                ));
 }
Example #2
0
        public async Task CreateDebt(IUser user, decimal amount, string unit, [Remainder] string?note = null)
        {
            if (amount < 0)
            {
                await RespondAsync("You cannot owe a negative amount!");

                return;
            }

            var message = $"{Context.User.Mention} owes {TransactionFormatting.FormatCurrency(amount, unit)} to {user.Mention}";

            var confirmed = await InteractionUtility.ConfirmAsync(_client, Context.Channel, TimeSpan.FromMinutes(1), message);

            if (!confirmed)
            {
                await RespondAsync("Confirmation timed out. Cancelled transaction!");

                return;
            }

            await _transactions.CreateTransaction(user.Id, Context.User.Id, amount, unit, note, DateTime.UtcNow);

            await RespondAsync(message);
        }