From 7b692b7493a324da2f1bb275d9af01f1aab05c66 Mon Sep 17 00:00:00 2001 From: Joe4evr Date: Fri, 23 Mar 2018 12:23:00 +0100 Subject: [PATCH] Didn't realize the client is passed into the MessageHelper function --- src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs | 5 ++++- src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs | 2 -- .../Entities/Messages/SocketUserMessage.cs | 6 +----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs index 47bb6f926..56511c10a 100644 --- a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs +++ b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs @@ -1,4 +1,4 @@ -using Discord.API.Rest; +using Discord.API.Rest; using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -13,6 +13,9 @@ namespace Discord.Rest public static async Task ModifyAsync(IMessage msg, BaseDiscordClient client, Action func, RequestOptions options) { + if (msg.Author.Id != client.CurrentUser.Id) + throw new InvalidOperationException("Discord allows only the author of a message to change it."); + var args = new MessageProperties(); func(args); var apiArgs = new API.Rest.ModifyMessageParams diff --git a/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs index d47673002..0d1f3be2b 100644 --- a/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs +++ b/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs @@ -126,8 +126,6 @@ namespace Discord.Rest public async Task ModifyAsync(Action func, RequestOptions options = null) { - if (Author.Id != Discord.CurrentUser.Id) - throw new InvalidOperationException("Discord allows only the author of a message to change it."); var model = await MessageHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); Update(model); } diff --git a/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs b/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs index 3ae9ae4e1..5489ad2bb 100644 --- a/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs +++ b/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs @@ -122,11 +122,7 @@ namespace Discord.WebSocket } public Task ModifyAsync(Action func, RequestOptions options = null) - { - if (Author.Id != Discord.CurrentUser.Id) - throw new InvalidOperationException("Discord allows only the author of a message to change it."); - return MessageHelper.ModifyAsync(this, Discord, func, options); - } + => MessageHelper.ModifyAsync(this, Discord, func, options); public Task AddReactionAsync(IEmote emote, RequestOptions options = null) => MessageHelper.AddReactionAsync(this, emote, Discord, options);