Browse Source

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

pull/992/head
Joe4evr 8 years ago
parent
commit
7b692b7493
3 changed files with 5 additions and 8 deletions
  1. +4
    -1
      src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs
  2. +0
    -2
      src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
  3. +1
    -5
      src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs

+ 4
- 1
src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs View File

@@ -1,4 +1,4 @@
using Discord.API.Rest;
using Discord.API.Rest;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
@@ -13,6 +13,9 @@ namespace Discord.Rest
public static async Task<Model> ModifyAsync(IMessage msg, BaseDiscordClient client, Action<MessageProperties> func, public static async Task<Model> ModifyAsync(IMessage msg, BaseDiscordClient client, Action<MessageProperties> func,
RequestOptions options) 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(); var args = new MessageProperties();
func(args); func(args);
var apiArgs = new API.Rest.ModifyMessageParams var apiArgs = new API.Rest.ModifyMessageParams


+ 0
- 2
src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs View File

@@ -126,8 +126,6 @@ namespace Discord.Rest


public async Task ModifyAsync(Action<MessageProperties> func, RequestOptions options = null) 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); var model = await MessageHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model); Update(model);
} }


+ 1
- 5
src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs View File

@@ -122,11 +122,7 @@ namespace Discord.WebSocket
} }


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


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


Loading…
Cancel
Save