Skip to content

Commit

Permalink
Throw when attempting to modify a message not made by the current user (
Browse files Browse the repository at this point in the history
discord-net#992)

* Throw when attempting to modify a message not made by the current user

* Didn't realize the client is passed into the MessageHelper function

* Respond to feedback
  • Loading branch information
Joe4evr authored and FiniteReality committed May 5, 2018
1 parent bd30494 commit 7d9051c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Discord.API.Rest;
using Discord.API.Rest;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand All @@ -13,6 +13,9 @@ internal static class MessageHelper
public static async Task<Model> ModifyAsync(IMessage msg, BaseDiscordClient client, Action<MessageProperties> func,
RequestOptions options)
{
if (msg.Author.Id != client.CurrentUser.Id)
throw new InvalidOperationException("Only the author of a message may change it.");

var args = new MessageProperties();
func(args);
var apiArgs = new API.Rest.ModifyMessageParams
Expand Down
2 changes: 1 addition & 1 deletion src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Discord.Rest;
using Discord.Rest;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand Down

0 comments on commit 7d9051c

Please sign in to comment.