mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-14 01:36:08 +03:00
Do not wrap result errors when returning them (#73)
This PR removes the wrapping of in-house created result errors with `Result.FromError` (I did not know this was possible until today, lol), which reduces code verbosity and makes it easier to read, and replaces `ArgumentNullError` with `ArgumentInvalidError` when retrieving IDs from a command context, which, in my opinion, is more correct. --------- Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
a6df26af67
commit
f47ebe81c5
17 changed files with 34 additions and 45 deletions
|
@ -68,8 +68,7 @@ public class MuteCommandGroup : CommandGroup {
|
|||
[Description("Mute reason")] string reason,
|
||||
[Description("Mute duration")] TimeSpan duration) {
|
||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var userId))
|
||||
return Result.FromError(
|
||||
new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context"));
|
||||
return new ArgumentInvalidError(nameof(_context), "Unable to retrieve necessary IDs from command context");
|
||||
|
||||
// The current user's avatar is used when sending error messages
|
||||
var currentUserResult = await _userApi.GetCurrentUserAsync(CancellationToken);
|
||||
|
@ -162,8 +161,7 @@ public class MuteCommandGroup : CommandGroup {
|
|||
[Description("Member to unmute")] IUser target,
|
||||
[Description("Unmute reason")] string reason) {
|
||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var userId))
|
||||
return Result.FromError(
|
||||
new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context"));
|
||||
return new ArgumentInvalidError(nameof(_context), "Unable to retrieve necessary IDs from command context");
|
||||
|
||||
// The current user's avatar is used when sending error messages
|
||||
var currentUserResult = await _userApi.GetCurrentUserAsync(CancellationToken);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue