diff --git a/Discord.Net/API/DiscordAPI.cs b/Discord.Net/API/DiscordAPI.cs index 9ea171692..6b14c5225 100644 --- a/Discord.Net/API/DiscordAPI.cs +++ b/Discord.Net/API/DiscordAPI.cs @@ -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 GetVoiceRegions(HttpOptions options) diff --git a/Discord.Net/API/Endpoints.cs b/Discord.Net/API/Endpoints.cs index 292d0cc9e..022eed5d0 100644 --- a/Discord.Net/API/Endpoints.cs +++ b/Discord.Net/API/Endpoints.cs @@ -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}"; diff --git a/Discord.Net/DiscordClient.Events.cs b/Discord.Net/DiscordClient.Events.cs index 8316b196c..6e604e021 100644 --- a/Discord.Net/DiscordClient.Events.cs +++ b/Discord.Net/DiscordClient.Events.cs @@ -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 { diff --git a/Discord.Net/DiscordClient.cs b/Discord.Net/DiscordClient.cs index 28cbb3a19..cb4fac018 100644 --- a/Discord.Net/DiscordClient.cs +++ b/Discord.Net/DiscordClient.cs @@ -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);