Added Create/Destroy Channel

This commit is contained in:
Brandon Smith
2015-08-11 00:01:46 -03:00
parent 1c52a62fb6
commit 1d222e9f3e
9 changed files with 70 additions and 43 deletions

View File

@@ -73,7 +73,7 @@ namespace Discord
foreach (var channel in extendedModel.Channels)
{
_channels.Update(channel.Id, model.Id, channel);
if (channel.Type == "text")
if (channel.Type == ChannelTypes.Text)
{
try
{
@@ -437,6 +437,24 @@ namespace Discord
return _servers.Remove(id);
}
//Channels
public Task<Channel> CreateChannel(Server server, string name, string region)
=> CreateChannel(server.Id, name, region);
public async Task<Channel> CreateChannel(string serverId, string name, string region)
{
CheckReady();
var response = await DiscordAPI.CreateChannel(serverId, name, region, _httpOptions);
return _channels.Update(response.Id, response);
}
public Task<Channel> DestroyChannel(Channel channel)
=> DestroyChannel(channel.Id);
public async Task<Channel> DestroyChannel(string channelId)
{
CheckReady();
var response = await DiscordAPI.DestroyChannel(channelId, _httpOptions);
return _channels.Remove(response.Id);
}
//Bans
public Task Ban(Server server, User user)
=> Ban(server.Id, user.Id);