57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
|
using Maki.Rest;
|
|||
|
using Maki.Structures.Channels;
|
|||
|
using Maki.Structures.Messages;
|
|||
|
using Maki.Structures.Rest;
|
|||
|
|
|||
|
namespace Maki
|
|||
|
{
|
|||
|
public class DiscordChannel
|
|||
|
{
|
|||
|
public readonly ulong Id;
|
|||
|
public readonly DiscordServer Server;
|
|||
|
private readonly Discord client;
|
|||
|
|
|||
|
public string Name { get; internal set; }
|
|||
|
|
|||
|
internal DiscordChannel(Discord discord, Channel channel, DiscordServer server)
|
|||
|
{
|
|||
|
client = discord;
|
|||
|
Id = channel.Id;
|
|||
|
Name = channel.Name;
|
|||
|
Server = server;
|
|||
|
}
|
|||
|
|
|||
|
public DiscordMessage Send(string text)
|
|||
|
{
|
|||
|
RestResponse<Message> msg = client.RestClient.Request<Message>(
|
|||
|
RestRequestMethod.POST,
|
|||
|
RestEndpoints.ChannelMessages(Id),
|
|||
|
new MessageCreate {
|
|||
|
Text = text,
|
|||
|
}
|
|||
|
);
|
|||
|
|
|||
|
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;
|
|||
|
}
|
|||
|
|
|||
|
public DiscordMessage Send(DiscordEmbed embed)
|
|||
|
{
|
|||
|
RestResponse<Message> msg = client.RestClient.Request<Message>(
|
|||
|
RestRequestMethod.POST,
|
|||
|
RestEndpoints.ChannelMessages(Id),
|
|||
|
new MessageCreate
|
|||
|
{
|
|||
|
Text = string.Empty,
|
|||
|
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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|