This commit is contained in:
Elysia
2023-06-14 14:00:48 +07:00
parent bd66c99ef2
commit 983816b0c7
5 changed files with 61 additions and 10 deletions

View File

@@ -186,7 +186,7 @@ exports.Endpoints = {
return {
Emoji: (emojiId, format = 'webp') => `${root}/emojis/${emojiId}.${format}`,
Asset: name => `${root}/assets/${name}`,
DefaultAvatar: discriminator => `${root}/embed/avatars/${discriminator}.png`,
DefaultAvatar: index => `${root}/embed/avatars/${index}.png`,
Avatar: (userId, hash, format, size, dynamic = false) => {
if (dynamic && hash.startsWith('a_')) format = 'gif';
return makeImageUrl(`${root}/avatars/${userId}/${hash}`, { format, size });

View File

@@ -709,8 +709,8 @@ class Util extends null {
if (!files.length) return [];
files = files.map((file, i) => ({
filename: file.name ?? file.attachment?.name ?? file.attachment?.filename ?? 'file.jpg',
// 8MB = 8388608 bytes
file_size: Math.floor((8_388_608 / 10) * Math.random()),
// 25MB = 26_214_400bytes
file_size: Math.floor((26_214_400 / 10) * Math.random()),
id: `${i}`,
}));
const { attachments } = await client.api.channels[channelId].attachments.post({
@@ -733,6 +733,15 @@ class Util extends null {
return false;
}
}
/**
* Calculates the default avatar index for a given user id.
* @param {Snowflake} userId - The user id to calculate the default avatar index for
* @returns {number}
*/
static calculateUserDefaultAvatarIndex(userId) {
return Number(BigInt(userId) >> 22n) % 6;
}
}
module.exports = Util;