mirror of
https://github.com/danbulant/discord.js
synced 2026-07-07 04:00:42 +00:00
Webpack build for branch master: cada8763a9
This commit is contained in:
parent
168c77f2ad
commit
b2a5c64d6a
2 changed files with 15 additions and 13 deletions
|
|
@ -179,6 +179,11 @@ const AllowedImageSizes = [
|
||||||
2048,
|
2048,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function checkImage({ size, format }) {
|
||||||
|
if (format && !AllowedImageFormats.includes(format)) throw new Error(`Invalid image format: ${format}`);
|
||||||
|
if (size && !AllowedImageSizes.includes(size)) throw new RangeError(`Invalid size: ${size}`);
|
||||||
|
}
|
||||||
|
|
||||||
exports.Endpoints = {
|
exports.Endpoints = {
|
||||||
CDN(root) {
|
CDN(root) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -187,30 +192,27 @@ exports.Endpoints = {
|
||||||
DefaultAvatar: number => `${root}/embed/avatars/${number}.png`,
|
DefaultAvatar: number => `${root}/embed/avatars/${number}.png`,
|
||||||
Avatar: (userID, hash, format = 'default', size) => {
|
Avatar: (userID, hash, format = 'default', size) => {
|
||||||
if (format === 'default') format = hash.startsWith('a_') ? 'gif' : 'webp';
|
if (format === 'default') format = hash.startsWith('a_') ? 'gif' : 'webp';
|
||||||
if (!AllowedImageFormats.includes(format)) throw new Error(`Invalid image format: ${format}`);
|
checkImage({ size, format });
|
||||||
if (size && !AllowedImageSizes.includes(size)) throw new RangeError(`Invalid size: ${size}`);
|
|
||||||
return `${root}/avatars/${userID}/${hash}.${format}${size ? `?size=${size}` : ''}`;
|
return `${root}/avatars/${userID}/${hash}.${format}${size ? `?size=${size}` : ''}`;
|
||||||
},
|
},
|
||||||
Icon: (guildID, hash, format = 'default', size) => {
|
Icon: (guildID, hash, format = 'webp', size) => {
|
||||||
if (format === 'default') format = 'webp';
|
checkImage({ size, format });
|
||||||
if (!AllowedImageFormats.includes(format)) throw new Error(`Invalid image format: ${format}`);
|
|
||||||
if (size && !AllowedImageSizes.includes(size)) throw new RangeError(`Invalid size: ${size}`);
|
|
||||||
return `${root}/icons/${guildID}/${hash}.${format}${size ? `?size=${size}` : ''}`;
|
return `${root}/icons/${guildID}/${hash}.${format}${size ? `?size=${size}` : ''}`;
|
||||||
},
|
},
|
||||||
AppIcon: (clientID, hash, format = 'default', size) => {
|
AppIcon: (clientID, hash, format = 'webp', size) => {
|
||||||
if (format === 'default') format = 'webp';
|
checkImage({ size, format });
|
||||||
if (!AllowedImageFormats.includes(format)) throw new Error(`Invalid image format: ${format}`);
|
|
||||||
if (size && !AllowedImageSizes.includes(size)) throw new RangeError(`Invalid size: ${size}`);
|
|
||||||
return `${root}/app-icons/${clientID}/${hash}.${format}${size ? `?size=${size}` : ''}`;
|
return `${root}/app-icons/${clientID}/${hash}.${format}${size ? `?size=${size}` : ''}`;
|
||||||
},
|
},
|
||||||
Splash: (guildID, hash) => `${root}/splashes/${guildID}/${hash}.jpg`,
|
Splash: (guildID, hash, format = 'webp', size) => {
|
||||||
|
checkImage({ size, format });
|
||||||
|
return `${root}/splashes/${guildID}/${hash}.${format}${size ? `?size=${size}` : ''}`;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
invite: code => `https://discord.gg/${code}`,
|
invite: code => `https://discord.gg/${code}`,
|
||||||
botGateway: '/gateway/bot',
|
botGateway: '/gateway/bot',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current status of the client. Here are the available statuses:
|
* The current status of the client. Here are the available statuses:
|
||||||
* - READY
|
* - READY
|
||||||
|
|
|
||||||
2
discord.master.min.js
vendored
2
discord.master.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue