How to use detritus-client-rest - 10 common examples

To help you get started, we’ve selected a few detritus-client-rest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github detritusjs / client / src / constants.ts View on Github external
[Distributors.DISCORD]: (skuId: string, slug?: null | string) =>
    Endpoints.Routes.URL + `/store/skus/${skuId}` + ((slug) ? `/${slug}` : ''),
  [Distributors.EPIC]: (skuId: string) =>
github detritusjs / client / src / structures / application.ts View on Github external
get platformDiscordUrl(): null | string {
    if (this.primarySkuId) {
      return (
        Endpoints.Routes.URL +
        Endpoints.Routes.APPLICATION_STORE_LISTING_APPLICATION(this.primarySkuId, this.slug)
      );
    }
    return null;
  }
github detritusjs / client / src / structures / user.ts View on Github external
get jumpLink(): string {
    return Endpoints.Routes.URL + Endpoints.Routes.USER(this.id);
  }
github detritusjs / client / src / structures / application.ts View on Github external
get platformDiscordUrl(): null | string {
    if (this.primarySkuId) {
      return (
        Endpoints.Routes.URL +
        Endpoints.Routes.APPLICATION_STORE_LISTING_APPLICATION(this.primarySkuId, this.slug)
      );
    }
    return null;
  }
github detritusjs / client / src / structures / application.ts View on Github external
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,
    );
  }
github detritusjs / client / src / structures / user.ts View on Github external
get defaultAvatarUrl(): string {
    return Endpoints.CDN.URL + Endpoints.CDN.AVATAR_DEFAULT(this.discriminator);
  }
github detritusjs / client / src / structures / application.ts View on Github external
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,
    );
  }
}
github detritusjs / client / src / structures / user.ts View on Github external
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);
  }
github detritusjs / client / src / clustermanager.ts View on Github external
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},
github detritusjs / client / lib / clusterclient.js View on Github external
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}
		});
	}

detritus-client-rest

A minimalistic TypeScript library to interact with all, or most, of Discord's rest endpoints

MIT
Latest version published 3 years ago

Package Health Score

42 / 100
Full package analysis