Browse Source

Added path property to all models for logging

tags/docs-0.9
RogueException 9 years ago
parent
commit
bc7edbf3c7
7 changed files with 18 additions and 6 deletions
  1. +5
    -3
      src/Discord.Net/Models/Channel.cs
  2. +4
    -2
      src/Discord.Net/Models/Invite.cs
  3. +2
    -0
      src/Discord.Net/Models/Message.cs
  4. +1
    -1
      src/Discord.Net/Models/Profile.cs
  5. +2
    -0
      src/Discord.Net/Models/Role.cs
  6. +2
    -0
      src/Discord.Net/Models/Server.cs
  7. +2
    -0
      src/Discord.Net/Models/User.cs

+ 5
- 3
src/Discord.Net/Models/Channel.cs View File

@@ -41,11 +41,11 @@ namespace Discord
Permissions = new ChannelPermissionOverrides(allow, deny);
}
}
private readonly ConcurrentDictionary<ulong, Member> _users;
private readonly ConcurrentDictionary<ulong, Message> _messages;
private Dictionary<ulong, PermissionOverwrite> _permissionOverwrites;
public DiscordClient Client { get; }

/// <summary> Gets the unique identifier for this channel. </summary>
@@ -64,6 +64,8 @@ namespace Discord
/// <summary> Gets the type of this channel). </summary>
public ChannelType Type { get; private set; }

/// <summary> Gets the path to this object. </summary>
internal string Path => $"{Server?.Name ?? "[Private]"}/{Name}";
/// <summary> Gets true if this is a private chat with another user. </summary>
public bool IsPrivate => Recipient != null;
/// <summary> Gets the string used to mention this channel. </summary>
@@ -345,7 +347,7 @@ namespace Discord
public async Task<Message> SendFile(string filePath)
{
using (var stream = File.OpenRead(filePath))
return await SendFile(Path.GetFileName(filePath), stream).ConfigureAwait(false);
return await SendFile(System.IO.Path.GetFileName(filePath), stream).ConfigureAwait(false);
}
public async Task<Message> SendFile(string filename, Stream stream)
{


+ 4
- 2
src/Discord.Net/Models/Invite.cs View File

@@ -85,8 +85,10 @@ namespace Discord
/// <summary> Gets when this invite was created. </summary>
public DateTime CreatedAt { get; private set; }

/// <summary> Returns a URL for this invite using XkcdCode if available or Id if not. </summary>
public string Url => $"{DiscordConfig.InviteUrl}/{Code}";
/// <summary> Gets the path to this object. </summary>
internal string Path => $"{Server?.Name ?? "[Private]"}/{Code}";
/// <summary> Returns a URL for this invite using XkcdCode if available or Id if not. </summary>
public string Url => $"{DiscordConfig.InviteUrl}/{Code}";

internal Invite(DiscordClient client, string code, string xkcdPass)
{


+ 2
- 0
src/Discord.Net/Models/Message.cs View File

@@ -201,6 +201,8 @@ namespace Discord

internal int Nonce { get; set; }

/// <summary> Gets the path to this object. </summary>
internal string Path => $"{Server?.Name ?? "[Private]"}/{Id}";
/// <summary> Returns the server containing the channel this message was sent to. </summary>
public Server Server => Channel.Server;
/// <summary> Returns if this message was sent from the logged-in accounts. </summary>


+ 1
- 1
src/Discord.Net/Models/Profile.cs View File

@@ -28,7 +28,7 @@ namespace Discord
public UserStatus Status => Client.PrivateUser.Status;
/// <summary> Returns the string used to mention this user. </summary>
public string Mention => $"<@{Id}>";
/// <summary> Gets the email for this user. </summary>
public string Email { get; private set; }
/// <summary> Gets if the email for this user has been verified. </summary>


+ 2
- 0
src/Discord.Net/Models/Role.cs View File

@@ -33,6 +33,8 @@ namespace Discord
/// <summary> Gets the color of this role. </summary>
public Color Color { get; private set; }

/// <summary> Gets the path to this object. </summary>
internal string Path => $"{Server?.Name ?? "[Private]"}/{Name}";
/// <summary> Gets true if this is the role representing all users in a server. </summary>
public bool IsEveryone => Id == Server.Id;
/// <summary> Gets a list of all members in this role. </summary>


+ 2
- 0
src/Discord.Net/Models/Server.cs View File

@@ -79,6 +79,8 @@ namespace Discord
/// <summary> Gets all custom emojis on this server. </summary>
public IEnumerable<Emoji> CustomEmojis { get; private set; }

/// <summary> Gets the path to this object. </summary>
internal string Path => Name;
/// <summary> Gets the user that created this server. </summary>
public User Owner => GetUser(_ownerId);
/// <summary> Returns true if the current user owns this server. </summary>


+ 2
- 0
src/Discord.Net/Models/User.cs View File

@@ -73,6 +73,8 @@ namespace Discord
// /// <summary> Gets this user's voice token. </summary>
// public string Token { get; private set; }

/// <summary> Gets the path to this object. </summary>
internal string Path => $"{Server?.Name ?? "[Private]"}/{Name}";
/// <summary> Gets the current private channel for this user if one exists. </summary>
public Channel PrivateChannel => Client.GetPrivateChannel(Id);
/// <summary> Returns the string used to mention this user. </summary>


Loading…
Cancel
Save