feat: support new username system (#765)

This commit is contained in:
n1ck_pro
2023-06-15 14:24:48 +02:00
committed by GitHub
parent e01cf7cfb4
commit 5af7147863
8 changed files with 44 additions and 20 deletions

View File

@@ -18,9 +18,13 @@ export interface APIUser {
*/
username: string;
/**
* The user's 4-digit discord-tag
* The user's Discord-tag
*/
discriminator: string;
/**
* The user's display name, if it is set. For bots, this is the application name
*/
global_name: string | null;
/**
* The user's avatar hash
*

View File

@@ -18,9 +18,13 @@ export interface APIUser {
*/
username: string;
/**
* The user's 4-digit discord-tag
* The user's Discord-tag
*/
discriminator: string;
/**
* The user's display name, if it is set. For bots, this is the application name
*/
global_name: string | null;
/**
* The user's avatar hash
*

View File

@@ -962,14 +962,16 @@ export const CDNRoutes = {
/**
* Route for:
* - GET `/embed/avatars/{user.discriminator % 5}.png`
* - GET `/embed/avatars/{index}.png`
*
* The `userDiscriminator` parameter should be the user discriminator modulo 5 (e.g. 1337 % 5 = 2)
* The value for `index` parameter depends on whether the user is [migrated to the new username system](https://discord.com/developers/docs/change-log#unique-usernames-on-discord).
* For users on the new username system, `index` will be `(user.id >> 22) % 6`.
* For users on the legacy username system, `index` will be `user.discriminator % 5`.
*
* This route supports the extension: PNG
*/
defaultUserAvatar(userDiscriminator: DefaultUserAvatarAssets) {
return `/embed/avatars/${userDiscriminator}.png` as const;
defaultUserAvatar(index: DefaultUserAvatarAssets) {
return `/embed/avatars/${index}.png` as const;
},
/**

View File

@@ -971,14 +971,16 @@ export const CDNRoutes = {
/**
* Route for:
* - GET `/embed/avatars/{user.discriminator % 5}.png`
* - GET `/embed/avatars/{index}.png`
*
* The `userDiscriminator` parameter should be the user discriminator modulo 5 (e.g. 1337 % 5 = 2)
* The value for `index` parameter depends on whether the user is [migrated to the new username system](https://discord.com/developers/docs/change-log#unique-usernames-on-discord).
* For users on the new username system, `index` will be `(user.id >> 22) % 6`.
* For users on the legacy username system, `index` will be `user.discriminator % 5`.
*
* This route supports the extension: PNG
*/
defaultUserAvatar(userDiscriminator: DefaultUserAvatarAssets) {
return `/embed/avatars/${userDiscriminator}.png` as const;
defaultUserAvatar(index: DefaultUserAvatarAssets) {
return `/embed/avatars/${index}.png` as const;
},
/**

View File

@@ -18,9 +18,13 @@ export interface APIUser {
*/
username: string;
/**
* The user's 4-digit discord-tag
* The user's Discord-tag
*/
discriminator: string;
/**
* The user's display name, if it is set. For bots, this is the application name
*/
global_name: string | null;
/**
* The user's avatar hash
*

View File

@@ -18,9 +18,13 @@ export interface APIUser {
*/
username: string;
/**
* The user's 4-digit discord-tag
* The user's Discord-tag
*/
discriminator: string;
/**
* The user's display name, if it is set. For bots, this is the application name
*/
global_name: string | null;
/**
* The user's avatar hash
*

View File

@@ -962,14 +962,16 @@ export const CDNRoutes = {
/**
* Route for:
* - GET `/embed/avatars/{user.discriminator % 5}.png`
* - GET `/embed/avatars/{index}.png`
*
* The `userDiscriminator` parameter should be the user discriminator modulo 5 (e.g. 1337 % 5 = 2)
* The value for `index` parameter depends on whether the user is [migrated to the new username system](https://discord.com/developers/docs/change-log#unique-usernames-on-discord).
* For users on the new username system, `index` will be `(user.id >> 22) % 6`.
* For users on the legacy username system, `index` will be `user.discriminator % 5`.
*
* This route supports the extension: PNG
*/
defaultUserAvatar(userDiscriminator: DefaultUserAvatarAssets) {
return `/embed/avatars/${userDiscriminator}.png` as const;
defaultUserAvatar(index: DefaultUserAvatarAssets) {
return `/embed/avatars/${index}.png` as const;
},
/**

View File

@@ -971,14 +971,16 @@ export const CDNRoutes = {
/**
* Route for:
* - GET `/embed/avatars/{user.discriminator % 5}.png`
* - GET `/embed/avatars/{index}.png`
*
* The `userDiscriminator` parameter should be the user discriminator modulo 5 (e.g. 1337 % 5 = 2)
* The value for `index` parameter depends on whether the user is [migrated to the new username system](https://discord.com/developers/docs/change-log#unique-usernames-on-discord).
* For users on the new username system, `index` will be `(user.id >> 22) % 6`.
* For users on the legacy username system, `index` will be `user.discriminator % 5`.
*
* This route supports the extension: PNG
*/
defaultUserAvatar(userDiscriminator: DefaultUserAvatarAssets) {
return `/embed/avatars/${userDiscriminator}.png` as const;
defaultUserAvatar(index: DefaultUserAvatarAssets) {
return `/embed/avatars/${index}.png` as const;
},
/**