| @@ -49,7 +49,7 @@ namespace Discord.Commands | |||||
| .Description("Returns information about commands.") | .Description("Returns information about commands.") | ||||
| .Do(async e => | .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 | if (e.Args.Length > 0) //Show command help | ||||
| { | { | ||||
| var map = _map.GetItem(string.Join(" ", e.Args)); | var map = _map.GetItem(string.Join(" ", e.Args)); | ||||
| @@ -42,7 +42,7 @@ namespace Discord.Legacy | |||||
| public static Task<Channel> CreatePMChannel(this DiscordClient client, User user) | public static Task<Channel> CreatePMChannel(this DiscordClient client, User user) | ||||
| { | { | ||||
| if (user == null) throw new ArgumentNullException(nameof(user)); | if (user == null) throw new ArgumentNullException(nameof(user)); | ||||
| return user.CreateChannel(); | |||||
| return user.CreatePMChannel(); | |||||
| } | } | ||||
| [Obsolete("Use Channel.Edit")] | [Obsolete("Use Channel.Edit")] | ||||
| public static Task EditChannel(this DiscordClient client, Channel channel, string name = null, string topic = null, int? position = null) | public static Task EditChannel(this DiscordClient client, Channel channel, string name = null, string topic = null, int? position = null) | ||||
| @@ -358,15 +358,17 @@ namespace Discord | |||||
| _privateChannels.TryGetValue(recipientId, out channel); | _privateChannels.TryGetValue(recipientId, out channel); | ||||
| return 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; | 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); | var response = await ClientAPI.Send(request).ConfigureAwait(false); | ||||
| channel = AddPrivateChannel(response.Id, user.Id); | |||||
| channel = AddPrivateChannel(response.Id, userId); | |||||
| channel.Update(response); | channel.Update(response); | ||||
| return channel; | return channel; | ||||
| } | } | ||||
| @@ -269,8 +269,8 @@ namespace Discord | |||||
| #endregion | #endregion | ||||
| #region Channels | #region Channels | ||||
| public Task<Channel> CreateChannel() | |||||
| => Client.CreatePrivateChannel(this); | |||||
| public Task<Channel> CreatePMChannel() | |||||
| => Client.CreatePMChannel(this); | |||||
| #endregion | #endregion | ||||
| #region Messages | #region Messages | ||||
| @@ -278,14 +278,14 @@ namespace Discord | |||||
| { | { | ||||
| if (text == null) throw new ArgumentNullException(nameof(text)); | 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); | return await channel.SendMessage(text).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<Message> SendFile(string filePath) | public async Task<Message> SendFile(string filePath) | ||||
| { | { | ||||
| if (filePath == null) throw new ArgumentNullException(nameof(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); | return await channel.SendFile(filePath).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<Message> SendFile(string filename, Stream stream) | public async Task<Message> SendFile(string filename, Stream stream) | ||||
| @@ -293,7 +293,7 @@ namespace Discord | |||||
| if (filename == null) throw new ArgumentNullException(nameof(filename)); | if (filename == null) throw new ArgumentNullException(nameof(filename)); | ||||
| if (stream == null) throw new ArgumentNullException(nameof(stream)); | 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); | return await channel.SendFile(filename, stream).ConfigureAwait(false); | ||||
| } | } | ||||
| #endregion | #endregion | ||||