How to use the detritus-client-rest.Client function in detritus-client-rest

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 / 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