mirror of
https://github.com/danbulant/discord.js
synced 2026-06-20 07:02:00 +00:00
Merge remote-tracking branch 'upstream/master' into inline-replies
This commit is contained in:
commit
1028183c23
39 changed files with 914 additions and 748 deletions
2
.github/CONTRIBUTING.md
vendored
2
.github/CONTRIBUTING.md
vendored
|
|
@ -11,7 +11,7 @@ is a great boon to your development process.
|
|||
To get ready to work on the codebase, please do the following:
|
||||
|
||||
1. Fork & clone the repository, and make sure you're on the **master** branch
|
||||
2. Run `npm install`
|
||||
2. Run `npm ci`
|
||||
3. If you're working on voice, also run `npm install @discordjs/opus` or `npm install opusscript`
|
||||
4. Code your heart out!
|
||||
5. Run `npm test` to run ESLint and ensure any JSDoc changes are valid
|
||||
|
|
|
|||
4
.github/workflows/deploy.yml
vendored
4
.github/workflows/deploy.yml
vendored
|
|
@ -21,7 +21,7 @@ jobs:
|
|||
node-version: 12
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
|
||||
- name: Build and deploy documentation
|
||||
uses: discordjs/action-docs@v1
|
||||
|
|
@ -41,7 +41,7 @@ jobs:
|
|||
node-version: 12
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
|
||||
- name: Build and deploy webpack
|
||||
uses: discordjs/action-webpack@v1
|
||||
|
|
|
|||
8
.github/workflows/test-cron.yml
vendored
8
.github/workflows/test-cron.yml
vendored
|
|
@ -16,7 +16,7 @@ jobs:
|
|||
node-version: 12
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
|
||||
- name: Run ESLint
|
||||
uses: icrawl/action-eslint@v1
|
||||
|
|
@ -34,7 +34,7 @@ jobs:
|
|||
node-version: 12
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
|
||||
- name: Run TSLint
|
||||
run: npm run lint:typings
|
||||
|
|
@ -52,7 +52,7 @@ jobs:
|
|||
node-version: 12
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
|
||||
- name: Register Problem Matcher
|
||||
run: echo "##[add-matcher].github/tsc.json"
|
||||
|
|
@ -73,7 +73,7 @@ jobs:
|
|||
node-version: 12
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
|
||||
- name: Test documentation
|
||||
run: npm run docs:test
|
||||
|
|
|
|||
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
|
|
@ -14,7 +14,7 @@ jobs:
|
|||
node-version: 12
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
|
||||
- name: Run ESLint
|
||||
uses: icrawl/action-eslint@v1
|
||||
|
|
@ -32,7 +32,7 @@ jobs:
|
|||
node-version: 12
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
|
||||
- name: Run TSLint
|
||||
run: npm run lint:typings
|
||||
|
|
@ -50,7 +50,7 @@ jobs:
|
|||
node-version: 12
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
|
||||
- name: Register Problem Matcher
|
||||
run: echo "##[add-matcher].github/tsc.json"
|
||||
|
|
@ -71,7 +71,7 @@ jobs:
|
|||
node-version: 12
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
|
||||
- name: Test documentation
|
||||
run: npm run docs:test
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ export const {
|
|||
SnowflakeUtil,
|
||||
Structures,
|
||||
SystemChannelFlags,
|
||||
UserFlags,
|
||||
Util,
|
||||
version,
|
||||
ChannelManager,
|
||||
|
|
@ -34,6 +35,7 @@ export const {
|
|||
GuildMemberManager,
|
||||
GuildMemberRoleManager,
|
||||
GuildManager,
|
||||
ReactionManager,
|
||||
ReactionUserManager,
|
||||
MessageManager,
|
||||
PresenceManager,
|
||||
|
|
@ -45,9 +47,11 @@ export const {
|
|||
resolveColor,
|
||||
resolveString,
|
||||
splitMessage,
|
||||
Application,
|
||||
Base,
|
||||
Activity,
|
||||
APIMessage,
|
||||
BaseGuildEmoji,
|
||||
CategoryChannel,
|
||||
Channel,
|
||||
ClientApplication,
|
||||
|
|
@ -60,6 +64,7 @@ export const {
|
|||
GuildChannel,
|
||||
GuildEmoji,
|
||||
GuildMember,
|
||||
GuildPreview,
|
||||
Integration,
|
||||
Invite,
|
||||
Message,
|
||||
|
|
|
|||
1150
package-lock.json
generated
1150
package-lock.json
generated
File diff suppressed because it is too large
Load diff
26
package.json
26
package.json
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "discord.js",
|
||||
"version": "12.3.1",
|
||||
"version": "12.4.1",
|
||||
"description": "A powerful library for interacting with the Discord API",
|
||||
"main": "./src/index",
|
||||
"types": "./typings/index.d.ts",
|
||||
|
|
@ -60,23 +60,23 @@
|
|||
"@commitlint/cli": "^11.0.0",
|
||||
"@commitlint/config-angular": "^11.0.0",
|
||||
"@types/node": "^12.12.6",
|
||||
"@types/ws": "^7.2.6",
|
||||
"@types/ws": "^7.2.7",
|
||||
"cross-env": "^7.0.2",
|
||||
"discord.js-docgen": "discordjs/docgen",
|
||||
"dtslint": "^4.0.0",
|
||||
"eslint": "^7.9.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-plugin-import": "^2.22.0",
|
||||
"discord.js-docgen": "git+https://github.com/discordjs/docgen.git",
|
||||
"dtslint": "^4.0.4",
|
||||
"eslint": "^7.11.0",
|
||||
"eslint-config-prettier": "^6.13.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-prettier": "^3.1.4",
|
||||
"husky": "^4.3.0",
|
||||
"jest": "^26.4.2",
|
||||
"jest": "^26.6.0",
|
||||
"json-filter-loader": "^1.0.0",
|
||||
"lint-staged": "^10.3.0",
|
||||
"prettier": "^2.1.1",
|
||||
"terser-webpack-plugin": "^4.2.0",
|
||||
"lint-staged": "^10.4.2",
|
||||
"prettier": "^2.1.2",
|
||||
"terser-webpack-plugin": "^4.2.3",
|
||||
"tslint": "^6.1.3",
|
||||
"typescript": "^4.0.2",
|
||||
"webpack": "^4.44.1",
|
||||
"typescript": "^4.0.3",
|
||||
"webpack": "^4.44.2",
|
||||
"webpack-cli": "^3.3.12"
|
||||
},
|
||||
"engines": {
|
||||
|
|
|
|||
|
|
@ -432,6 +432,13 @@ class Client extends BaseClient {
|
|||
if (typeof options.messageSweepInterval !== 'number' || isNaN(options.messageSweepInterval)) {
|
||||
throw new TypeError('CLIENT_INVALID_OPTION', 'messageSweepInterval', 'a number');
|
||||
}
|
||||
if (
|
||||
typeof options.messageEditHistoryMaxSize !== 'number' ||
|
||||
isNaN(options.messageEditHistoryMaxSize) ||
|
||||
options.messageEditHistoryMaxSize < -1
|
||||
) {
|
||||
throw new TypeError('CLIENT_INVALID_OPTION', 'messageEditHistoryMaxSize', 'a number greater than or equal to -1');
|
||||
}
|
||||
if (typeof options.fetchAllMembers !== 'boolean') {
|
||||
throw new TypeError('CLIENT_INVALID_OPTION', 'fetchAllMembers', 'a boolean');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class GenericAction {
|
|||
const guild = this.client.guilds.cache.get(data.guild_id);
|
||||
if (guild) {
|
||||
const member = this.getMember(data.member, guild);
|
||||
return member ? member.user : undefined;
|
||||
return member ? member.user : this.getUser(data.member.user);
|
||||
}
|
||||
}
|
||||
return this.getUser(data);
|
||||
|
|
|
|||
|
|
@ -5,13 +5,14 @@ const { Events } = require('../../util/Constants');
|
|||
|
||||
class GuildEmojiCreateAction extends Action {
|
||||
handle(guild, createdEmoji) {
|
||||
const already = guild.emojis.cache.has(createdEmoji.id);
|
||||
const emoji = guild.emojis.add(createdEmoji);
|
||||
/**
|
||||
* Emitted whenever a custom emoji is created in a guild.
|
||||
* @event Client#emojiCreate
|
||||
* @param {GuildEmoji} emoji The emoji that was created
|
||||
*/
|
||||
this.client.emit(Events.GUILD_EMOJI_CREATE, emoji);
|
||||
if (!already) this.client.emit(Events.GUILD_EMOJI_CREATE, emoji);
|
||||
return { emoji };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class InviteCreateAction extends Action {
|
|||
const client = this.client;
|
||||
const channel = client.channels.cache.get(data.channel_id);
|
||||
const guild = client.guilds.cache.get(data.guild_id);
|
||||
if (!channel && !guild) return false;
|
||||
if (!channel) return false;
|
||||
|
||||
const inviteData = Object.assign(data, { channel, guild });
|
||||
const invite = new Invite(client, inviteData);
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ class MessageUpdateAction extends Action {
|
|||
const { id, channel_id, guild_id, author, timestamp, type } = data;
|
||||
const message = this.getMessage({ id, channel_id, guild_id, author, timestamp, type }, channel);
|
||||
if (message) {
|
||||
message.patch(data);
|
||||
const old = message.patch(data);
|
||||
return {
|
||||
old: message._edits[0],
|
||||
old,
|
||||
updated: message,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ class VoiceConnection extends EventEmitter {
|
|||
|
||||
/**
|
||||
* The voice state of this connection
|
||||
* @type {VoiceState}
|
||||
* @type {?VoiceState}
|
||||
*/
|
||||
get voice() {
|
||||
return this.channel.guild.voice;
|
||||
|
|
@ -203,8 +203,8 @@ class VoiceConnection extends EventEmitter {
|
|||
* Set the token and endpoint required to connect to the voice servers.
|
||||
* @param {string} token The voice token
|
||||
* @param {string} endpoint The voice endpoint
|
||||
* @private
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
setTokenAndEndpoint(token, endpoint) {
|
||||
this.emit('debug', `Token "${token}" and endpoint "${endpoint}"`);
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class StreamDispatcher extends Writable {
|
|||
* The broadcast controlling this dispatcher, if any
|
||||
* @type {?VoiceBroadcast}
|
||||
*/
|
||||
this.broadcast = this.streams.broadcast;
|
||||
this.broadcast = this.streams.broadcast || null;
|
||||
|
||||
this._pausedTime = 0;
|
||||
this._silentPausedTime = 0;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class WebSocketManager extends EventEmitter {
|
|||
* The gateway this manager uses
|
||||
* @type {?string}
|
||||
*/
|
||||
this.gateway = undefined;
|
||||
this.gateway = null;
|
||||
|
||||
/**
|
||||
* The amount of shards this manager handles
|
||||
|
|
@ -98,11 +98,11 @@ class WebSocketManager extends EventEmitter {
|
|||
* The current session limit of the client
|
||||
* @private
|
||||
* @type {?Object}
|
||||
* @prop {number} total Total number of identifies available
|
||||
* @prop {number} remaining Number of identifies remaining
|
||||
* @prop {number} reset_after Number of milliseconds after which the limit resets
|
||||
* @property {number} total Total number of identifies available
|
||||
* @property {number} remaining Number of identifies remaining
|
||||
* @property {number} reset_after Number of milliseconds after which the limit resets
|
||||
*/
|
||||
this.sessionStartLimit = undefined;
|
||||
this.sessionStartLimit = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -212,7 +212,7 @@ class WebSocketManager extends EventEmitter {
|
|||
|
||||
if (UNRESUMABLE_CLOSE_CODES.includes(event.code)) {
|
||||
// These event codes cannot be resumed
|
||||
shard.sessionID = undefined;
|
||||
shard.sessionID = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ class WebSocketShard extends EventEmitter {
|
|||
|
||||
/**
|
||||
* The current session ID of the shard
|
||||
* @type {string}
|
||||
* @type {?string}
|
||||
* @private
|
||||
*/
|
||||
this.sessionID = undefined;
|
||||
this.sessionID = null;
|
||||
|
||||
/**
|
||||
* The previous heartbeat ping of the shard
|
||||
|
|
@ -124,7 +124,7 @@ class WebSocketShard extends EventEmitter {
|
|||
* @type {?NodeJS.Timeout}
|
||||
* @private
|
||||
*/
|
||||
Object.defineProperty(this, 'helloTimeout', { value: undefined, writable: true });
|
||||
Object.defineProperty(this, 'helloTimeout', { value: null, writable: true });
|
||||
|
||||
/**
|
||||
* If the manager attached its event handlers on the shard
|
||||
|
|
@ -140,7 +140,7 @@ class WebSocketShard extends EventEmitter {
|
|||
* @type {?Set<string>}
|
||||
* @private
|
||||
*/
|
||||
Object.defineProperty(this, 'expectedGuilds', { value: undefined, writable: true });
|
||||
Object.defineProperty(this, 'expectedGuilds', { value: null, writable: true });
|
||||
|
||||
/**
|
||||
* The ready timeout
|
||||
|
|
@ -148,7 +148,7 @@ class WebSocketShard extends EventEmitter {
|
|||
* @type {?NodeJS.Timeout}
|
||||
* @private
|
||||
*/
|
||||
Object.defineProperty(this, 'readyTimeout', { value: undefined, writable: true });
|
||||
Object.defineProperty(this, 'readyTimeout', { value: null, writable: true });
|
||||
|
||||
/**
|
||||
* Time when the WebSocket connection was opened
|
||||
|
|
@ -428,7 +428,7 @@ class WebSocketShard extends EventEmitter {
|
|||
// Reset the sequence
|
||||
this.sequence = -1;
|
||||
// Reset the session ID as it's invalid
|
||||
this.sessionID = undefined;
|
||||
this.sessionID = null;
|
||||
// Set the status to reconnecting
|
||||
this.status = Status.RECONNECTING;
|
||||
// Finally, emit the INVALID_SESSION event
|
||||
|
|
@ -457,7 +457,7 @@ class WebSocketShard extends EventEmitter {
|
|||
// Step 0. Clear the ready timeout, if it exists
|
||||
if (this.readyTimeout) {
|
||||
this.manager.client.clearTimeout(this.readyTimeout);
|
||||
this.readyTimeout = undefined;
|
||||
this.readyTimeout = null;
|
||||
}
|
||||
// Step 1. If we don't have any other guilds pending, we are ready
|
||||
if (!this.expectedGuilds.size) {
|
||||
|
|
@ -480,7 +480,7 @@ class WebSocketShard extends EventEmitter {
|
|||
this.debug(`Shard did not receive any more guild packets in 15 seconds.
|
||||
Unavailable guild count: ${this.expectedGuilds.size}`);
|
||||
|
||||
this.readyTimeout = undefined;
|
||||
this.readyTimeout = null;
|
||||
|
||||
this.status = Status.READY;
|
||||
|
||||
|
|
@ -498,7 +498,7 @@ class WebSocketShard extends EventEmitter {
|
|||
if (this.helloTimeout) {
|
||||
this.debug('Clearing the HELLO timeout.');
|
||||
this.manager.client.clearTimeout(this.helloTimeout);
|
||||
this.helloTimeout = undefined;
|
||||
this.helloTimeout = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -519,7 +519,7 @@ class WebSocketShard extends EventEmitter {
|
|||
if (this.heartbeatInterval) {
|
||||
this.debug('Clearing the heartbeat interval.');
|
||||
this.manager.client.clearInterval(this.heartbeatInterval);
|
||||
this.heartbeatInterval = undefined;
|
||||
this.heartbeatInterval = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -734,7 +734,7 @@ class WebSocketShard extends EventEmitter {
|
|||
// Step 5: Reset the sequence and session ID if requested
|
||||
if (reset) {
|
||||
this.sequence = -1;
|
||||
this.sessionID = undefined;
|
||||
this.sessionID = null;
|
||||
}
|
||||
|
||||
// Step 6: reset the ratelimit data
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ const GuildEmoji = require('../structures/GuildEmoji');
|
|||
const ReactionEmoji = require('../structures/ReactionEmoji');
|
||||
const Collection = require('../util/Collection');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
const { parseEmoji } = require('../util/Util');
|
||||
|
||||
/**
|
||||
* Manages API methods for GuildEmojis and stores their cache.
|
||||
|
|
@ -105,6 +106,7 @@ class GuildEmojiManager extends BaseManager {
|
|||
/**
|
||||
* Data that can be resolved to give an emoji identifier. This can be:
|
||||
* * The unicode representation of an emoji
|
||||
* * The `<a:name:id>`, `<:name:id>`, `:name:id` or `a:name:id` emoji identifier string of an emoji
|
||||
* * An EmojiResolvable
|
||||
* @typedef {string|EmojiResolvable} EmojiIdentifierResolvable
|
||||
*/
|
||||
|
|
@ -119,6 +121,10 @@ class GuildEmojiManager extends BaseManager {
|
|||
if (emojiResolvable) return emojiResolvable.identifier;
|
||||
if (emoji instanceof ReactionEmoji) return emoji.identifier;
|
||||
if (typeof emoji === 'string') {
|
||||
const res = parseEmoji(emoji);
|
||||
if (res && res.name.length) {
|
||||
emoji = `${res.animated ? 'a:' : ''}${res.name}${res.id ? `:${res.id}` : ''}`;
|
||||
}
|
||||
if (!emoji.includes('%')) return encodeURIComponent(emoji);
|
||||
else return emoji;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ const { Error, TypeError, RangeError } = require('../errors');
|
|||
const GuildMember = require('../structures/GuildMember');
|
||||
const Collection = require('../util/Collection');
|
||||
const { Events, OPCodes } = require('../util/Constants');
|
||||
const SnowflakeUtil = require('../util/Snowflake');
|
||||
|
||||
/**
|
||||
* Manages API methods for GuildMembers and stores their cache.
|
||||
|
|
@ -161,19 +162,22 @@ class GuildMemberManager extends BaseManager {
|
|||
* .then(pruned => console.log(`I just pruned ${pruned} people!`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
prune({ days = 7, dry = false, count = true, roles = [], reason } = {}) {
|
||||
prune({ days = 7, dry = false, count: compute_prune_count = true, roles = [], reason } = {}) {
|
||||
if (typeof days !== 'number') throw new TypeError('PRUNE_DAYS_TYPE');
|
||||
|
||||
const query = new URLSearchParams();
|
||||
query.set('days', days);
|
||||
query.set('compute_prune_count', count);
|
||||
const query = { days };
|
||||
const resolvedRoles = [];
|
||||
|
||||
for (const role of roles) {
|
||||
const resolvedRole = this.guild.roles.resolveID(role);
|
||||
if (!resolvedRole) {
|
||||
return Promise.reject(new TypeError('INVALID_TYPE', 'roles', 'Array of Roles or Snowflakes', true));
|
||||
}
|
||||
query.append('include_roles', role);
|
||||
resolvedRoles.push(resolvedRole);
|
||||
}
|
||||
|
||||
if (resolvedRoles.length) {
|
||||
query.include_roles = dry ? resolvedRoles.join(',') : resolvedRoles;
|
||||
}
|
||||
|
||||
const endpoint = this.client.api.guilds(this.guild.id).prune;
|
||||
|
|
@ -182,13 +186,12 @@ class GuildMemberManager extends BaseManager {
|
|||
return endpoint.get({ query, reason }).then(data => data.pruned);
|
||||
}
|
||||
|
||||
const body = [...query.entries()].reduce((acc, [k, v]) => {
|
||||
if (k === 'include_roles') v = (acc[k] || []).concat(v);
|
||||
acc[k] = v;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return endpoint.post({ data: body, reason }).then(data => data.pruned);
|
||||
return endpoint
|
||||
.post({
|
||||
data: { ...query, compute_prune_count },
|
||||
reason,
|
||||
})
|
||||
.then(data => data.pruned);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -263,7 +266,7 @@ class GuildMemberManager extends BaseManager {
|
|||
user: user_ids,
|
||||
query,
|
||||
time = 120e3,
|
||||
nonce = Date.now().toString(16),
|
||||
nonce = SnowflakeUtil.generate(),
|
||||
force = false,
|
||||
} = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class Shard extends EventEmitter {
|
|||
|
||||
/**
|
||||
* Arguments for the shard's process executable (only when {@link ShardingManager#mode} is `process`)
|
||||
* @type {?string[]}
|
||||
* @type {string[]}
|
||||
*/
|
||||
this.execArgv = manager.execArgv;
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class ShardClientUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Evaluates a script or function on all shards, in the context of the {@link Clients}.
|
||||
* Evaluates a script or function on all shards, in the context of the {@link Client}s.
|
||||
* @param {string|Function} script JavaScript to run on each shard
|
||||
* @returns {Promise<Array<*>>} Results of the script execution
|
||||
* @example
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ const Util = require('../util/Util');
|
|||
|
||||
/**
|
||||
* Represents a data model that is identifiable by a Snowflake (i.e. Discord API data models).
|
||||
* @abstract
|
||||
*/
|
||||
class Base {
|
||||
constructor(client) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ const Emoji = require('./Emoji');
|
|||
/**
|
||||
* Parent class for {@link GuildEmoji} and {@link GuildPreviewEmoji}.
|
||||
* @extends {Emoji}
|
||||
* @abstract
|
||||
*/
|
||||
class BaseGuildEmoji extends Emoji {
|
||||
constructor(client, data, guild) {
|
||||
|
|
@ -16,6 +17,10 @@ class BaseGuildEmoji extends Emoji {
|
|||
*/
|
||||
this.guild = guild;
|
||||
|
||||
this.requireColons = null;
|
||||
this.managed = null;
|
||||
this.available = null;
|
||||
|
||||
/**
|
||||
* Array of role ids this emoji is active for
|
||||
* @name BaseGuildEmoji#_roles
|
||||
|
|
@ -30,26 +35,29 @@ class BaseGuildEmoji extends Emoji {
|
|||
_patch(data) {
|
||||
if (data.name) this.name = data.name;
|
||||
|
||||
/**
|
||||
* Whether or not this emoji requires colons surrounding it
|
||||
* @type {?boolean}
|
||||
* @name GuildEmoji#requiresColons
|
||||
*/
|
||||
if (typeof data.require_colons !== 'undefined') this.requiresColons = data.require_colons;
|
||||
if (typeof data.require_colons !== 'undefined') {
|
||||
/**
|
||||
* Whether or not this emoji requires colons surrounding it
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.requiresColons = data.require_colons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this emoji is managed by an external service
|
||||
* @type {?boolean}
|
||||
* @name GuildEmoji#managed
|
||||
*/
|
||||
if (typeof data.managed !== 'undefined') this.managed = data.managed;
|
||||
if (typeof data.managed !== 'undefined') {
|
||||
/**
|
||||
* Whether this emoji is managed by an external service
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.managed = data.managed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this emoji is available
|
||||
* @type {?boolean}
|
||||
* @name GuildEmoji#available
|
||||
*/
|
||||
if (typeof data.available !== 'undefined') this.available = data.available;
|
||||
if (typeof data.available !== 'undefined') {
|
||||
/**
|
||||
* Whether this emoji is available
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.available = data.available;
|
||||
}
|
||||
|
||||
if (data.roles) this._roles = data.roles;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ const Snowflake = require('../util/Snowflake');
|
|||
/**
|
||||
* Represents any channel on Discord.
|
||||
* @extends {Base}
|
||||
* @abstract
|
||||
*/
|
||||
class Channel extends Base {
|
||||
constructor(client, data) {
|
||||
|
|
|
|||
|
|
@ -94,11 +94,9 @@ class ClientUser extends Structures.get('User') {
|
|||
* @property {PresenceStatusData} [status] Status of the user
|
||||
* @property {boolean} [afk] Whether the user is AFK
|
||||
* @property {Object} [activity] Activity the user is playing
|
||||
* @property {Object|string} [activity.application] An application object or application id
|
||||
* @property {string} [activity.application.id] The id of the application
|
||||
* @property {string} [activity.name] Name of the activity
|
||||
* @property {ActivityType|number} [activity.type] Type of the activity
|
||||
* @property {string} [activity.url] Stream url
|
||||
* @property {string} [activity.url] Twitch / YouTube stream URL
|
||||
* @property {?number|number[]} [shardID] Shard Id(s) to have the activity set on
|
||||
*/
|
||||
|
||||
|
|
@ -141,10 +139,10 @@ class ClientUser extends Structures.get('User') {
|
|||
}
|
||||
|
||||
/**
|
||||
* Options for setting an activity
|
||||
* Options for setting an activity.
|
||||
* @typedef ActivityOptions
|
||||
* @type {Object}
|
||||
* @property {string} [url] Twitch stream URL
|
||||
* @property {string} [url] Twitch / YouTube stream URL
|
||||
* @property {ActivityType|number} [type] Type of the activity
|
||||
* @property {?number|number[]} [shardID] Shard Id(s) to have the activity set on
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -231,36 +231,38 @@ class Guild extends Base {
|
|||
*/
|
||||
this.premiumTier = data.premium_tier;
|
||||
|
||||
/**
|
||||
* The total number of boosts for this server
|
||||
* @type {?number}
|
||||
* @name Guild#premiumSubscriptionCount
|
||||
*/
|
||||
if (typeof data.premium_subscription_count !== 'undefined') {
|
||||
/**
|
||||
* The total number of boosts for this server
|
||||
* @type {?number}
|
||||
*/
|
||||
this.premiumSubscriptionCount = data.premium_subscription_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether widget images are enabled on this guild
|
||||
* @type {?boolean}
|
||||
* @name Guild#widgetEnabled
|
||||
*/
|
||||
if (typeof data.widget_enabled !== 'undefined') this.widgetEnabled = data.widget_enabled;
|
||||
if (typeof data.widget_enabled !== 'undefined') {
|
||||
/**
|
||||
* Whether widget images are enabled on this guild
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.widgetEnabled = data.widget_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* The widget channel ID, if enabled
|
||||
* @type {?string}
|
||||
* @name Guild#widgetChannelID
|
||||
*/
|
||||
if (typeof data.widget_channel_id !== 'undefined') this.widgetChannelID = data.widget_channel_id;
|
||||
if (typeof data.widget_channel_id !== 'undefined') {
|
||||
/**
|
||||
* The widget channel ID, if enabled
|
||||
* @type {?string}
|
||||
*/
|
||||
this.widgetChannelID = data.widget_channel_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The embed channel ID, if enabled
|
||||
* @type {?string}
|
||||
* @name Guild#embedChannelID
|
||||
* @deprecated
|
||||
*/
|
||||
if (typeof data.embed_channel_id !== 'undefined') this.embedChannelID = data.embed_channel_id;
|
||||
if (typeof data.embed_channel_id !== 'undefined') {
|
||||
/**
|
||||
* The embed channel ID, if enabled
|
||||
* @type {?string}
|
||||
* @deprecated
|
||||
*/
|
||||
this.embedChannelID = data.embed_channel_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The verification level of the guild
|
||||
|
|
@ -299,40 +301,47 @@ class Guild extends Base {
|
|||
*/
|
||||
this.systemChannelFlags = new SystemChannelFlags(data.system_channel_flags).freeze();
|
||||
|
||||
/**
|
||||
* The maximum amount of members the guild can have
|
||||
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
|
||||
* @type {?number}
|
||||
* @name Guild#maximumMembers
|
||||
*/
|
||||
if (typeof data.max_members !== 'undefined') this.maximumMembers = data.max_members || 250000;
|
||||
|
||||
/**
|
||||
* The maximum amount of presences the guild can have
|
||||
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
|
||||
* @type {?number}
|
||||
* @name Guild#maximumPresences
|
||||
*/
|
||||
if (typeof data.max_presences !== 'undefined') this.maximumPresences = data.max_presences || 25000;
|
||||
|
||||
/**
|
||||
* The approximate amount of members the guild has
|
||||
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
|
||||
* @type {?number}
|
||||
* @name Guild#approximateMemberCount
|
||||
*/
|
||||
if (typeof data.approximate_member_count !== 'undefined') {
|
||||
this.approximateMemberCount = data.approximate_member_count;
|
||||
if (typeof data.max_members !== 'undefined') {
|
||||
/**
|
||||
* The maximum amount of members the guild can have
|
||||
* @type {?number}
|
||||
*/
|
||||
this.maximumMembers = data.max_members;
|
||||
} else if (typeof this.maximumMembers === 'undefined') {
|
||||
this.maximumMembers = null;
|
||||
}
|
||||
|
||||
if (typeof data.max_presences !== 'undefined') {
|
||||
/**
|
||||
* The maximum amount of presences the guild can have
|
||||
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
|
||||
* @type {?number}
|
||||
*/
|
||||
this.maximumPresences = data.max_presences || 25000;
|
||||
} else if (typeof this.maximumPresences === 'undefined') {
|
||||
this.maximumPresences = null;
|
||||
}
|
||||
|
||||
if (typeof data.approximate_member_count !== 'undefined') {
|
||||
/**
|
||||
* The approximate amount of members the guild has
|
||||
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
|
||||
* @type {?number}
|
||||
*/
|
||||
this.approximateMemberCount = data.approximate_member_count;
|
||||
} else if (typeof this.approximateMemberCount === 'undefined') {
|
||||
this.approximateMemberCount = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The approximate amount of presences the guild has
|
||||
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
|
||||
* @type {?number}
|
||||
* @name Guild#approximatePresenceCount
|
||||
*/
|
||||
if (typeof data.approximate_presence_count !== 'undefined') {
|
||||
/**
|
||||
* The approximate amount of presences the guild has
|
||||
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
|
||||
* @type {?number}
|
||||
*/
|
||||
this.approximatePresenceCount = data.approximate_presence_count;
|
||||
} else if (typeof this.approximatePresenceCount === 'undefined') {
|
||||
this.approximatePresenceCount = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ const Util = require('../util/Util');
|
|||
/**
|
||||
* Key mirror of all available audit log targets.
|
||||
* @name GuildAuditLogs.Targets
|
||||
* @type {AuditLogTargetType}
|
||||
* @type {Object<string, string>}
|
||||
*/
|
||||
const Targets = {
|
||||
ALL: 'ALL',
|
||||
|
|
@ -84,7 +84,7 @@ const Targets = {
|
|||
/**
|
||||
* All available actions keyed under their names to their numeric values.
|
||||
* @name GuildAuditLogs.Actions
|
||||
* @type {AuditLogAction}
|
||||
* @type {Object<string, number>}
|
||||
*/
|
||||
const Actions = {
|
||||
ALL: null,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ const Util = require('../util/Util');
|
|||
* - {@link NewsChannel}
|
||||
* - {@link StoreChannel}
|
||||
* @extends {Channel}
|
||||
* @abstract
|
||||
*/
|
||||
class GuildChannel extends Channel {
|
||||
/**
|
||||
|
|
@ -52,7 +53,7 @@ class GuildChannel extends Channel {
|
|||
* The ID of the category parent of this channel
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.parentID = data.parent_id;
|
||||
this.parentID = data.parent_id || null;
|
||||
|
||||
/**
|
||||
* A map of permission overwrites in this channel for roles and users
|
||||
|
|
@ -298,7 +299,7 @@ class GuildChannel extends Channel {
|
|||
* @property {boolean} [nsfw] Whether the channel is NSFW
|
||||
* @property {number} [bitrate] The bitrate of the voice channel
|
||||
* @property {number} [userLimit] The user limit of the voice channel
|
||||
* @property {Snowflake} [parentID] The parent ID of the channel
|
||||
* @property {?Snowflake} [parentID] The parent ID of the channel
|
||||
* @property {boolean} [lockPermissions]
|
||||
* Lock the permissions of the channel to what the parent's permissions are
|
||||
* @property {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} [permissionOverwrites]
|
||||
|
|
@ -412,7 +413,7 @@ class GuildChannel extends Channel {
|
|||
|
||||
/**
|
||||
* Sets a new topic for the guild channel.
|
||||
* @param {string} topic The new topic for the guild channel
|
||||
* @param {?string} topic The new topic for the guild channel
|
||||
* @param {string} [reason] Reason for changing the guild channel's topic
|
||||
* @returns {Promise<GuildChannel>}
|
||||
* @example
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ class GuildMember extends Base {
|
|||
/**
|
||||
* The nickname of this member, if they have one
|
||||
* @type {?string}
|
||||
* @name GuildMember#nickname
|
||||
*/
|
||||
this.nickname = null;
|
||||
|
||||
|
|
@ -74,7 +73,6 @@ class GuildMember extends Base {
|
|||
/**
|
||||
* The user that this guild member instance represents
|
||||
* @type {User}
|
||||
* @name GuildMember#user
|
||||
*/
|
||||
this.user = this.client.users.add(data.user, true);
|
||||
}
|
||||
|
|
@ -269,7 +267,8 @@ class GuildMember extends Base {
|
|||
*/
|
||||
hasPermission(permission, { checkAdmin = true, checkOwner = true } = {}) {
|
||||
if (checkOwner && this.user.id === this.guild.ownerID) return true;
|
||||
return this.roles.cache.some(r => r.permissions.has(permission, checkAdmin));
|
||||
const permissions = new Permissions(this.roles.cache.map(role => role.permissions));
|
||||
return permissions.has(permission, checkAdmin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class GuildPreview extends Base {
|
|||
* The description for this guild
|
||||
* @type {?string}
|
||||
*/
|
||||
this.description = data.description;
|
||||
this.description = data.description || null;
|
||||
|
||||
if (!this.emojis) {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ class Integration extends Base {
|
|||
* @type {?User}
|
||||
*/
|
||||
this.user = this.client.users.add(data.user);
|
||||
} else {
|
||||
this.user = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -239,13 +239,18 @@ class Message extends Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates the message.
|
||||
* Updates the message and returns the old message.
|
||||
* @param {Object} data Raw Discord message update data
|
||||
* @returns {Message}
|
||||
* @private
|
||||
*/
|
||||
patch(data) {
|
||||
const clone = this._clone();
|
||||
this._edits.unshift(clone);
|
||||
const { messageEditHistoryMaxSize } = this.client.options;
|
||||
if (messageEditHistoryMaxSize !== 0) {
|
||||
const editsLimit = messageEditHistoryMaxSize === -1 ? Infinity : messageEditHistoryMaxSize;
|
||||
if (this._edits.unshift(clone) > editsLimit) this._edits.pop();
|
||||
}
|
||||
|
||||
if ('edited_timestamp' in data) this.editedTimestamp = new Date(data.edited_timestamp).getTime();
|
||||
if ('content' in data) this.content = data.content;
|
||||
|
|
@ -272,6 +277,8 @@ class Message extends Base {
|
|||
);
|
||||
|
||||
this.flags = new MessageFlags('flags' in data ? data.flags : 0).freeze();
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -434,6 +441,23 @@ class Message extends Base {
|
|||
return referenceChannel.messages.resolve(this.reference.messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the message is crosspostable by the client user
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get crosspostable() {
|
||||
return (
|
||||
this.channel.type === 'news' &&
|
||||
!this.flags.has(MessageFlags.FLAGS.CROSSPOSTED) &&
|
||||
this.type === 'DEFAULT' &&
|
||||
this.channel.viewable &&
|
||||
this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.SEND_MESSAGES) &&
|
||||
(this.author.id === this.client.user.id ||
|
||||
this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_MESSAGES))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Options that can be passed into editMessage.
|
||||
* @typedef {Object} MessageEditOptions
|
||||
|
|
|
|||
|
|
@ -29,37 +29,37 @@ class MessageEmbed {
|
|||
* * `link` - a link embed
|
||||
* @type {string}
|
||||
*/
|
||||
this.type = data.type;
|
||||
this.type = data.type || 'rich';
|
||||
|
||||
/**
|
||||
* The title of this embed
|
||||
* @type {?string}
|
||||
*/
|
||||
this.title = data.title;
|
||||
this.title = 'title' in data ? data.title : null;
|
||||
|
||||
/**
|
||||
* The description of this embed
|
||||
* @type {?string}
|
||||
*/
|
||||
this.description = data.description;
|
||||
this.description = 'description' in data ? data.description : null;
|
||||
|
||||
/**
|
||||
* The URL of this embed
|
||||
* @type {?string}
|
||||
*/
|
||||
this.url = data.url;
|
||||
this.url = 'url' in data ? data.url : null;
|
||||
|
||||
/**
|
||||
* The color of this embed
|
||||
* @type {?number}
|
||||
*/
|
||||
this.color = Util.resolveColor(data.color);
|
||||
this.color = 'color' in data ? Util.resolveColor(data.color) : null;
|
||||
|
||||
/**
|
||||
* The timestamp of this embed
|
||||
* @type {?number}
|
||||
*/
|
||||
this.timestamp = data.timestamp ? new Date(data.timestamp).getTime() : null;
|
||||
this.timestamp = 'timestamp' in data ? new Date(data.timestamp).getTime() : null;
|
||||
|
||||
/**
|
||||
* Represents a field of a MessageEmbed
|
||||
|
|
@ -331,7 +331,7 @@ class MessageEmbed {
|
|||
*/
|
||||
setFooter(text, iconURL) {
|
||||
text = Util.resolveString(text);
|
||||
this.footer = { text, iconURL, proxyIconURL: undefined };
|
||||
this.footer = { text, iconURL };
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,13 +46,14 @@ class MessageReaction {
|
|||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* The number of people that have given the same reaction
|
||||
* @type {?number}
|
||||
* @name MessageReaction#count
|
||||
*/
|
||||
// eslint-disable-next-line eqeqeq
|
||||
if (this.count == undefined) this.count = data.count;
|
||||
if (this.count == undefined) {
|
||||
/**
|
||||
* The number of people that have given the same reaction
|
||||
* @type {?number}
|
||||
*/
|
||||
this.count = data.count;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -184,8 +184,8 @@ class Activity {
|
|||
/**
|
||||
* Timestamps for the activity
|
||||
* @type {?Object}
|
||||
* @prop {?Date} start When the activity started
|
||||
* @prop {?Date} end When the activity will end
|
||||
* @property {?Date} start When the activity started
|
||||
* @property {?Date} end When the activity will end
|
||||
*/
|
||||
this.timestamps = data.timestamps
|
||||
? {
|
||||
|
|
@ -197,8 +197,8 @@ class Activity {
|
|||
/**
|
||||
* Party of the activity
|
||||
* @type {?Object}
|
||||
* @prop {?string} id ID of the party
|
||||
* @prop {number[]} size Size of the party as `[current, max]`
|
||||
* @property {?string} id ID of the party
|
||||
* @property {number[]} size Size of the party as `[current, max]`
|
||||
*/
|
||||
this.party = data.party || null;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ class User extends Base {
|
|||
*/
|
||||
this.id = data.id;
|
||||
|
||||
this.system = null;
|
||||
this.locale = null;
|
||||
this.flags = null;
|
||||
|
||||
this._patch(data);
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +39,6 @@ class User extends Base {
|
|||
/**
|
||||
* The username of the user
|
||||
* @type {?string}
|
||||
* @name User#username
|
||||
*/
|
||||
this.username = data.username;
|
||||
} else if (typeof this.username !== 'string') {
|
||||
|
|
@ -45,7 +48,6 @@ class User extends Base {
|
|||
/**
|
||||
* Whether or not the user is a bot
|
||||
* @type {boolean}
|
||||
* @name User#bot
|
||||
*/
|
||||
this.bot = Boolean(data.bot);
|
||||
|
||||
|
|
@ -53,7 +55,6 @@ class User extends Base {
|
|||
/**
|
||||
* A discriminator based on username for the user
|
||||
* @type {?string}
|
||||
* @name User#discriminator
|
||||
*/
|
||||
this.discriminator = data.discriminator;
|
||||
} else if (typeof this.discriminator !== 'string') {
|
||||
|
|
@ -64,7 +65,6 @@ class User extends Base {
|
|||
/**
|
||||
* The ID of the user's avatar
|
||||
* @type {?string}
|
||||
* @name User#avatar
|
||||
*/
|
||||
this.avatar = data.avatar;
|
||||
} else if (typeof this.avatar !== 'string') {
|
||||
|
|
@ -75,7 +75,6 @@ class User extends Base {
|
|||
/**
|
||||
* Whether the user is an Official Discord System user (part of the urgent message system)
|
||||
* @type {?boolean}
|
||||
* @name User#system
|
||||
*/
|
||||
this.system = Boolean(data.system);
|
||||
}
|
||||
|
|
@ -84,7 +83,6 @@ class User extends Base {
|
|||
/**
|
||||
* The locale of the user's client (ISO 639-1)
|
||||
* @type {?string}
|
||||
* @name User#locale
|
||||
*/
|
||||
this.locale = data.locale;
|
||||
}
|
||||
|
|
@ -93,7 +91,6 @@ class User extends Base {
|
|||
/**
|
||||
* The flags for this user
|
||||
* @type {?UserFlags}
|
||||
* @name User#flags
|
||||
*/
|
||||
this.flags = new UserFlags(data.public_flags);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ class VoiceChannel extends GuildChannel {
|
|||
/**
|
||||
* The members in this voice channel
|
||||
* @type {Collection<Snowflake, GuildMember>}
|
||||
* @name VoiceChannel#members
|
||||
* @readonly
|
||||
*/
|
||||
get members() {
|
||||
|
|
|
|||
|
|
@ -32,32 +32,32 @@ class VoiceState extends Base {
|
|||
* Whether this member is deafened server-wide
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.serverDeaf = data.deaf;
|
||||
this.serverDeaf = 'deaf' in data ? data.deaf : null;
|
||||
/**
|
||||
* Whether this member is muted server-wide
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.serverMute = data.mute;
|
||||
this.serverMute = 'mute' in data ? data.mute : null;
|
||||
/**
|
||||
* Whether this member is self-deafened
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.selfDeaf = data.self_deaf;
|
||||
this.selfDeaf = 'self_deaf' in data ? data.self_deaf : null;
|
||||
/**
|
||||
* Whether this member is self-muted
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.selfMute = data.self_mute;
|
||||
this.selfMute = 'self_mute' in data ? data.self_mute : null;
|
||||
/**
|
||||
* Whether this member's camera is enabled
|
||||
* @type {boolean}
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.selfVideo = data.self_video;
|
||||
this.selfVideo = 'self_video' in data ? data.self_video : null;
|
||||
/**
|
||||
* The session ID of this member's connection
|
||||
* @type {?string}
|
||||
*/
|
||||
this.sessionID = data.session_id;
|
||||
this.sessionID = 'session_id' in data ? data.session_id : null;
|
||||
/**
|
||||
* Whether this member is streaming using "Go Live"
|
||||
* @type {boolean}
|
||||
|
|
@ -67,7 +67,7 @@ class VoiceState extends Base {
|
|||
* The ID of the voice channel that this member is in
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.channelID = data.channel_id;
|
||||
this.channelID = data.channel_id || null;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ const browser = (exports.browser = typeof window !== 'undefined');
|
|||
* sweepable (in seconds, 0 for forever)
|
||||
* @property {number} [messageSweepInterval=0] How frequently to remove messages from the cache that are older than
|
||||
* the message cache lifetime (in seconds, 0 for never)
|
||||
* @property {number} [messageEditHistoryMaxSize=-1] Maximum number of previous versions to hold for an edited message
|
||||
* (-1 or Infinity for unlimited - don't do this without sweeping, otherwise memory usage may climb indefinitely.)
|
||||
* @property {boolean} [fetchAllMembers=false] Whether to cache all guild members and users upon startup, as well as
|
||||
* upon joining a guild (should be avoided whenever possible)
|
||||
* @property {DisableMentionType} [disableMentions='none'] Default value for {@link MessageOptions#disableMentions}
|
||||
|
|
@ -43,6 +45,7 @@ exports.DefaultOptions = {
|
|||
messageCacheMaxSize: 200,
|
||||
messageCacheLifetime: 0,
|
||||
messageSweepInterval: 0,
|
||||
messageEditHistoryMaxSize: -1,
|
||||
fetchAllMembers: false,
|
||||
disableMentions: 'none',
|
||||
partials: [],
|
||||
|
|
|
|||
77
typings/index.d.ts
vendored
77
typings/index.d.ts
vendored
|
|
@ -29,6 +29,7 @@ declare module 'discord.js' {
|
|||
public createdTimestamp: number;
|
||||
public details: string | null;
|
||||
public emoji: Emoji | null;
|
||||
public flags: Readonly<ActivityFlags>;
|
||||
public name: string;
|
||||
public party: {
|
||||
id: string | null;
|
||||
|
|
@ -141,13 +142,13 @@ declare module 'discord.js' {
|
|||
constructor(client: Client, data: object, guild: Guild);
|
||||
private _roles: string[];
|
||||
|
||||
public available?: boolean;
|
||||
public available: boolean | null;
|
||||
public readonly createdAt: Date;
|
||||
public readonly createdTimestamp: number;
|
||||
public guild: Guild | GuildPreview;
|
||||
public id: Snowflake;
|
||||
public managed?: boolean;
|
||||
public requiresColons?: boolean;
|
||||
public managed: boolean | null;
|
||||
public requiresColons: boolean | null;
|
||||
}
|
||||
|
||||
class BroadcastDispatcher extends VolumeMixin(StreamDispatcher) {
|
||||
|
|
@ -624,8 +625,8 @@ declare module 'discord.js' {
|
|||
public afkChannelID: Snowflake | null;
|
||||
public afkTimeout: number;
|
||||
public applicationID: Snowflake | null;
|
||||
public approximateMemberCount?: number;
|
||||
public approximatePresenceCount?: number;
|
||||
public approximateMemberCount: number | null;
|
||||
public approximatePresenceCount: number | null;
|
||||
public available: boolean;
|
||||
public banner: string | null;
|
||||
public channels: GuildChannelManager;
|
||||
|
|
@ -817,11 +818,11 @@ declare module 'discord.js' {
|
|||
public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null;
|
||||
public setName(name: string, reason?: string): Promise<this>;
|
||||
public setParent(
|
||||
channel: CategoryChannel | Snowflake,
|
||||
channel: CategoryChannel | Snowflake | null,
|
||||
options?: { lockPermissions?: boolean; reason?: string },
|
||||
): Promise<this>;
|
||||
public setPosition(position: number, options?: { relative?: boolean; reason?: string }): Promise<this>;
|
||||
public setTopic(topic: string, reason?: string): Promise<this>;
|
||||
public setTopic(topic: string | null, reason?: string): Promise<this>;
|
||||
public updateOverwrite(
|
||||
userOrRole: RoleResolvable | UserResolvable,
|
||||
options: PermissionOverwriteOption,
|
||||
|
|
@ -887,7 +888,7 @@ declare module 'discord.js' {
|
|||
constructor(client: Client, data: object);
|
||||
public approximateMemberCount: number;
|
||||
public approximatePresenceCount: number;
|
||||
public description?: string;
|
||||
public description: string | null;
|
||||
public discoverySplash: string | null;
|
||||
public emojis: Collection<Snowflake, GuildPreviewEmoji>;
|
||||
public features: GuildFeatures[];
|
||||
|
|
@ -931,7 +932,7 @@ declare module 'discord.js' {
|
|||
public syncedAt: number;
|
||||
public syncing: boolean;
|
||||
public type: string;
|
||||
public user?: User;
|
||||
public user: User | null;
|
||||
public delete(reason?: string): Promise<Integration>;
|
||||
public edit(data: IntegrationEditData, reason?: string): Promise<Integration>;
|
||||
public sync(): Promise<Integration>;
|
||||
|
|
@ -977,7 +978,7 @@ declare module 'discord.js' {
|
|||
export class Message extends Base {
|
||||
constructor(client: Client, data: object, channel: TextChannel | DMChannel | NewsChannel);
|
||||
private _edits: Message[];
|
||||
private patch(data: object): void;
|
||||
private patch(data: object): Message;
|
||||
|
||||
public activity: MessageActivity | null;
|
||||
public application: ClientApplication | null;
|
||||
|
|
@ -1054,7 +1055,7 @@ declare module 'discord.js' {
|
|||
public attachment: BufferResolvable | Stream;
|
||||
public height: number | null;
|
||||
public id: Snowflake;
|
||||
public name?: string;
|
||||
public name: string | null;
|
||||
public proxyURL: string;
|
||||
public size: number;
|
||||
public readonly spoiler: boolean;
|
||||
|
|
@ -1082,9 +1083,9 @@ declare module 'discord.js' {
|
|||
export class MessageEmbed {
|
||||
constructor(data?: MessageEmbed | MessageEmbedOptions);
|
||||
public author: MessageEmbedAuthor | null;
|
||||
public color?: number;
|
||||
public color: number | null;
|
||||
public readonly createdAt: Date | null;
|
||||
public description?: string;
|
||||
public description: string | null;
|
||||
public fields: EmbedField[];
|
||||
public files: (MessageAttachment | string | FileOptions)[];
|
||||
public footer: MessageEmbedFooter | null;
|
||||
|
|
@ -1094,9 +1095,9 @@ declare module 'discord.js' {
|
|||
public provider: MessageEmbedProvider | null;
|
||||
public thumbnail: MessageEmbedThumbnail | null;
|
||||
public timestamp: number | null;
|
||||
public title?: string;
|
||||
public title: string | null;
|
||||
public type: string;
|
||||
public url?: string;
|
||||
public url: string | null;
|
||||
public readonly video: MessageEmbedVideo | null;
|
||||
public addField(name: StringResolvable, value: StringResolvable, inline?: boolean): this;
|
||||
public addFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this;
|
||||
|
|
@ -1232,7 +1233,6 @@ declare module 'discord.js' {
|
|||
constructor(client: Client, data?: object);
|
||||
public activities: Activity[];
|
||||
public clientStatus: ClientPresenceStatusData | null;
|
||||
public flags: Readonly<ActivityFlags>;
|
||||
public guild: Guild | null;
|
||||
public readonly member: GuildMember | null;
|
||||
public status: PresenceStatus;
|
||||
|
|
@ -1541,13 +1541,13 @@ declare module 'discord.js' {
|
|||
public discriminator: string;
|
||||
public readonly defaultAvatarURL: string;
|
||||
public readonly dmChannel: DMChannel | null;
|
||||
public flags?: Readonly<UserFlags>;
|
||||
public flags: Readonly<UserFlags> | null;
|
||||
public id: Snowflake;
|
||||
public lastMessageID: Snowflake | null;
|
||||
public locale?: string;
|
||||
public locale: string | null;
|
||||
public readonly partial: false;
|
||||
public readonly presence: Presence;
|
||||
public system?: boolean;
|
||||
public system: boolean | null;
|
||||
public readonly tag: string;
|
||||
public username: string;
|
||||
public avatarURL(options?: ImageURLOptions & { dynamic?: boolean }): string | null;
|
||||
|
|
@ -1614,7 +1614,7 @@ declare module 'discord.js' {
|
|||
constructor(client: Client);
|
||||
public client: Client;
|
||||
public subscribers: StreamDispatcher[];
|
||||
public readonly dispatcher?: BroadcastDispatcher;
|
||||
public readonly dispatcher: BroadcastDispatcher | null;
|
||||
public play(input: string | Readable, options?: StreamOptions): BroadcastDispatcher;
|
||||
public end(): void;
|
||||
|
||||
|
|
@ -1670,7 +1670,7 @@ declare module 'discord.js' {
|
|||
public receiver: VoiceReceiver;
|
||||
public speaking: Readonly<Speaking>;
|
||||
public status: VoiceStatus;
|
||||
public readonly voice: VoiceState;
|
||||
public readonly voice: VoiceState | null;
|
||||
public voiceManager: ClientVoiceManager;
|
||||
public disconnect(): void;
|
||||
public play(input: VoiceBroadcast | Readable | string, options?: StreamOptions): StreamDispatcher;
|
||||
|
|
@ -1722,18 +1722,18 @@ declare module 'discord.js' {
|
|||
export class VoiceState extends Base {
|
||||
constructor(guild: Guild, data: object);
|
||||
public readonly channel: VoiceChannel | null;
|
||||
public channelID?: Snowflake;
|
||||
public channelID: Snowflake | null;
|
||||
public readonly connection: VoiceConnection | null;
|
||||
public readonly deaf?: boolean;
|
||||
public readonly deaf: boolean | null;
|
||||
public guild: Guild;
|
||||
public id: Snowflake;
|
||||
public readonly member: GuildMember | null;
|
||||
public readonly mute?: boolean;
|
||||
public selfDeaf?: boolean;
|
||||
public selfMute?: boolean;
|
||||
public serverDeaf?: boolean;
|
||||
public serverMute?: boolean;
|
||||
public sessionID?: string;
|
||||
public readonly mute: boolean | null;
|
||||
public selfDeaf: boolean | null;
|
||||
public selfMute: boolean | null;
|
||||
public serverDeaf: boolean | null;
|
||||
public serverMute: boolean | null;
|
||||
public sessionID: string | null;
|
||||
public streaming: boolean;
|
||||
public selfVideo: boolean;
|
||||
public readonly speaking: boolean | null;
|
||||
|
|
@ -1787,10 +1787,10 @@ declare module 'discord.js' {
|
|||
private packetQueue: object[];
|
||||
private destroyed: boolean;
|
||||
private reconnecting: boolean;
|
||||
private sessionStartLimit?: { total: number; remaining: number; reset_after: number };
|
||||
private sessionStartLimit: { total: number; remaining: number; reset_after: number } | null;
|
||||
|
||||
public readonly client: Client;
|
||||
public gateway?: string;
|
||||
public gateway: string | null;
|
||||
public shards: Collection<number, WebSocketShard>;
|
||||
public status: Status;
|
||||
public readonly ping: number;
|
||||
|
|
@ -1814,15 +1814,15 @@ declare module 'discord.js' {
|
|||
constructor(manager: WebSocketManager, id: number);
|
||||
private sequence: number;
|
||||
private closeSequence: number;
|
||||
private sessionID?: string;
|
||||
private sessionID: string | null;
|
||||
private lastPingTimestamp: number;
|
||||
private lastHeartbeatAcked: boolean;
|
||||
private ratelimit: { queue: object[]; total: number; remaining: number; time: 60e3; timer: NodeJS.Timeout | null };
|
||||
private connection: WebSocket | null;
|
||||
private helloTimeout: NodeJS.Timeout | undefined;
|
||||
private helloTimeout: NodeJS.Timeout | null;
|
||||
private eventsAttached: boolean;
|
||||
private expectedGuilds: Set<Snowflake> | undefined;
|
||||
private readyTimeout: NodeJS.Timeout | undefined;
|
||||
private expectedGuilds: Set<Snowflake> | null;
|
||||
private readyTimeout: NodeJS.Timeout | null;
|
||||
|
||||
public manager: WebSocketManager;
|
||||
public id: number;
|
||||
|
|
@ -2072,7 +2072,7 @@ declare module 'discord.js' {
|
|||
interface TextBasedChannelFields extends PartialTextBasedChannelFields {
|
||||
_typing: Map<string, TypingData>;
|
||||
lastPinTimestamp: number | null;
|
||||
readonly lastPinAt: Date;
|
||||
readonly lastPinAt: Date | null;
|
||||
typing: boolean;
|
||||
typingCount: number;
|
||||
awaitMessages(filter: CollectorFilter, options?: AwaitMessagesOptions): Promise<Collection<Snowflake, Message>>;
|
||||
|
|
@ -2235,7 +2235,7 @@ declare module 'discord.js' {
|
|||
nsfw?: boolean;
|
||||
bitrate?: number;
|
||||
userLimit?: number;
|
||||
parentID?: Snowflake;
|
||||
parentID?: Snowflake | null;
|
||||
rateLimitPerUser?: number;
|
||||
lockPermissions?: boolean;
|
||||
permissionOverwrites?: readonly OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;
|
||||
|
|
@ -2318,6 +2318,7 @@ declare module 'discord.js' {
|
|||
messageCacheMaxSize?: number;
|
||||
messageCacheLifetime?: number;
|
||||
messageSweepInterval?: number;
|
||||
messageEditHistoryMaxSize?: number;
|
||||
fetchAllMembers?: boolean;
|
||||
disableMentions?: 'none' | 'all' | 'everyone';
|
||||
allowedMentions?: MessageMentionOptions;
|
||||
|
|
@ -3020,6 +3021,7 @@ declare module 'discord.js' {
|
|||
| 'attachments'
|
||||
| 'channel'
|
||||
| 'deletable'
|
||||
| 'crosspostable'
|
||||
| 'editable'
|
||||
| 'mentions'
|
||||
| 'pinnable'
|
||||
|
|
@ -3031,6 +3033,7 @@ declare module 'discord.js' {
|
|||
attachments: Message['attachments'];
|
||||
channel: Message['channel'];
|
||||
readonly deletable: boolean;
|
||||
readonly crosspostable: boolean;
|
||||
readonly editable: boolean;
|
||||
readonly edits: Message['edits'];
|
||||
embeds: Message['embeds'];
|
||||
|
|
|
|||
Loading…
Reference in a new issue