Added Mention function to User, GlobalUser, Channel and Role. Obsoleted old Mention static class.

This commit is contained in:
RogueException
2015-12-03 06:37:11 -04:00
parent 3ccd416027
commit bba866652e
4 changed files with 14 additions and 3 deletions

View File

@@ -91,6 +91,9 @@ namespace Discord
private PermissionOverwrite[] _permissionOverwrites; private PermissionOverwrite[] _permissionOverwrites;
public IEnumerable<PermissionOverwrite> PermissionOverwrites { get { return _permissionOverwrites; } internal set { _permissionOverwrites = value.ToArray(); } } public IEnumerable<PermissionOverwrite> PermissionOverwrites { get { return _permissionOverwrites; } internal set { _permissionOverwrites = value.ToArray(); } }
/// <summary> Returns the string used to mention this channel. </summary>
public string Mention => $"<#{Id}>";
internal Channel(DiscordClient client, long id, long? serverId, long? recipientId) internal Channel(DiscordClient client, long id, long? serverId, long? recipientId)
: base(client, id) : base(client, id)
{ {

View File

@@ -8,7 +8,6 @@ namespace Discord
{ {
public sealed class GlobalUser : CachedObject<long> public sealed class GlobalUser : CachedObject<long>
{ {
/// <summary> Returns the email for this user. Note: this field is only ever populated for the current logged in user. </summary> /// <summary> Returns the email for this user. Note: this field is only ever populated for the current logged in user. </summary>
[JsonIgnore] [JsonIgnore]
public string Email { get; private set; } public string Email { get; private set; }
@@ -39,6 +38,9 @@ namespace Discord
private IEnumerable<long> ServerIds => _users.Select(x => x.Key); private IEnumerable<long> ServerIds => _users.Select(x => x.Key);
private readonly ConcurrentDictionary<long, User> _users; private readonly ConcurrentDictionary<long, User> _users;
/// <summary> Returns the string used to mention this user. </summary>
public string Mention => $"<@{Id}>";
internal GlobalUser(DiscordClient client, long id) internal GlobalUser(DiscordClient client, long id)
: base(client, id) : base(client, id)
{ {

View File

@@ -1,5 +1,6 @@
using Discord.API; using Discord.API;
using Newtonsoft.Json; using Newtonsoft.Json;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -38,6 +39,9 @@ namespace Discord
private IEnumerable<long> MemberIds => Members.Select(x => x.Id); private IEnumerable<long> MemberIds => Members.Select(x => x.Id);
//TODO: Add local members cache //TODO: Add local members cache
/// <summary> Returns the string used to mention this role. </summary>
public string Mention { get { if (IsEveryone) return "@everyone"; else throw new InvalidOperationException("Discord currently only supports referencing the everyone role"); } }
internal Role(DiscordClient client, long id, long serverId) internal Role(DiscordClient client, long id, long serverId)
: base(client, id) : base(client, id)
{ {

View File

@@ -41,7 +41,6 @@ namespace Discord
public bool IsServerMuted { get; private set; } public bool IsServerMuted { get; private set; }
public bool IsServerDeafened { get; private set; } public bool IsServerDeafened { get; private set; }
public bool IsServerSuppressed { get; private set; } public bool IsServerSuppressed { get; private set; }
public bool IsSpeaking { get; internal set; }
public bool IsPrivate => _server.Id == null; public bool IsPrivate => _server.Id == null;
public string SessionId { get; private set; } public string SessionId { get; private set; }
@@ -117,6 +116,9 @@ namespace Discord
} }
} }
/// <summary> Returns the string used to mention this user. </summary>
public string Mention => $"<@{Id}>";
internal User(DiscordClient client, long id, long? serverId) internal User(DiscordClient client, long id, long? serverId)
: base(client, id) : base(client, id)
{ {