Renamed User.CreateChannel to CreatePMChannel, added DiscordClient.CreatePMChannel(userId)

This commit is contained in:
RogueException
2015-12-31 04:24:23 -04:00
parent c19a353549
commit aa040193a1
4 changed files with 13 additions and 11 deletions

View File

@@ -49,7 +49,7 @@ namespace Discord.Commands
.Description("Returns information about commands.")
.Do(async e =>
{
Channel replyChannel = _config.HelpMode == HelpMode.Public ? e.Channel : await e.User.CreateChannel().ConfigureAwait(false);
Channel replyChannel = _config.HelpMode == HelpMode.Public ? e.Channel : await e.User.CreatePMChannel().ConfigureAwait(false);
if (e.Args.Length > 0) //Show command help
{
var map = _map.GetItem(string.Join(" ", e.Args));

View File

@@ -42,7 +42,7 @@ namespace Discord.Legacy
public static Task<Channel> CreatePMChannel(this DiscordClient client, User user)
{
if (user == null) throw new ArgumentNullException(nameof(user));
return user.CreateChannel();
return user.CreatePMChannel();
}
[Obsolete("Use Channel.Edit")]
public static Task EditChannel(this DiscordClient client, Channel channel, string name = null, string topic = null, int? position = null)

View File

@@ -358,15 +358,17 @@ namespace Discord
_privateChannels.TryGetValue(recipientId, out channel);
return channel;
}
internal async Task<Channel> CreatePrivateChannel(User user)
internal Task<Channel> CreatePMChannel(User user)
=> CreatePrivateChannel(user.Id);
public async Task<Channel> CreatePrivateChannel(ulong userId)
{
var channel = GetPrivateChannel(user.Id);
var channel = GetPrivateChannel(userId);
if (channel != null) return channel;
var request = new CreatePrivateChannelRequest() { RecipientId = user.Id };
var request = new CreatePrivateChannelRequest() { RecipientId = userId };
var response = await ClientAPI.Send(request).ConfigureAwait(false);
channel = AddPrivateChannel(response.Id, user.Id);
channel = AddPrivateChannel(response.Id, userId);
channel.Update(response);
return channel;
}

View File

@@ -269,8 +269,8 @@ namespace Discord
#endregion
#region Channels
public Task<Channel> CreateChannel()
=> Client.CreatePrivateChannel(this);
public Task<Channel> CreatePMChannel()
=> Client.CreatePMChannel(this);
#endregion
#region Messages
@@ -278,14 +278,14 @@ namespace Discord
{
if (text == null) throw new ArgumentNullException(nameof(text));
var channel = await CreateChannel().ConfigureAwait(false);
var channel = await CreatePMChannel().ConfigureAwait(false);
return await channel.SendMessage(text).ConfigureAwait(false);
}
public async Task<Message> SendFile(string filePath)
{
if (filePath == null) throw new ArgumentNullException(nameof(filePath));
var channel = await CreateChannel().ConfigureAwait(false);
var channel = await CreatePMChannel().ConfigureAwait(false);
return await channel.SendFile(filePath).ConfigureAwait(false);
}
public async Task<Message> SendFile(string filename, Stream stream)
@@ -293,7 +293,7 @@ namespace Discord
if (filename == null) throw new ArgumentNullException(nameof(filename));
if (stream == null) throw new ArgumentNullException(nameof(stream));
var channel = await CreateChannel().ConfigureAwait(false);
var channel = await CreatePMChannel().ConfigureAwait(false);
return await channel.SendFile(filename, stream).ConfigureAwait(false);
}
#endregion