Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[Distributors.DISCORD]: (skuId: string, slug?: null | string) =>
Endpoints.Routes.URL + `/store/skus/${skuId}` + ((slug) ? `/${slug}` : ''),
[Distributors.EPIC]: (skuId: string) =>
get platformDiscordUrl(): null | string {
if (this.primarySkuId) {
return (
Endpoints.Routes.URL +
Endpoints.Routes.APPLICATION_STORE_LISTING_APPLICATION(this.primarySkuId, this.slug)
);
}
return null;
}
get jumpLink(): string {
return Endpoints.Routes.URL + Endpoints.Routes.USER(this.id);
}
get platformDiscordUrl(): null | string {
if (this.primarySkuId) {
return (
Endpoints.Routes.URL +
Endpoints.Routes.APPLICATION_STORE_LISTING_APPLICATION(this.primarySkuId, this.slug)
);
}
return null;
}
iconUrlFormat(format?: null | string, query?: UrlQuery): null | string {
if (!this.icon) {
return null;
}
const hash = this.icon;
format = getFormatFromHash(
hash,
format,
this.client.imageFormat,
);
return addQuery(
Endpoints.CDN.URL + Endpoints.CDN.APP_ICON(this.id, hash, format),
query,
);
}
get defaultAvatarUrl(): string {
return Endpoints.CDN.URL + Endpoints.CDN.AVATAR_DEFAULT(this.discriminator);
}
splashUrlFormat(format?: null | string, query?: UrlQuery): null | string {
if (!this.splash) {
return null;
}
const hash = this.splash;
format = getFormatFromHash(
hash,
format,
this.client.imageFormat,
);
return addQuery(
Endpoints.CDN.URL + Endpoints.CDN.APP_ICON(this.id, hash, format),
query,
);
}
}
avatarUrlFormat(format?: null | string, query?: UrlQuery): string {
if (!this.avatar) {
return addQuery(this.defaultAvatarUrl, query);
}
const hash = this.avatar;
format = getFormatFromHash(hash, format, this.client.imageFormat);
return addQuery(Endpoints.CDN.URL + Endpoints.CDN.AVATAR(this.id, hash, format), query);
}
options: ClusterManagerOptions = {},
) {
super();
this.file = file;
if (!options.isAbsolute) {
if (require.main) {
this.file = path.join(path.dirname(require.main.filename), this.file);
}
}
if (!token) {
throw new Error('Token is required for this library to work.');
}
this.token = token;
this.respawn = (options.respawn || options.respawn === undefined);
this.rest = new DetritusRestClient(token, {authType: AuthTypes.BOT});
this.shardCount = +(options.shardCount || this.shardCount);
if (Array.isArray(options.shards)) {
if (options.shards.length !== 2) {
throw new Error('Shards need to be in the format of [shardStart, shardEnd]');
}
const [shardStart, shardEnd] = options.shards;
this.shardEnd = +shardEnd;
this.shardStart = +shardStart;
}
this.shardsPerCluster = +(options.shardsPerCluster || this.shardsPerCluster);
Object.defineProperties(this, {
ran: {configurable: true, writable: false},
rest: {enumerable: false, writable: false},
token: {enumerable: false, writable: false},
shards: {enumerable: true, value: new Map()}
});
if (Array.isArray(options.shards)) {
if (options.shards.length !== 2) {
throw new Error('Shards need to be in the format of [shardStart, shardEnd]');
}
this.setShardStart(options.shards.shift());
this.setShardEnd(options.shards.shift());
}
options.isBot = true;
options.rest = Object.assign({}, options.rest, {authType: 'bot'});
Object.defineProperties(this, {
rest: {value: new RestClient(token, options.rest, this)}
});
options.rest.globalBucket = this.rest.global;
options.pass = Object.assign({}, options.pass, {cluster: this});
options.gateway = Object.assign({}, options.gateway);
Object.defineProperties(this, {
token: {value: token},
clientOptions: {value: options},
ran: {configurable: true, value: false}
});
}