From 455b32407156901600727927e771b9046636cf81 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 5 Jun 2023 21:38:09 +0100 Subject: [PATCH] feat: add support for new usernames user discriminators become "0" if the user has a new username, distinct from "0000" for webhooks. --- CHANGELOG.md | 26 +++----------------- X10D.DSharpPlus/src/DiscordUserExtensions.cs | 6 +++++ 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9482e2e..b3203eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,30 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 4.0.0 - [Unreleased] +## [3.2.1] - 2023-06-05 ### Added -- X10D: Added extension methods for `DateOnly`, for parity with `DateTime` and `DateTimeOffset`. -- X10D: Added math-related extension methods for `BigInteger`. -- X10D: Added `Span.Replace(T, T)`. -- X10D: Added `CountDigits` for integer types. -- X10D: Added `IEnumerable.Except(T)`. -- X10D: Added `Progress.OnProgressChanged([T])`. -- X10D: Added `TextWriter.WriteNoAlloc(int[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteNoAlloc(uint[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteNoAlloc(long[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteNoAlloc(ulong[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteLineNoAlloc(int[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteLineNoAlloc(uint[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteLineNoAlloc(long[, ReadOnlySpan[, IFormatProvider]])`. -- X10D: Added `TextWriter.WriteLineNoAlloc(ulong[, ReadOnlySpan[, IFormatProvider]])`. -- X10D.Unity: Added `RaycastHit.GetComponent` and `RaycastHit.TryGetComponent`. -- X10D.Unity: Added `DebugUtility.DrawFunction`, and `DebugUtility.DrawUnjoinedPolyhedron` on which it relies. - -### Changed - -- X10D: `DateTime.Age(DateTime)` and `DateTimeOffset.Age(DateTimeOffset)` parameter renamed from `asOf` to `referenceDate`. +- X10D.DSharpPlus: Added support for new usernames. See https://discord.com/blog/usernames ## [3.2.0] - 2023-04-03 @@ -592,7 +573,8 @@ please [open an issue](https://github.com/oliverbooth/X10D/issues)! Earlier versions of this package are undocumented and unlisted from package results. -[unreleased]: https://github.com/oliverbooth/X10D/compare/v3.2.0...main +[unreleased]: https://github.com/oliverbooth/X10D/compare/v3.2.1...main +[3.2.1]: https://github.com/oliverbooth/X10D/releases/tag/v3.2.1 [3.2.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.2.0 [3.1.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.1.0 [3.0.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.0.0 diff --git a/X10D.DSharpPlus/src/DiscordUserExtensions.cs b/X10D.DSharpPlus/src/DiscordUserExtensions.cs index 6ab8314..0cc9483 100644 --- a/X10D.DSharpPlus/src/DiscordUserExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordUserExtensions.cs @@ -77,6 +77,12 @@ public static class DiscordUserExtensions } #endif + if (user.Discriminator == "0") + { + // user has a new username. see: https://discord.com/blog/usernames + return user.Username; + } + return $"{user.Username}#{user.Discriminator}"; }