From bc7edbf3c7ef9f6cbc54fd46af7b8b09480e8b40 Mon Sep 17 00:00:00 2001 From: RogueException Date: Mon, 15 Feb 2016 19:14:18 -0400 Subject: [PATCH] Added path property to all models for logging --- src/Discord.Net/Models/Channel.cs | 8 +++++--- src/Discord.Net/Models/Invite.cs | 6 ++++-- src/Discord.Net/Models/Message.cs | 2 ++ src/Discord.Net/Models/Profile.cs | 2 +- src/Discord.Net/Models/Role.cs | 2 ++ src/Discord.Net/Models/Server.cs | 2 ++ src/Discord.Net/Models/User.cs | 2 ++ 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Discord.Net/Models/Channel.cs b/src/Discord.Net/Models/Channel.cs index 29e2f1a51..438646bdf 100644 --- a/src/Discord.Net/Models/Channel.cs +++ b/src/Discord.Net/Models/Channel.cs @@ -41,11 +41,11 @@ namespace Discord Permissions = new ChannelPermissionOverrides(allow, deny); } } - + private readonly ConcurrentDictionary _users; private readonly ConcurrentDictionary _messages; private Dictionary _permissionOverwrites; - + public DiscordClient Client { get; } /// Gets the unique identifier for this channel. @@ -64,6 +64,8 @@ namespace Discord /// Gets the type of this channel). public ChannelType Type { get; private set; } + /// Gets the path to this object. + internal string Path => $"{Server?.Name ?? "[Private]"}/{Name}"; /// Gets true if this is a private chat with another user. public bool IsPrivate => Recipient != null; /// Gets the string used to mention this channel. @@ -345,7 +347,7 @@ namespace Discord public async Task 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 SendFile(string filename, Stream stream) { diff --git a/src/Discord.Net/Models/Invite.cs b/src/Discord.Net/Models/Invite.cs index 56df207d9..a6a0407b1 100644 --- a/src/Discord.Net/Models/Invite.cs +++ b/src/Discord.Net/Models/Invite.cs @@ -85,8 +85,10 @@ namespace Discord /// Gets when this invite was created. public DateTime CreatedAt { get; private set; } - /// Returns a URL for this invite using XkcdCode if available or Id if not. - public string Url => $"{DiscordConfig.InviteUrl}/{Code}"; + /// Gets the path to this object. + internal string Path => $"{Server?.Name ?? "[Private]"}/{Code}"; + /// Returns a URL for this invite using XkcdCode if available or Id if not. + public string Url => $"{DiscordConfig.InviteUrl}/{Code}"; internal Invite(DiscordClient client, string code, string xkcdPass) { diff --git a/src/Discord.Net/Models/Message.cs b/src/Discord.Net/Models/Message.cs index c589df91e..324acd3ae 100644 --- a/src/Discord.Net/Models/Message.cs +++ b/src/Discord.Net/Models/Message.cs @@ -201,6 +201,8 @@ namespace Discord internal int Nonce { get; set; } + /// Gets the path to this object. + internal string Path => $"{Server?.Name ?? "[Private]"}/{Id}"; /// Returns the server containing the channel this message was sent to. public Server Server => Channel.Server; /// Returns if this message was sent from the logged-in accounts. diff --git a/src/Discord.Net/Models/Profile.cs b/src/Discord.Net/Models/Profile.cs index c0aaa6f25..89cdde640 100644 --- a/src/Discord.Net/Models/Profile.cs +++ b/src/Discord.Net/Models/Profile.cs @@ -28,7 +28,7 @@ namespace Discord public UserStatus Status => Client.PrivateUser.Status; /// Returns the string used to mention this user. public string Mention => $"<@{Id}>"; - + /// Gets the email for this user. public string Email { get; private set; } /// Gets if the email for this user has been verified. diff --git a/src/Discord.Net/Models/Role.cs b/src/Discord.Net/Models/Role.cs index 1bdec0d3c..4fd5c4b7a 100644 --- a/src/Discord.Net/Models/Role.cs +++ b/src/Discord.Net/Models/Role.cs @@ -33,6 +33,8 @@ namespace Discord /// Gets the color of this role. public Color Color { get; private set; } + /// Gets the path to this object. + internal string Path => $"{Server?.Name ?? "[Private]"}/{Name}"; /// Gets true if this is the role representing all users in a server. public bool IsEveryone => Id == Server.Id; /// Gets a list of all members in this role. diff --git a/src/Discord.Net/Models/Server.cs b/src/Discord.Net/Models/Server.cs index aaed6aac8..ec5f58519 100644 --- a/src/Discord.Net/Models/Server.cs +++ b/src/Discord.Net/Models/Server.cs @@ -79,6 +79,8 @@ namespace Discord /// Gets all custom emojis on this server. public IEnumerable CustomEmojis { get; private set; } + /// Gets the path to this object. + internal string Path => Name; /// Gets the user that created this server. public User Owner => GetUser(_ownerId); /// Returns true if the current user owns this server. diff --git a/src/Discord.Net/Models/User.cs b/src/Discord.Net/Models/User.cs index b2f5488cf..dd381d014 100644 --- a/src/Discord.Net/Models/User.cs +++ b/src/Discord.Net/Models/User.cs @@ -73,6 +73,8 @@ namespace Discord // /// Gets this user's voice token. // public string Token { get; private set; } + /// Gets the path to this object. + internal string Path => $"{Server?.Name ?? "[Private]"}/{Name}"; /// Gets the current private channel for this user if one exists. public Channel PrivateChannel => Client.GetPrivateChannel(Id); /// Returns the string used to mention this user.