Browse Source

Added DeleteMessage, added ChannelId to outgoing messages

tags/docs-0.9
Brandon Smith 9 years ago
parent
commit
adf30ad4e5
4 changed files with 21 additions and 14 deletions
  1. +2
    -0
      Discord.Net/API/DiscordAPI.cs
  2. +7
    -6
      Discord.Net/API/Endpoints.cs
  3. +0
    -7
      Discord.Net/DiscordClient.Events.cs
  4. +12
    -1
      Discord.Net/DiscordClient.cs

+ 2
- 0
Discord.Net/API/DiscordAPI.cs 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)


+ 7
- 6
Discord.Net/API/Endpoints.cs 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}";


+ 0
- 7
Discord.Net/DiscordClient.Events.cs 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
{


+ 12
- 1
Discord.Net/DiscordClient.cs 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);


Loading…
Cancel
Save