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

59 lines
1.9 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; }
2017-05-16 22:45:28 +00:00
public DiscordChannelType Type { get; internal set; }
2017-05-14 12:02:51 +00:00
2017-05-17 22:33:09 +00:00
public int Position { get; internal set; }
public string Topic { get; internal set; }
public ulong LastMessageId { get; internal set; }
public int Bitrate { get; internal set; }
public int UserLimit { get; internal set; }
public override string ToString() => $@"<#{Id}>";
internal DiscordChannel(Discord discord, Channel channel, DiscordServer server = null)
2017-05-14 12:02:51 +00:00
{
client = discord;
Id = channel.Id;
Name = channel.Name;
2017-05-16 22:45:28 +00:00
Type = (DiscordChannelType)channel.Type;
2017-05-17 22:33:09 +00:00
Position = channel.Position ?? 0;
Topic = channel.Topic;
LastMessageId = channel.LastMessageId ?? 0;
Bitrate = channel.Bitrate ?? 0;
UserLimit = channel.UserLimit ?? 0;
2017-05-14 12:02:51 +00:00
Server = server;
}
2017-05-21 01:08:34 +00:00
public DiscordMessage Send(string text = "", DiscordEmbed embed = null)
2017-05-20 01:29:03 +00:00
{
RestResponse<Message> msg = client.RestClient.Request<Message>(
RestRequestMethod.POST,
RestEndpoints.ChannelMessages(Id),
new MessageCreate
{
Text = text,
2017-05-21 01:08:34 +00:00
Embed = embed?.ToStruct(),
2017-05-20 01:29:03 +00:00
}
);
2017-05-21 01:30:45 +00:00
DiscordMessage message = new DiscordMessage(client, msg.Response, this, client.members.Find(x => x.User.Id == msg.Response.User.Id));
2017-05-20 01:29:03 +00:00
client.messages.Add(message);
return message;
}
2017-05-14 12:02:51 +00:00
}
}