Browse Source

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

tags/docs-0.9
RogueException 9 years ago
parent
commit
aa040193a1
4 changed files with 13 additions and 11 deletions
  1. +1
    -1
      src/Discord.Net.Commands/CommandService.cs
  2. +1
    -1
      src/Discord.Net/DiscordClient.Obsolete.cs
  3. +6
    -4
      src/Discord.Net/DiscordClient.cs
  4. +5
    -5
      src/Discord.Net/Models/User.cs

+ 1
- 1
src/Discord.Net.Commands/CommandService.cs 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));


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


+ 6
- 4
src/Discord.Net/DiscordClient.cs 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;
}


+ 5
- 5
src/Discord.Net/Models/User.cs 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


Loading…
Cancel
Save