Archived
1
0
Fork 0
This repository has been archived on 2024-05-21. You can view files and clone it, but cannot push or open issues or pull requests.
maki/Maki/DiscordChannel.cs

57 lines
1.7 KiB
C#
Raw Normal View History

2017-05-14 12:02:51 +00:00
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;
}
}
}