Archived
1
0
Fork 0
This commit is contained in:
flash 2017-05-20 03:29:03 +02:00
parent 0c2bab4a94
commit 699694db7c
4 changed files with 49 additions and 2 deletions

View file

@ -69,5 +69,22 @@ namespace Maki
client.messages.Add(message);
return message;
}
public DiscordMessage Send(string text, DiscordEmbed embed)
{
RestResponse<Message> msg = client.RestClient.Request<Message>(
RestRequestMethod.POST,
RestEndpoints.ChannelMessages(Id),
new MessageCreate
{
Text = text,
Embed = embed.ToStruct(),
}
);
DiscordMessage message = new DiscordMessage(client, msg.Response, client.members.Find(x => x.User.Id == msg.Response.User.Id), this);
client.messages.Add(message);
return message;
}
}
}

View file

@ -1,4 +1,6 @@
using Maki.Structures.Messages;
using Maki.Rest;
using Maki.Structures.Messages;
using Maki.Structures.Rest;
using System;
using System.Linq;
@ -40,9 +42,22 @@ namespace Maki
IsPinned = msg.IsPinned == true;
}
public DiscordMessage Edit(string text)
public DiscordMessage Edit(string text = null, DiscordEmbed embed = null)
{
RestResponse<Message> msg = client.RestClient.Request<Message>(RestRequestMethod.PATCH, RestEndpoints.ChannelMessage(Channel.Id, Id), new MessageEdit {
Text = text,
Embed = embed?.ToStruct(),
});
Text = msg.Response.Content;
Edited = msg.Response.Edited ?? DateTime.UtcNow;
return this;
}
public void Delete()
{
client.RestClient.Request<object>(RestRequestMethod.DELETE, RestEndpoints.ChannelMessage(Channel.Id, Id));
}
}
}

View file

@ -119,6 +119,7 @@
<Compile Include="Structures\Presences\TypingStart.cs" />
<Compile Include="Structures\Rest\Error.cs" />
<Compile Include="Structures\Rest\MessageCreate.cs" />
<Compile Include="Structures\Rest\MessageEdit.cs" />
<Compile Include="Structures\Rest\RoleCreate.cs" />
<Compile Include="Structures\Roles\Role.cs" />
<Compile Include="Structures\Users\PermissionOverwrite.cs" />

View file

@ -0,0 +1,14 @@
using Maki.Structures.Embeds;
using Newtonsoft.Json;
namespace Maki.Structures.Rest
{
internal struct MessageEdit
{
[JsonProperty("content")]
public string Text;
[JsonProperty("embed")]
public Embed? Embed;
}
}