Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from Mar 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion 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;
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
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
Expand Down
@@ -1,4 +1,4 @@
using Discord.Rest;
using Discord.Rest;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand Down