mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
Move protocol version to a constant, and reorganise constants a bit
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -40,7 +40,7 @@ class RESTMethods {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.rest.makeRequest('get', Constants.Endpoints.gateway, true)
|
this.rest.makeRequest('get', Constants.Endpoints.gateway, true)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.rest.client.ws.gateway = `${res.url}/?encoding=json&v=${this.rest.client.options.protocolVersion}`;
|
this.rest.client.ws.gateway = `${res.url}/?encoding=json&v=${Constants.PROTOCOL_VERSION}`;
|
||||||
resolve(this.rest.client.ws.gateway);
|
resolve(this.rest.client.ws.gateway);
|
||||||
})
|
})
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
exports.Package = require('../../package.json');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for a Client.
|
* Options for a Client.
|
||||||
* @typedef {Object} ClientOptions
|
* @typedef {Object} ClientOptions
|
||||||
@@ -10,7 +12,8 @@
|
|||||||
* (in seconds, 0 for forever)
|
* (in seconds, 0 for forever)
|
||||||
* @property {number} [messageSweepInterval=0] How frequently to remove messages from the cache that are older than
|
* @property {number} [messageSweepInterval=0] How frequently to remove messages from the cache that are older than
|
||||||
* the max message lifetime (in seconds, 0 for never)
|
* the max message lifetime (in seconds, 0 for never)
|
||||||
* @property {boolean} [fetchAllMembers=false] Whether to cache all guild members and users upon startup
|
* @property {boolean} [fetchAllMembers=false] Whether to cache all guild members and users upon startup, as well as
|
||||||
|
* upon joining a guild
|
||||||
* @property {boolean} [disableEveryone=false] Default value for MessageOptions.disableEveryone
|
* @property {boolean} [disableEveryone=false] Default value for MessageOptions.disableEveryone
|
||||||
* @property {number} [restWsBridgeTimeout=5000] Maximum time permitted between REST responses and their
|
* @property {number} [restWsBridgeTimeout=5000] Maximum time permitted between REST responses and their
|
||||||
* corresponding websocket events
|
* corresponding websocket events
|
||||||
@@ -26,7 +29,6 @@ exports.DefaultOptions = {
|
|||||||
fetchAllMembers: false,
|
fetchAllMembers: false,
|
||||||
disableEveryone: false,
|
disableEveryone: false,
|
||||||
restWsBridgeTimeout: 5000,
|
restWsBridgeTimeout: 5000,
|
||||||
protocolVersion: 6,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Websocket options. These are left as snake_case to match the API.
|
* Websocket options. These are left as snake_case to match the API.
|
||||||
@@ -47,23 +49,6 @@ exports.DefaultOptions = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.Status = {
|
|
||||||
READY: 0,
|
|
||||||
CONNECTING: 1,
|
|
||||||
RECONNECTING: 2,
|
|
||||||
IDLE: 3,
|
|
||||||
NEARLY: 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.ChannelTypes = {
|
|
||||||
text: 0,
|
|
||||||
DM: 1,
|
|
||||||
voice: 2,
|
|
||||||
groupDM: 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.Package = require('../../package.json');
|
|
||||||
|
|
||||||
exports.Errors = {
|
exports.Errors = {
|
||||||
NO_TOKEN: 'Request to use token, but token was unavailable to the client.',
|
NO_TOKEN: 'Request to use token, but token was unavailable to the client.',
|
||||||
NO_BOT_ACCOUNT: 'You ideally should be using a bot account!',
|
NO_BOT_ACCOUNT: 'You ideally should be using a bot account!',
|
||||||
@@ -75,10 +60,10 @@ exports.Errors = {
|
|||||||
INVALID_SHARD: 'Invalid shard settings were provided.',
|
INVALID_SHARD: 'Invalid shard settings were provided.',
|
||||||
};
|
};
|
||||||
|
|
||||||
const API = `https://discordapp.com/api/v${exports.DefaultOptions.protocolVersion}`;
|
const PROTOCOL_VERSION = exports.PROTOCOL_VERSION = 6;
|
||||||
|
const API = exports.API = `https://discordapp.com/api/v${PROTOCOL_VERSION}`;
|
||||||
const Endpoints = exports.Endpoints = {
|
const Endpoints = exports.Endpoints = {
|
||||||
// general endpoints
|
// general
|
||||||
login: `${API}/auth/login`,
|
login: `${API}/auth/login`,
|
||||||
logout: `${API}/auth/logout`,
|
logout: `${API}/auth/logout`,
|
||||||
gateway: `${API}/gateway`,
|
gateway: `${API}/gateway`,
|
||||||
@@ -120,6 +105,21 @@ const Endpoints = exports.Endpoints = {
|
|||||||
channelMessage: (channelID, messageID) => `${Endpoints.channelMessages(channelID)}/${messageID}`,
|
channelMessage: (channelID, messageID) => `${Endpoints.channelMessages(channelID)}/${messageID}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.Status = {
|
||||||
|
READY: 0,
|
||||||
|
CONNECTING: 1,
|
||||||
|
RECONNECTING: 2,
|
||||||
|
IDLE: 3,
|
||||||
|
NEARLY: 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.ChannelTypes = {
|
||||||
|
text: 0,
|
||||||
|
DM: 1,
|
||||||
|
voice: 2,
|
||||||
|
groupDM: 3,
|
||||||
|
};
|
||||||
|
|
||||||
exports.OPCodes = {
|
exports.OPCodes = {
|
||||||
DISPATCH: 0,
|
DISPATCH: 0,
|
||||||
HEARTBEAT: 1,
|
HEARTBEAT: 1,
|
||||||
@@ -248,7 +248,5 @@ const PermissionFlags = exports.PermissionFlags = {
|
|||||||
|
|
||||||
let _ALL_PERMISSIONS = 0;
|
let _ALL_PERMISSIONS = 0;
|
||||||
for (const key in PermissionFlags) _ALL_PERMISSIONS |= PermissionFlags[key];
|
for (const key in PermissionFlags) _ALL_PERMISSIONS |= PermissionFlags[key];
|
||||||
|
|
||||||
exports.ALL_PERMISSIONS = _ALL_PERMISSIONS;
|
exports.ALL_PERMISSIONS = _ALL_PERMISSIONS;
|
||||||
|
|
||||||
exports.DEFAULT_PERMISSIONS = 104324097;
|
exports.DEFAULT_PERMISSIONS = 104324097;
|
||||||
|
|||||||
Reference in New Issue
Block a user