old_contents: const request = require('superagent');
  const Constants = require('../../util/Constants');
  
  class APIRequest {
    constructor(rest, method, url, auth, data, file) {
      this.rest = rest;
      this.method = method;
      this.url = url;
      this.auth = auth;
      this.data = data;
      this.file = file;
    }
  
    getEndpoint() {
      return `${this.url}`;
    }
  
    getAuth() {
      if (this.rest.client.token && this.rest.client.user && this.rest.client.user.bot) {
        return `Bot ${this.rest.client.token}`;
      } else if (this.rest.client.token) {
        return this.rest.client.token;
      }
      throw new Error(Constants.Errors.NO_TOKEN);
    }
  
    gen() {
      const apiRequest = request[this.method](this.url);
      if (this.auth) apiRequest.set('authorization', this.getAuth());
      if (this.file && this.file.file) {
        apiRequest.attach('file', this.file.file, this.file.name);
        this.data = this.data || {};
        for (const key in this.data) {
          if (this.data[key]) {
            apiRequest.field(key, this.data[key]);
          }
        }
      } else if (this.data) {
        apiRequest.send(this.data);
      }
      apiRequest.set('User-Agent', this.rest.userAgentManager.userAgent);
      return apiRequest;
    }
  }
  
  module.exports = APIRequest;
  
new_contents: const request = require('superagent');
  const Constants = require('../../util/Constants');
  
  class APIRequest {
    constructor(rest, method, url, auth, data, file) {
      this.rest = rest;
      this.method = method;
      this.url = url;
      this.auth = auth;
      this.data = data;
      this.file = file;
    }
  
    getEndpoint() {
      return this.url;
    }
  
    getAuth() {
      if (this.rest.client.token && this.rest.client.user && this.rest.client.user.bot) {
        return `Bot ${this.rest.client.token}`;
      } else if (this.rest.client.token) {
        return this.rest.client.token;
      }
      throw new Error(Constants.Errors.NO_TOKEN);
    }
  
    gen() {
      const apiRequest = request[this.method](this.url);
      if (this.auth) apiRequest.set('authorization', this.getAuth());
      if (this.file && this.file.file) {
        apiRequest.attach('file', this.file.file, this.file.name);
        this.data = this.data || {};
        for (const key in this.data) {
          if (this.data[key]) {
            apiRequest.field(key, this.data[key]);
          }
        }
      } else if (this.data) {
        apiRequest.send(this.data);
      }
      apiRequest.set('User-Agent', this.rest.userAgentManager.userAgent);
      return apiRequest;
    }
  }
  
  module.exports = APIRequest;
  
subject: Simplify APIRequest endpoint