| @@ -10,19 +10,19 @@ namespace Discord | |||||
| { | { | ||||
| internal static class InternalExtensions | internal static class InternalExtensions | ||||
| { | { | ||||
| internal static readonly IFormatProvider _format = CultureInfo.InvariantCulture; | |||||
| public static ulong ToId(this string value) => ulong.Parse(value, NumberStyles.None, _format); | |||||
| public static ulong? ToNullableId(this string value) => value == null ? (ulong?)null : ulong.Parse(value, NumberStyles.None, _format); | |||||
| internal static readonly IFormatProvider _format = CultureInfo.InvariantCulture; | |||||
| public static ulong ToId(this string value) => ulong.Parse(value, NumberStyles.None, _format); | |||||
| public static ulong? ToNullableId(this string value) => value == null ? (ulong?)null : ulong.Parse(value, NumberStyles.None, _format); | |||||
| public static bool TryToId(this string value, out ulong result) => ulong.TryParse(value, NumberStyles.None, _format, out result); | public static bool TryToId(this string value, out ulong result) => ulong.TryParse(value, NumberStyles.None, _format, out result); | ||||
| public static string ToIdString(this ulong value) => value.ToString(_format); | public static string ToIdString(this ulong value) => value.ToString(_format); | ||||
| public static string ToIdString(this ulong? value) => value?.ToString(_format); | |||||
| public static string ToIdString(this ulong? value) => value?.ToString(_format); | |||||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||||
| public static bool HasBit(this uint rawValue, byte bit) => ((rawValue >> bit) & 1U) == 1; | public static bool HasBit(this uint rawValue, byte bit) => ((rawValue >> bit) & 1U) == 1; | ||||
| public static bool TryGetOrAdd<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> d, | |||||
| public static bool TryGetOrAdd<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> d, | |||||
| TKey key, Func<TKey, TValue> factory, out TValue result) | TKey key, Func<TKey, TValue> factory, out TValue result) | ||||
| { | { | ||||
| bool created = false; | bool created = false; | ||||
| @@ -98,6 +98,16 @@ namespace Discord | |||||
| if (!exactMatch) | if (!exactMatch) | ||||
| { | { | ||||
| if (name.Length >= 3 && name[0] == '<' && name[1] == '@' && name[2] == '!' && name[name.Length - 1] == '>') //Search by nickname'd mention | |||||
| { | |||||
| ulong id; | |||||
| if (name.Substring(3, name.Length - 4).TryToId(out id)) | |||||
| { | |||||
| var user = users.Where(x => x.Id == id).FirstOrDefault(); | |||||
| if (user != null) | |||||
| query = query.Concat(new User[] { user }); | |||||
| } | |||||
| } | |||||
| if (name.Length >= 2 && name[0] == '<' && name[1] == '@' && name[name.Length - 1] == '>') //Search by raw mention | if (name.Length >= 2 && name[0] == '<' && name[1] == '@' && name[name.Length - 1] == '>') //Search by raw mention | ||||
| { | { | ||||
| ulong id; | ulong id; | ||||