Added DeleteMessage, added ChannelId to outgoing messages

This commit is contained in:
Brandon Smith
2015-08-13 13:45:49 -03:00
parent a7455ba60f
commit adf30ad4e5
4 changed files with 21 additions and 14 deletions

View File

@@ -80,6 +80,8 @@ namespace Discord.API
}
public static Task SendIsTyping(string channelId, HttpOptions options)
=> Http.Post(Endpoints.ChannelTyping(channelId), options);
public static Task DeleteMessage(string channelId, string msgId, HttpOptions options)
=> Http.Delete(Endpoints.ChannelMessage(channelId, msgId), options);
//Voice
public static Task<APIResponses.GetRegions[]> GetVoiceRegions(HttpOptions options)

View File

@@ -18,15 +18,16 @@
// /api/channels
public static readonly string Channels = $"{BaseApi}/channels";
public static string Channel(string id) => $"{Channels}/{id}";
public static string ChannelTyping(string id) => $"{Channels}/{id}/typing";
public static string ChannelMessages(string id) => $"{Channels}/{id}/messages";
public static string ChannelMessages(string id, int limit) => $"{Channels}/{id}/messages?limit={limit}";
public static string ChannelInvites(string id) => $"{Channels}/{id}/invites";
public static string Channel(string channelId) => $"{Channels}/{channelId}";
public static string ChannelTyping(string channelId) => $"{Channels}/{channelId}/typing";
public static string ChannelMessages(string channelId) => $"{Channels}/{channelId}/messages";
public static string ChannelMessages(string channelId, int limit) => $"{Channels}/{channelId}/messages?limit={limit}";
public static string ChannelMessage(string channelId, string msgId) => $"{Channels}/{channelId}/messages/{msgId}";
public static string ChannelInvites(string channelId) => $"{Channels}/{channelId}/invites";
// /api/guilds
public static readonly string Servers = $"{BaseApi}/guilds";
public static string Server(string id) => $"{Servers}/{id}";
public static string Server(string serverId) => $"{Servers}/{serverId}";
public static string ServerChannels(string serverId) => $"{Servers}/{serverId}/channels";
public static string ServerMember(string serverId, string userId) => $"{Servers}/{serverId}/members/{userId}";
public static string ServerBan(string serverId, string userId) => $"{Servers}/{serverId}/bans/{userId}";

View File

@@ -31,13 +31,6 @@ namespace Discord
Disconnected(this, EventArgs.Empty);
}
/*public event EventHandler LoggedIn;
private void RaiseLoggedIn()
{
if (LoggedIn != null)
LoggedIn(this, EventArgs.Empty);
}*/
//Server
public sealed class ServerEventArgs : EventArgs
{

View File

@@ -591,7 +591,7 @@ namespace Discord
if (text.Length <= 2000)
{
var msg = await DiscordAPI.SendMessage(channelId, text, mentions, _httpOptions);
_messages.Update(msg.Id, msg);
_messages.Update(msg.Id, channelId, msg);
}
else
{
@@ -606,6 +606,17 @@ namespace Discord
}
}
public Task DeleteMessage(Message msg)
=> DeleteMessage(msg.ChannelId, msg.Id);
public async Task DeleteMessage(string channelId, string msgId)
{
try
{
await DiscordAPI.DeleteMessage(channelId, msgId, _httpOptions);
}
catch (WebException ex) when ((ex.Response as HttpWebResponse)?.StatusCode == HttpStatusCode.NotFound) { }
}
//Voice
public Task Mute(Server server, User user)
=> Mute(server.Id, user.Id);