public async Task Deny([NotNull] string input) { var fid = FriendlyId32.Parse(input); if (!fid.HasValue) { await TypingReplyAsync("Invalid ID `{id}`"); return; } var transactions = await(await _pending.Get(debtId: fid.Value.Value)).ToArray(); if (transactions.Length == 0) { await TypingReplyAsync($"Cannot find a transaction with ID `{fid}`"); return; } if (transactions.Length > 1) { await TypingReplyAsync($"Found multiple transactions with ID `{fid}`! This is probably an error, please report it."); return; } var transaction = transactions[0]; if (transaction.ToId != Context.User.Id) { await TypingReplyAsync("You cannot deny this transaction"); return; } var result = await _pending.DenyPending(fid.Value.Value); switch (result) { case DenyResult.Denied: await TypingReplyAsync($"Denied {TransactionFormatting.FormatTransaction(this, transaction, true)}"); break; case DenyResult.AlreadyDenied: await TypingReplyAsync("This transaction has already been denied"); break; case DenyResult.AlreadyConfirmed: await TypingReplyAsync("This transaction has already been confirmed and can no longer be denied"); break; case DenyResult.IdNotFound: await TypingReplyAsync($"Cannot find a transaction with ID `{fid}`! This is probably an error, please report it."); break; default: await TypingReplyAsync($"Unknown transaction state `{result}`! This is probably an error, please report it."); throw new ArgumentOutOfRangeException(); } }
public async Task Deny(string input) { var fid = BalderHash32.Parse(input); if (!fid.HasValue) { await RespondAsync($"Invalid ID `{fid}`"); return; } var transactions = await _pending.Get(debtId : fid.Value.Value).ToListAsync(); if (transactions.Count == 0) { await RespondAsync($"Cannot find a transaction with ID `{fid}`"); return; } if (transactions.Count > 1) { await RespondAsync($"Found multiple transactions with ID `{fid}`! This is probably an error, please report it."); return; } var transaction = transactions[0]; if (transaction.ToId != Context.User.Id) { await RespondAsync("You cannot deny a transaction which does not belong to you"); return; } var result = await _pending.DenyPending(fid.Value.Value); switch (result) { case DenyResult.Denied: await RespondAsync($"Denied {await transaction.Format(_users, true)}"); break; case DenyResult.AlreadyDenied: await RespondAsync("This transaction has already been denied"); break; case DenyResult.AlreadyConfirmed: await RespondAsync("This transaction has already been confirmed and can no longer be denied"); break; case DenyResult.IdNotFound: await RespondAsync($"Cannot find a transaction with ID `{fid}`! This is probably an error, please report it."); break; default: await RespondAsync($"Unknown transaction state `{result}`! This is probably an error, please report it."); throw new ArgumentOutOfRangeException(); } }