2

I'm trying to edit a message that my bot sent, but I can't seem to find any answers by myself. For context, the old message is a "waiting" message until the API I'm using retrieves the data I want. The new message is what the data that was received.

This is my current solution:

var msg = await ReplyAsync("old message");

//... unrelated code ...    

await msg.DeleteAsync();
await ReplyAsync("new message");

The arguments for ModifyAsync(); are Action<MessageProperties> funct, [RequestOptions options].

I've attempted to use ModifyAsync(); myself, to no avail.

All I want to do is modify the content of the message, and all of the research I've done leads to earlier versions of the Discord.Net library.

How can I do this correctly?

xubiod
  • 21
  • 1
  • 1
  • 4

2 Answers2

2

I did some research and found this : https://github.com/RogueException/Discord.Net/issues/474

I know it isn't modifying a message but it works the same way, you pass it a lambda expression:

var Message = await Context.Channel.SendMessageAsync("test message");

await Message.ModifyAsync(msg => msg.Content = "test [edited]");
Unknown
  • 769
  • 2
  • 7
  • 17
  • This method doesn't actually work. This is the error message returned: `A local or parameter named 'msg' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter` – xubiod Sep 12 '17 at 22:47
  • This solution does work, the error is caused by something on your end. You probably have a variable name that is the same as another. – Unknown Sep 13 '17 at 22:59
  • https://stackoverflow.com/questions/6156449/why-cant-a-duplicate-variable-name-be-declared-in-a-nested-local-scope Take a look at this link, it should be of use. @xubiod – Unknown Sep 15 '17 at 16:25
0
await Context.Channel.SendMessageAsync("Test.");
await Context.Message.ModifyAsync(m => { m.Content = "Test [Edited]."; });

I hope that helps

Leonardo Alves Machado
  • 2,747
  • 10
  • 38
  • 53