mirror of
https://github.com/danbulant/discord.js
synced 2026-07-06 11:40:41 +00:00
Merge branch 'master' into reply-prefix
This commit is contained in:
commit
1a699f2718
25 changed files with 179 additions and 55 deletions
|
|
@ -41,12 +41,12 @@ discord.js is a powerful [Node.js](https://nodejs.org) module that allows you to
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
**Node.js 11.0.0 or newer is required.**
|
**Node.js 12.0.0 or newer is required.**
|
||||||
Ignore any warnings about unmet peer dependencies, as they're all optional.
|
Ignore any warnings about unmet peer dependencies, as they're all optional.
|
||||||
|
|
||||||
Without voice support: `npm install discordjs/discord.js`
|
Without voice support: `npm install discord.js`
|
||||||
With voice support ([@discordjs/opus](https://www.npmjs.com/package/@discordjs/opus)): `npm install discordjs/discord.js @discordjs/opus`
|
With voice support ([@discordjs/opus](https://www.npmjs.com/package/@discordjs/opus)): `npm install discord.js @discordjs/opus`
|
||||||
With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discordjs/discord.js opusscript`
|
With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discord.js opusscript`
|
||||||
|
|
||||||
### Audio engines
|
### Audio engines
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a user a link to their avatar
|
* Send a user a link to their avatar
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A bot that welcomes new guild members when they join
|
* A bot that welcomes new guild members when they join
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ping pong bot, whenever you send "ping", it replies "pong".
|
* A ping pong bot, whenever you send "ping", it replies "pong".
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message using a webhook
|
* Send a message using a webhook
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ These questions are some of the most frequently asked.
|
||||||
|
|
||||||
## No matter what, I get `SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode`‽
|
## No matter what, I get `SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode`‽
|
||||||
|
|
||||||
Update to Node.js 11.0.0 or newer.
|
Update to Node.js 12.0.0 or newer.
|
||||||
|
|
||||||
## How do I get voice working?
|
## How do I get voice working?
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
# Version 12.0.0
|
||||||
|
|
||||||
|
v12.0.0 contains many new and improved features, optimisations, and bug fixes.
|
||||||
|
See [the changelog](https://github.com/discordjs/discord.js/releases/tag/12.0.0) for a full list of changes.
|
||||||
|
You can also visit [the guide](https://discordjs.guide/additional-info/changes-in-v12.html) for help with updating your v11 code to v12.
|
||||||
|
|
||||||
# Version 11.1.0
|
# Version 11.1.0
|
||||||
|
|
||||||
v11.1.0 features improved voice and gateway stability, as well as support for new features such as audit logs and searching for messages.
|
v11.1.0 features improved voice and gateway stability, as well as support for new features such as audit logs and searching for messages.
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,6 @@
|
||||||
|
|
||||||
Welcome to the discord.js v12 documentation.
|
Welcome to the discord.js v12 documentation.
|
||||||
|
|
||||||
v12 is still very much a work-in-progress, as we're aiming to make it the best it can possibly be before releasing.
|
|
||||||
Only use it if you are fond of living life on the bleeding edge.
|
|
||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
||||||
discord.js is a powerful [Node.js](https://nodejs.org) module that allows you to easily interact with the
|
discord.js is a powerful [Node.js](https://nodejs.org) module that allows you to easily interact with the
|
||||||
|
|
@ -36,12 +33,12 @@ discord.js is a powerful [Node.js](https://nodejs.org) module that allows you to
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
**Node.js 11.0.0 or newer is required.**
|
**Node.js 12.0.0 or newer is required.**
|
||||||
Ignore any warnings about unmet peer dependencies, as they're all optional.
|
Ignore any warnings about unmet peer dependencies, as they're all optional.
|
||||||
|
|
||||||
Without voice support: `npm install discordjs/discord.js`
|
Without voice support: `npm install discord.js`
|
||||||
With voice support ([@discordjs/opus](https://www.npmjs.com/package/@discordjs/opus)): `npm install discordjs/discord.js @discordjs/opus`
|
With voice support ([@discordjs/opus](https://www.npmjs.com/package/@discordjs/opus)): `npm install discord.js @discordjs/opus`
|
||||||
With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discordjs/discord.js opusscript`
|
With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discord.js opusscript`
|
||||||
|
|
||||||
### Audio engines
|
### Audio engines
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "discord.js",
|
"name": "discord.js",
|
||||||
"version": "12.0.0-dev",
|
"version": "12.0.0",
|
||||||
"description": "A powerful library for interacting with the Discord API",
|
"description": "A powerful library for interacting with the Discord API",
|
||||||
"main": "./src/index",
|
"main": "./src/index",
|
||||||
"types": "./typings/index.d.ts",
|
"types": "./typings/index.d.ts",
|
||||||
|
|
@ -141,7 +141,9 @@
|
||||||
"*.ts": "prettier --write --single-quote --print-width 120 --trailing-comma all --end-of-line lf"
|
"*.ts": "prettier --write --single-quote --print-width 120 --trailing-comma all --end-of-line lf"
|
||||||
},
|
},
|
||||||
"commitlint": {
|
"commitlint": {
|
||||||
"extends": ["@commitlint/config-angular"],
|
"extends": [
|
||||||
|
"@commitlint/config-angular"
|
||||||
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"type-enum": [
|
"type-enum": [
|
||||||
2,
|
2,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ const Webhook = require('../structures/Webhook');
|
||||||
const Collection = require('../util/Collection');
|
const Collection = require('../util/Collection');
|
||||||
const { Events, browser, DefaultOptions } = require('../util/Constants');
|
const { Events, browser, DefaultOptions } = require('../util/Constants');
|
||||||
const DataResolver = require('../util/DataResolver');
|
const DataResolver = require('../util/DataResolver');
|
||||||
|
const Intents = require('../util/Intents');
|
||||||
const Permissions = require('../util/Permissions');
|
const Permissions = require('../util/Permissions');
|
||||||
const Structures = require('../util/Structures');
|
const Structures = require('../util/Structures');
|
||||||
|
|
||||||
|
|
@ -381,6 +382,9 @@ class Client extends BaseClient {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_validateOptions(options = this.options) {
|
_validateOptions(options = this.options) {
|
||||||
|
if (typeof options.ws.intents !== 'undefined') {
|
||||||
|
options.ws.intents = Intents.resolve(options.ws.intents);
|
||||||
|
}
|
||||||
if (typeof options.shardCount !== 'number' || isNaN(options.shardCount) || options.shardCount < 1) {
|
if (typeof options.shardCount !== 'number' || isNaN(options.shardCount) || options.shardCount < 1) {
|
||||||
throw new TypeError('CLIENT_INVALID_OPTION', 'shardCount', 'a number greater than or equal to 1');
|
throw new TypeError('CLIENT_INVALID_OPTION', 'shardCount', 'a number greater than or equal to 1');
|
||||||
}
|
}
|
||||||
|
|
@ -415,9 +419,6 @@ class Client extends BaseClient {
|
||||||
if (typeof options.restSweepInterval !== 'number' || isNaN(options.restSweepInterval)) {
|
if (typeof options.restSweepInterval !== 'number' || isNaN(options.restSweepInterval)) {
|
||||||
throw new TypeError('CLIENT_INVALID_OPTION', 'restSweepInterval', 'a number');
|
throw new TypeError('CLIENT_INVALID_OPTION', 'restSweepInterval', 'a number');
|
||||||
}
|
}
|
||||||
if (!Array.isArray(options.disabledEvents)) {
|
|
||||||
throw new TypeError('CLIENT_INVALID_OPTION', 'disabledEvents', 'an Array');
|
|
||||||
}
|
|
||||||
if (typeof options.retryLimit !== 'number' || isNaN(options.retryLimit)) {
|
if (typeof options.retryLimit !== 'number' || isNaN(options.retryLimit)) {
|
||||||
throw new TypeError('CLIENT_INVALID_OPTION', 'retryLimit', 'a number');
|
throw new TypeError('CLIENT_INVALID_OPTION', 'retryLimit', 'a number');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,8 @@ class PlayInterface {
|
||||||
* @returns {StreamDispatcher}
|
* @returns {StreamDispatcher}
|
||||||
*/
|
*/
|
||||||
play(resource, options = {}) {
|
play(resource, options = {}) {
|
||||||
if (resource instanceof Broadcast) {
|
const VoiceBroadcast = require('../VoiceBroadcast');
|
||||||
|
if (resource instanceof VoiceBroadcast) {
|
||||||
if (!this.player.playBroadcast) throw new Error('VOICE_PLAY_INTERFACE_NO_BROADCAST');
|
if (!this.player.playBroadcast) throw new Error('VOICE_PLAY_INTERFACE_NO_BROADCAST');
|
||||||
return this.player.playBroadcast(resource, options);
|
return this.player.playBroadcast(resource, options);
|
||||||
}
|
}
|
||||||
|
|
@ -91,6 +92,3 @@ class PlayInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = PlayInterface;
|
module.exports = PlayInterface;
|
||||||
|
|
||||||
// eslint-disable-next-line import/order
|
|
||||||
const Broadcast = require('../VoiceBroadcast');
|
|
||||||
|
|
|
||||||
|
|
@ -382,7 +382,7 @@ class WebSocketManager extends EventEmitter {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet && !this.client.options.disabledEvents.includes(packet.t) && PacketHandlers[packet.t]) {
|
if (packet && PacketHandlers[packet.t]) {
|
||||||
PacketHandlers[packet.t](this.client, packet, shard);
|
PacketHandlers[packet.t](this.client, packet, shard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ const Messages = {
|
||||||
|
|
||||||
SHARDING_INVALID: 'Invalid shard settings were provided.',
|
SHARDING_INVALID: 'Invalid shard settings were provided.',
|
||||||
SHARDING_REQUIRED: 'This session would have handled too many guilds - Sharding is required.',
|
SHARDING_REQUIRED: 'This session would have handled too many guilds - Sharding is required.',
|
||||||
|
INVALID_INTENTS: 'Invalid intent provided for WebSocket intents.',
|
||||||
|
DISALLOWED_INTENTS: 'Privileged intent provided is not enabled or whitelisted.',
|
||||||
SHARDING_NO_SHARDS: 'No shards have been spawned.',
|
SHARDING_NO_SHARDS: 'No shards have been spawned.',
|
||||||
SHARDING_IN_PROCESS: 'Shards are still being spawned.',
|
SHARDING_IN_PROCESS: 'Shards are still being spawned.',
|
||||||
SHARDING_ALREADY_SPAWNED: count => `Already spawned ${count} shards.`,
|
SHARDING_ALREADY_SPAWNED: count => `Already spawned ${count} shards.`,
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@ module.exports = {
|
||||||
Collection: require('./util/Collection'),
|
Collection: require('./util/Collection'),
|
||||||
Constants: require('./util/Constants'),
|
Constants: require('./util/Constants'),
|
||||||
DataResolver: require('./util/DataResolver'),
|
DataResolver: require('./util/DataResolver'),
|
||||||
LimitedCollection: require('./util/LimitedCollection'),
|
|
||||||
BaseManager: require('./managers/BaseManager'),
|
BaseManager: require('./managers/BaseManager'),
|
||||||
DiscordAPIError: require('./rest/DiscordAPIError'),
|
DiscordAPIError: require('./rest/DiscordAPIError'),
|
||||||
HTTPError: require('./rest/HTTPError'),
|
HTTPError: require('./rest/HTTPError'),
|
||||||
MessageFlags: require('./util/MessageFlags'),
|
MessageFlags: require('./util/MessageFlags'),
|
||||||
|
Intents: require('./util/Intents'),
|
||||||
Permissions: require('./util/Permissions'),
|
Permissions: require('./util/Permissions'),
|
||||||
Speaking: require('./util/Speaking'),
|
Speaking: require('./util/Speaking'),
|
||||||
Snowflake: require('./util/Snowflake'),
|
Snowflake: require('./util/Snowflake'),
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class GuildManager extends BaseManager {
|
||||||
/**
|
/**
|
||||||
* Partial data for a Role.
|
* Partial data for a Role.
|
||||||
* @typedef {Object} PartialRoleData
|
* @typedef {Object} PartialRoleData
|
||||||
* @property {number} id The ID for this role, used to set channel overrides,
|
* @property {number} [id] The ID for this role, used to set channel overrides,
|
||||||
* this is a placeholder and will be replaced by the API after consumption
|
* this is a placeholder and will be replaced by the API after consumption
|
||||||
* @property {string} [name] The name of the role
|
* @property {string} [name] The name of the role
|
||||||
* @property {ColorResolvable} [color] The color of the role, either a hex string or a base 10 number
|
* @property {ColorResolvable} [color] The color of the role, either a hex string or a base 10 number
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class MessageManager extends BaseManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cache of Messages
|
* The cache of Messages
|
||||||
* @type {LimitedCollection<Snowflake, Message>}
|
* @type {Collection<Snowflake, Message>}
|
||||||
* @name MessageManager#cache
|
* @name MessageManager#cache
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ class Shard extends EventEmitter {
|
||||||
* @param {string} prop Name of the client property to get, using periods for nesting
|
* @param {string} prop Name of the client property to get, using periods for nesting
|
||||||
* @returns {Promise<*>}
|
* @returns {Promise<*>}
|
||||||
* @example
|
* @example
|
||||||
* shard.fetchClientValue('guilds.size')
|
* shard.fetchClientValue('guilds.cache.size')
|
||||||
* .then(count => console.log(`${count} guilds in shard ${shard.id}`))
|
* .then(count => console.log(`${count} guilds in shard ${shard.id}`))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,8 @@ class GuildMember extends Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this member is manageable in terms of role hierarchy by the client user
|
* Whether the client user is above this user in the hierarchy, according to role position and guild ownership.
|
||||||
|
* This is a prerequisite for many moderative actions.
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class TextBasedChannel {
|
||||||
* @property {MessageEmbed|Object} [embed] An embed for the message
|
* @property {MessageEmbed|Object} [embed] An embed for the message
|
||||||
* (see [here](https://discordapp.com/developers/docs/resources/channel#embed-object) for more details)
|
* (see [here](https://discordapp.com/developers/docs/resources/channel#embed-object) for more details)
|
||||||
* @property {'none' | 'all' | 'everyone'} [disableMentions=this.client.options.disableMentions] Whether or not
|
* @property {'none' | 'all' | 'everyone'} [disableMentions=this.client.options.disableMentions] Whether or not
|
||||||
* all mentionsor everyone/here mentions should be sanitized to prevent unexpected mentions
|
* all mentions or everyone/here mentions should be sanitized to prevent unexpected mentions
|
||||||
* @property {FileOptions[]|BufferResolvable[]} [files] Files to send with the message
|
* @property {FileOptions[]|BufferResolvable[]} [files] Files to send with the message
|
||||||
* @property {string|boolean} [code] Language for optional codeblock formatting to apply
|
* @property {string|boolean} [code] Language for optional codeblock formatting to apply
|
||||||
* @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if
|
* @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,6 @@ const browser = (exports.browser = typeof window !== 'undefined');
|
||||||
* (or 0 for never)
|
* (or 0 for never)
|
||||||
* @property {number} [retryLimit=1] How many times to retry on 5XX errors (Infinity for indefinite amount of retries)
|
* @property {number} [retryLimit=1] How many times to retry on 5XX errors (Infinity for indefinite amount of retries)
|
||||||
* @property {PresenceData} [presence] Presence data to use upon login
|
* @property {PresenceData} [presence] Presence data to use upon login
|
||||||
* @property {WSEventType[]} [disabledEvents] An array of disabled websocket events. Events in this array will not be
|
|
||||||
* processed, potentially resulting in performance improvements for larger bots. Only disable events you are
|
|
||||||
* 100% certain you don't need, as many are important, but not obviously so. The safest one to disable with the
|
|
||||||
* most impact is typically `TYPING_START`.
|
|
||||||
* @property {WebsocketOptions} [ws] Options for the WebSocket
|
* @property {WebsocketOptions} [ws] Options for the WebSocket
|
||||||
* @property {HTTPOptions} [http] HTTP options
|
* @property {HTTPOptions} [http] HTTP options
|
||||||
*/
|
*/
|
||||||
|
|
@ -60,7 +56,6 @@ exports.DefaultOptions = {
|
||||||
*/
|
*/
|
||||||
replyPrefixer: null,
|
replyPrefixer: null,
|
||||||
restWsBridgeTimeout: 5000,
|
restWsBridgeTimeout: 5000,
|
||||||
disabledEvents: [],
|
|
||||||
restRequestTimeout: 15000,
|
restRequestTimeout: 15000,
|
||||||
retryLimit: 1,
|
retryLimit: 1,
|
||||||
restTimeOffset: 500,
|
restTimeOffset: 500,
|
||||||
|
|
@ -71,6 +66,7 @@ exports.DefaultOptions = {
|
||||||
* WebSocket options (these are left as snake_case to match the API)
|
* WebSocket options (these are left as snake_case to match the API)
|
||||||
* @typedef {Object} WebsocketOptions
|
* @typedef {Object} WebsocketOptions
|
||||||
* @property {number} [large_threshold=250] Number of members in a guild to be considered large
|
* @property {number} [large_threshold=250] Number of members in a guild to be considered large
|
||||||
|
* @property {IntentsResolvable} [intents] Intents to enable for this connection
|
||||||
*/
|
*/
|
||||||
ws: {
|
ws: {
|
||||||
large_threshold: 250,
|
large_threshold: 250,
|
||||||
|
|
@ -108,6 +104,8 @@ exports.WSCodes = {
|
||||||
4004: 'TOKEN_INVALID',
|
4004: 'TOKEN_INVALID',
|
||||||
4010: 'SHARDING_INVALID',
|
4010: 'SHARDING_INVALID',
|
||||||
4011: 'SHARDING_REQUIRED',
|
4011: 'SHARDING_REQUIRED',
|
||||||
|
4013: 'INVALID_INTENTS',
|
||||||
|
4014: 'DISALLOWED_INTENTS',
|
||||||
};
|
};
|
||||||
|
|
||||||
const AllowedImageFormats = ['webp', 'png', 'jpg', 'gif'];
|
const AllowedImageFormats = ['webp', 'png', 'jpg', 'gif'];
|
||||||
|
|
|
||||||
76
src/util/Intents.js
Normal file
76
src/util/Intents.js
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
'use strict';
|
||||||
|
const BitField = require('./BitField');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data structure that makes it easy to calculate intents.
|
||||||
|
* @extends {BitField}
|
||||||
|
*/
|
||||||
|
class Intents extends BitField {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data that can be resolved to give a permission number. This can be:
|
||||||
|
* * A string (see {@link Intents.FLAGS})
|
||||||
|
* * An intents flag
|
||||||
|
* * An instance of Intents
|
||||||
|
* * An array of IntentsResolvable
|
||||||
|
* @typedef {string|number|Intents|IntentsResolvable[]} IntentsResolvable
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Numeric websocket intents. All available properties:
|
||||||
|
* * `GUILDS`
|
||||||
|
* * `GUILD_MEMBERS`
|
||||||
|
* * `GUILD_BANS`
|
||||||
|
* * `GUILD_EMOJIS`
|
||||||
|
* * `GUILD_INTEGRATIONS`
|
||||||
|
* * `GUILD_WEBHOOKS`
|
||||||
|
* * `GUILD_INVITES`
|
||||||
|
* * `GUILD_VOICE_STATES`
|
||||||
|
* * `GUILD_PRESENCES`
|
||||||
|
* * `GUILD_MESSAGES`
|
||||||
|
* * `GUILD_MESSAGE_REACTIONS`
|
||||||
|
* * `GUILD_MESSAGE_TYPING`
|
||||||
|
* * `DIRECT_MESSAGES`
|
||||||
|
* * `DIRECT_MESSAGE_REACTIONS`
|
||||||
|
* * `DIRECT_MESSAGE_TYPING`
|
||||||
|
* @type {Object}
|
||||||
|
* @see {@link https://discordapp.com/developers/docs/topics/gateway#list-of-intents}
|
||||||
|
*/
|
||||||
|
Intents.FLAGS = {
|
||||||
|
GUILDS: 1 << 0,
|
||||||
|
GUILD_MEMBERS: 1 << 1,
|
||||||
|
GUILD_BANS: 1 << 2,
|
||||||
|
GUILD_EMOJIS: 1 << 3,
|
||||||
|
GUILD_INTEGRATIONS: 1 << 4,
|
||||||
|
GUILD_WEBHOOKS: 1 << 5,
|
||||||
|
GUILD_INVITES: 1 << 6,
|
||||||
|
GUILD_VOICE_STATES: 1 << 7,
|
||||||
|
GUILD_PRESENCES: 1 << 8,
|
||||||
|
GUILD_MESSAGES: 1 << 9,
|
||||||
|
GUILD_MESSAGE_REACTIONS: 1 << 10,
|
||||||
|
GUILD_MESSAGE_TYPING: 1 << 11,
|
||||||
|
DIRECT_MESSAGES: 1 << 12,
|
||||||
|
DIRECT_MESSAGE_REACTIONS: 1 << 13,
|
||||||
|
DIRECT_MESSAGE_TYPING: 1 << 14,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bitfield representing all privileged intents
|
||||||
|
* @type {number}
|
||||||
|
* @see {@link https://discordapp.com/developers/docs/topics/gateway#privileged-intents}
|
||||||
|
*/
|
||||||
|
Intents.PRIVILEGED = Intents.FLAGS.GUILD_MEMBERS | Intents.FLAGS.GUILD_PRESENCES;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bitfield representing all intents combined
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Intents.ALL = Object.values(Intents.FLAGS).reduce((acc, p) => acc | p, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bitfield representing all non-privileged intents
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Intents.NON_PRIVILEGED = Intents.ALL & ~Intents.PRIVILEGED;
|
||||||
|
|
||||||
|
module.exports = Intents;
|
||||||
|
|
@ -8,6 +8,7 @@ const Collection = require('./Collection.js');
|
||||||
* @extends {Collection}
|
* @extends {Collection}
|
||||||
* @param {number} [maxSize=0] The maximum size of the Collection
|
* @param {number} [maxSize=0] The maximum size of the Collection
|
||||||
* @param {Iterable} [iterable=null] Optional entries passed to the Map constructor.
|
* @param {Iterable} [iterable=null] Optional entries passed to the Map constructor.
|
||||||
|
* @private
|
||||||
*/
|
*/
|
||||||
class LimitedCollection extends Collection {
|
class LimitedCollection extends Collection {
|
||||||
constructor(maxSize = 0, iterable = null) {
|
constructor(maxSize = 0, iterable = null) {
|
||||||
|
|
@ -24,6 +25,10 @@ class LimitedCollection extends Collection {
|
||||||
if (this.size >= this.maxSize && !this.has(key)) this.delete(this.firstKey());
|
if (this.size >= this.maxSize && !this.has(key)) this.delete(this.firstKey());
|
||||||
return super.set(key, value);
|
return super.set(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get [Symbol.species]() {
|
||||||
|
return Collection;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = LimitedCollection;
|
module.exports = LimitedCollection;
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ const Discord = require('../src');
|
||||||
const { Util } = Discord;
|
const { Util } = Discord;
|
||||||
|
|
||||||
const client = new Discord.Client({
|
const client = new Discord.Client({
|
||||||
// To see a difference, comment out disableMentions and run the same tests using disableEveryone
|
// To see a difference, comment out disableMentions and run the same tests using disableEveryone
|
||||||
// You will notice that all messages will mention @everyone
|
// You will notice that all messages will mention @everyone
|
||||||
//disableEveryone: true
|
// disableEveryone: true
|
||||||
disableMentions: 'everyone'
|
disableMentions: 'everyone',
|
||||||
});
|
});
|
||||||
|
|
||||||
const tests = [
|
const tests = [
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
const Discord = require('../');
|
'use strict';
|
||||||
|
|
||||||
const { token } = require('./auth');
|
const { token } = require('./auth');
|
||||||
|
const Discord = require('../');
|
||||||
|
|
||||||
const sharder = new Discord.ShardingManager(`${process.cwd()}/test/shard.js`, { token, respawn: false });
|
const sharder = new Discord.ShardingManager(`${process.cwd()}/test/shard.js`, { token, respawn: false });
|
||||||
|
|
||||||
|
|
|
||||||
62
typings/index.d.ts
vendored
62
typings/index.d.ts
vendored
|
|
@ -1,12 +1,12 @@
|
||||||
declare enum ChannelType {
|
declare enum ChannelType {
|
||||||
text,
|
text = 0,
|
||||||
dm,
|
dm = 1,
|
||||||
voice,
|
voice = 2,
|
||||||
group,
|
group = 3,
|
||||||
category,
|
category = 4,
|
||||||
news,
|
news = 5,
|
||||||
store,
|
store = 6,
|
||||||
unknown,
|
unknown = 7,
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'discord.js' {
|
declare module 'discord.js' {
|
||||||
|
|
@ -133,6 +133,7 @@ declare module 'discord.js' {
|
||||||
|
|
||||||
export class CategoryChannel extends GuildChannel {
|
export class CategoryChannel extends GuildChannel {
|
||||||
public readonly children: Collection<Snowflake, GuildChannel>;
|
public readonly children: Collection<Snowflake, GuildChannel>;
|
||||||
|
public type: 'category';
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Channel extends Base {
|
export class Channel extends Base {
|
||||||
|
|
@ -552,7 +553,6 @@ declare module 'discord.js' {
|
||||||
DARK_BUT_NOT_BLACK: 0x2c2f33;
|
DARK_BUT_NOT_BLACK: 0x2c2f33;
|
||||||
NOT_QUITE_BLACK: 0x23272a;
|
NOT_QUITE_BLACK: 0x23272a;
|
||||||
};
|
};
|
||||||
VerificationLevels: ['None', 'Low', 'Medium', '(╯°□°)╯︵ ┻━┻', '┻━┻ ミヽ(ಠ益ಠ)ノ彡┻━┻'];
|
|
||||||
Status: {
|
Status: {
|
||||||
READY: 0;
|
READY: 0;
|
||||||
CONNECTING: 1;
|
CONNECTING: 1;
|
||||||
|
|
@ -689,6 +689,7 @@ declare module 'discord.js' {
|
||||||
public messages: MessageManager;
|
public messages: MessageManager;
|
||||||
public recipient: User;
|
public recipient: User;
|
||||||
public readonly partial: false;
|
public readonly partial: false;
|
||||||
|
public type: 'dm';
|
||||||
public fetch(): Promise<DMChannel>;
|
public fetch(): Promise<DMChannel>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -861,6 +862,7 @@ declare module 'discord.js' {
|
||||||
public readonly permissionsLocked: boolean | null;
|
public readonly permissionsLocked: boolean | null;
|
||||||
public readonly position: number;
|
public readonly position: number;
|
||||||
public rawPosition: number;
|
public rawPosition: number;
|
||||||
|
public type: Exclude<keyof typeof ChannelType, 'dm' | 'group' | 'unknown'>;
|
||||||
public readonly viewable: boolean;
|
public readonly viewable: boolean;
|
||||||
public clone(options?: GuildChannelCloneOptions): Promise<this>;
|
public clone(options?: GuildChannelCloneOptions): Promise<this>;
|
||||||
public createInvite(options?: InviteOptions): Promise<Invite>;
|
public createInvite(options?: InviteOptions): Promise<Invite>;
|
||||||
|
|
@ -977,6 +979,14 @@ declare module 'discord.js' {
|
||||||
public sync(): Promise<Integration>;
|
public sync(): Promise<Integration>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Intents extends BitField<IntentsString> {
|
||||||
|
public static FLAGS: Record<IntentsString, number>;
|
||||||
|
public static PRIVILEGED: number;
|
||||||
|
public static ALL: number;
|
||||||
|
public static NON_PRIVILEGED: number;
|
||||||
|
public static resolve(bit?: BitFieldResolvable<IntentsString>): number;
|
||||||
|
}
|
||||||
|
|
||||||
export class Invite extends Base {
|
export class Invite extends Base {
|
||||||
constructor(client: Client, data: object);
|
constructor(client: Client, data: object);
|
||||||
public channel: GuildChannel | PartialGroupDMChannel;
|
public channel: GuildChannel | PartialGroupDMChannel;
|
||||||
|
|
@ -1211,6 +1221,7 @@ declare module 'discord.js' {
|
||||||
public messages: MessageManager;
|
public messages: MessageManager;
|
||||||
public nsfw: boolean;
|
public nsfw: boolean;
|
||||||
public topic: string | null;
|
public topic: string | null;
|
||||||
|
public type: 'news';
|
||||||
public createWebhook(
|
public createWebhook(
|
||||||
name: string,
|
name: string,
|
||||||
options?: { avatar?: BufferResolvable | Base64Resolvable; reason?: string },
|
options?: { avatar?: BufferResolvable | Base64Resolvable; reason?: string },
|
||||||
|
|
@ -1546,6 +1557,7 @@ declare module 'discord.js' {
|
||||||
constructor(guild: Guild, data?: object);
|
constructor(guild: Guild, data?: object);
|
||||||
public messages: MessageManager;
|
public messages: MessageManager;
|
||||||
public nsfw: boolean;
|
public nsfw: boolean;
|
||||||
|
public type: 'text';
|
||||||
public rateLimitPerUser: number;
|
public rateLimitPerUser: number;
|
||||||
public topic: string | null;
|
public topic: string | null;
|
||||||
public createWebhook(
|
public createWebhook(
|
||||||
|
|
@ -1654,6 +1666,7 @@ declare module 'discord.js' {
|
||||||
public readonly full: boolean;
|
public readonly full: boolean;
|
||||||
public readonly joinable: boolean;
|
public readonly joinable: boolean;
|
||||||
public readonly speakable: boolean;
|
public readonly speakable: boolean;
|
||||||
|
public type: 'voice';
|
||||||
public userLimit: number;
|
public userLimit: number;
|
||||||
public join(): Promise<VoiceConnection>;
|
public join(): Promise<VoiceConnection>;
|
||||||
public leave(): void;
|
public leave(): void;
|
||||||
|
|
@ -1901,11 +1914,6 @@ declare module 'discord.js' {
|
||||||
public toJSON(): object;
|
public toJSON(): object;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LimitedCollection<K, V> extends Collection<K, V> {
|
|
||||||
public constructor(maxSize: number, iterable: Iterable<any>);
|
|
||||||
public maxSize: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region Managers
|
//#region Managers
|
||||||
|
|
@ -2003,7 +2011,7 @@ declare module 'discord.js' {
|
||||||
export class MessageManager extends BaseManager<Snowflake, Message, MessageResolvable> {
|
export class MessageManager extends BaseManager<Snowflake, Message, MessageResolvable> {
|
||||||
constructor(channel: TextChannel | DMChannel, iterable?: Iterable<any>);
|
constructor(channel: TextChannel | DMChannel, iterable?: Iterable<any>);
|
||||||
public channel: TextBasedChannelFields;
|
public channel: TextBasedChannelFields;
|
||||||
public cache: LimitedCollection<Snowflake, Message>;
|
public cache: Collection<Snowflake, Message>;
|
||||||
public fetch(message: Snowflake, cache?: boolean): Promise<Message>;
|
public fetch(message: Snowflake, cache?: boolean): Promise<Message>;
|
||||||
public fetch(options?: ChannelLogsQueryOptions, cache?: boolean): Promise<Collection<Snowflake, Message>>;
|
public fetch(options?: ChannelLogsQueryOptions, cache?: boolean): Promise<Collection<Snowflake, Message>>;
|
||||||
public fetchPinned(cache?: boolean): Promise<Collection<Snowflake, Message>>;
|
public fetchPinned(cache?: boolean): Promise<Collection<Snowflake, Message>>;
|
||||||
|
|
@ -2293,7 +2301,6 @@ declare module 'discord.js' {
|
||||||
restSweepInterval?: number;
|
restSweepInterval?: number;
|
||||||
retryLimit?: number;
|
retryLimit?: number;
|
||||||
presence?: PresenceData;
|
presence?: PresenceData;
|
||||||
disabledEvents?: WSEventType[];
|
|
||||||
ws?: WebSocketOptions;
|
ws?: WebSocketOptions;
|
||||||
http?: HTTPOptions;
|
http?: HTTPOptions;
|
||||||
}
|
}
|
||||||
|
|
@ -2513,7 +2520,10 @@ declare module 'discord.js' {
|
||||||
interface GuildCreateChannelOptions {
|
interface GuildCreateChannelOptions {
|
||||||
permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;
|
permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;
|
||||||
topic?: string;
|
topic?: string;
|
||||||
type?: Exclude<keyof typeof ChannelType, 'dm' | 'group' | 'unknown'>;
|
type?: Exclude<
|
||||||
|
keyof typeof ChannelType | ChannelType,
|
||||||
|
'dm' | 'group' | 'unknown' | ChannelType.dm | ChannelType.group | ChannelType.unknown
|
||||||
|
>;
|
||||||
nsfw?: boolean;
|
nsfw?: boolean;
|
||||||
parent?: ChannelResolvable;
|
parent?: ChannelResolvable;
|
||||||
bitrate?: number;
|
bitrate?: number;
|
||||||
|
|
@ -2623,6 +2633,23 @@ declare module 'discord.js' {
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IntentsString =
|
||||||
|
| 'GUILDS'
|
||||||
|
| 'GUILD_MEMBERS'
|
||||||
|
| 'GUILD_BANS'
|
||||||
|
| 'GUILD_EMOJIS'
|
||||||
|
| 'GUILD_INTEGRATIONS'
|
||||||
|
| 'GUILD_WEBHOOKS'
|
||||||
|
| 'GUILD_INVITES'
|
||||||
|
| 'GUILD_VOICE_STATES'
|
||||||
|
| 'GUILD_PRESENCES'
|
||||||
|
| 'GUILD_MESSAGES'
|
||||||
|
| 'GUILD_MESSAGE_REACTIONS'
|
||||||
|
| 'GUILD_MESSAGE_TYPING'
|
||||||
|
| 'DIRECT_MESSAGES'
|
||||||
|
| 'DIRECT_MESSAGE_REACTIONS'
|
||||||
|
| 'DIRECT_MESSAGE_TYPING';
|
||||||
|
|
||||||
interface InviteOptions {
|
interface InviteOptions {
|
||||||
temporary?: boolean;
|
temporary?: boolean;
|
||||||
maxAge?: number;
|
maxAge?: number;
|
||||||
|
|
@ -2981,6 +3008,7 @@ declare module 'discord.js' {
|
||||||
interface WebSocketOptions {
|
interface WebSocketOptions {
|
||||||
large_threshold?: number;
|
large_threshold?: number;
|
||||||
compress?: boolean;
|
compress?: boolean;
|
||||||
|
intents?: BitFieldResolvable<IntentsString> | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type WSEventType =
|
type WSEventType =
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue