Skip to content

Commit

Permalink
Implement new username field.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nihlus authored and VelvetToroyashi committed Jun 17, 2023
1 parent 0724e52 commit 7ce0f10
Show file tree
Hide file tree
Showing 79 changed files with 128 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public interface IPartialUser
[Obsolete("Discord has deprecated the discriminator field.")]
Optional<ushort> Discriminator { get; }

/// <inheritdoc cref="IUser.GlobalName" />
Optional<string?> GlobalName { get; }

/// <inheritdoc cref="IUser.Avatar" />
Optional<IImageHash?> Avatar { get; }

Expand Down
13 changes: 13 additions & 0 deletions Backend/Remora.Discord.API.Abstractions/API/Objects/Users/IUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

using System;
using System.Drawing;
using JetBrains.Annotations;
using Remora.Rest.Core;
Expand All @@ -40,6 +41,10 @@ public interface IUser : IPartialUser
/// <summary>
/// Gets the username of the user. This is a unique value.
/// </summary>
/// <remarks>
/// Discord is currently migrating to a new username system. When the migration is complete, this field will be
/// unique across the platform.
/// </remarks>
new string Username { get; }

/// <summary>
Expand All @@ -53,6 +58,11 @@ public interface IUser : IPartialUser
/// <remarks>Discord no longer uses discriminators, and migrated users will simply have '0' as their discriminator.</remarks>
new ushort Discriminator { get; }

/// <summary>
/// Gets the user's display name, if it is set. For bots, this is the application name.
/// </summary>
new string? GlobalName { get; }

/// <summary>
/// Gets the user's avatar hash.
/// </summary>
Expand Down Expand Up @@ -126,6 +136,9 @@ public interface IUser : IPartialUser
/// <inheritdoc/>
Optional<ushort> IPartialUser.Discriminator => this.Discriminator;

/// <inheritdoc/>
Optional<string?> IPartialUser.GlobalName => this.GlobalName;

/// <inheritdoc/>
Optional<IImageHash?> IPartialUser.Avatar => new(this.Avatar);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public record UserUpdate
string Username,
string GlobalName,
ushort Discriminator,
string? GlobalName,
IImageHash? Avatar,
Optional<bool> IsBot = default,
Optional<bool> IsSystem = default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public record PartialUser
Optional<string> Username = default,
Optional<string> GlobalName = default,
Optional<ushort> Discriminator = default,
Optional<string?> GlobalName = default,
Optional<IImageHash?> Avatar = default,
Optional<bool> IsBot = default,
Optional<bool> IsSystem = default,
Expand Down
1 change: 1 addition & 0 deletions Backend/Remora.Discord.API/API/Objects/Users/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public record User
string Username,
string GlobalName,
ushort Discriminator,
string? GlobalName,
IImageHash? Avatar,
Optional<bool> IsBot = default,
Optional<bool> IsSystem = default,
Expand Down
2 changes: 2 additions & 0 deletions Backend/Remora.Discord.API/API/Objects/Users/UserMention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public record UserMention
string Username,
string GlobalName,
ushort Discriminator,
string? GlobalName,
IImageHash? Avatar,
Optional<bool> IsBot = default,
Optional<bool> IsSystem = default,
Expand All @@ -54,6 +55,7 @@ public record UserMention
Username,
GlobalName,
Discriminator,
GlobalName,
Avatar,
IsBot,
IsSystem,
Expand Down
1 change: 1 addition & 0 deletions Tests/Remora.Discord.Gateway.Tests/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static class Constants
"mock_bot",
"Mock Bot",
0,
"mock-bot",
null
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
{
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
{
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
{
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
{
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
{
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
{
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"id": "999999999999999999",
"username": "none",
"discriminator": "9999",
"global_name": "none",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"id": "999999999999999999",
"username": "none",
"discriminator": "9999",
"global_name": "none",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"id": "999999999999999999",
"username": "none",
"discriminator": "9999",
"global_name": "none",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
"guild_id": "999999999999999999"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"id": "999999999999999999",
"username": "none",
"discriminator": "9999",
"global_name": "none",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
"nick": "none",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"id": "999999999999999999",
"username": "none",
"discriminator": "9999",
"global_name": "none",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
"nick": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"id": "999999999999999999",
"username": "none",
"discriminator": "9999",
"global_name": "none",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
"avatar": "68b329da9893e34099c7d8ad5cb9c940",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"creator": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"creator": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"creator": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"creator": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"creator": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"creator": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"user": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"user": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"user": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand All @@ -36,6 +37,7 @@
"author": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"id": "999999999999999999",
"username": "none",
"discriminator": "9999",
"global_name": "none",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
"max_age": 1,
Expand All @@ -26,4 +27,4 @@
"temporary": true,
"uses": 1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"author": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand Down Expand Up @@ -63,6 +64,7 @@
"author": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand All @@ -85,6 +87,7 @@
"user": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
}
Expand Down Expand Up @@ -114,9 +117,10 @@
"id": "999999999999999999",
"username": "none",
"discriminator": "9999",
"global_name": "none",
"avatar": "68b329da9893e34099c7d8ad5cb9c940",
"member": {}
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"author": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand Down Expand Up @@ -65,6 +66,7 @@
"user": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
}
Expand Down Expand Up @@ -93,9 +95,10 @@
"id": "999999999999999999",
"username": "none",
"discriminator": "9999",
"global_name": "none",
"avatar": "68b329da9893e34099c7d8ad5cb9c940",
"member": {}
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"author": {
"username": "none",
"discriminator": "9999",
"global_name": "none",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
},
Expand Down Expand Up @@ -39,9 +40,10 @@
"id": "999999999999999999",
"username": "none",
"discriminator": "9999",
"global_name": "none",
"avatar": "68b329da9893e34099c7d8ad5cb9c940",
"member": {}
}
]
}
}
}
Loading

0 comments on commit 7ce0f10

Please sign in to comment.