mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-10 16:03:15 +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
|
@ -29,7 +29,7 @@ public class GuildMemberJoinedResponder : IResponder<IGuildMemberAdd> {
|
|||
|
||||
public async Task<Result> RespondAsync(IGuildMemberAdd gatewayEvent, CancellationToken ct = default) {
|
||||
if (!gatewayEvent.User.IsDefined(out var user))
|
||||
return Result.FromError(new ArgumentNullError(nameof(gatewayEvent.User)));
|
||||
return new ArgumentNullError(nameof(gatewayEvent.User));
|
||||
var data = await _dataService.GetData(gatewayEvent.GuildID, ct);
|
||||
var cfg = data.Settings;
|
||||
if (GuildSettings.PublicFeedbackChannel.Get(cfg).Empty()
|
||||
|
|
|
@ -45,9 +45,9 @@ public class MessageEditedResponder : IResponder<IMessageUpdate> {
|
|||
return Result.FromSuccess(); // The message wasn't actually edited
|
||||
|
||||
if (!gatewayEvent.ChannelID.IsDefined(out var channelId))
|
||||
return Result.FromError(new ArgumentNullError(nameof(gatewayEvent.ChannelID)));
|
||||
return new ArgumentNullError(nameof(gatewayEvent.ChannelID));
|
||||
if (!gatewayEvent.ID.IsDefined(out var messageId))
|
||||
return Result.FromError(new ArgumentNullError(nameof(gatewayEvent.ID)));
|
||||
return new ArgumentNullError(nameof(gatewayEvent.ID));
|
||||
|
||||
var cacheKey = new KeyHelpers.MessageCacheKey(channelId, messageId);
|
||||
var messageResult = await _cacheService.TryGetValueAsync<IMessage>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue