Browse Source

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

pull/992/head
Joe4evr 8 years ago
parent
commit
1dfd8c8be6
2 changed files with 9 additions and 3 deletions
  1. +3
    -1
      src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
  2. +6
    -2
      src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs

+ 3
- 1
src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
@@ -126,6 +126,8 @@ namespace Discord.Rest

public async Task ModifyAsync(Action<MessageProperties> 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);
}


+ 6
- 2
src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs View File

@@ -1,4 +1,4 @@
using Discord.Rest;
using Discord.Rest;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
@@ -122,7 +122,11 @@ namespace Discord.WebSocket
}

public Task ModifyAsync(Action<MessageProperties> func, RequestOptions options = null)
=> MessageHelper.ModifyAsync(this, Discord, func, options);
{
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);
}

public Task AddReactionAsync(IEmote emote, RequestOptions options = null)
=> MessageHelper.AddReactionAsync(this, emote, Discord, options);


Loading…
Cancel
Save