discord.js
Advanced tools
Comparing version 11.3.0 to 11.3.1
{ | ||
"name": "discord.js", | ||
"version": "11.3.0", | ||
"version": "11.3.1", | ||
"description": "A powerful library for interacting with the Discord API", | ||
@@ -17,3 +17,3 @@ "main": "./src/index", | ||
"type": "git", | ||
"url": "git+https://github.com/hydrabolt/discord.js.git" | ||
"url": "git+https://github.com/discordjs/discord.js.git" | ||
}, | ||
@@ -31,10 +31,10 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/hydrabolt/discord.js/issues" | ||
"url": "https://github.com/discordjs/discord.js/issues" | ||
}, | ||
"homepage": "https://github.com/hydrabolt/discord.js#readme", | ||
"homepage": "https://github.com/discordjs/discord.js#readme", | ||
"runkitExampleFilename": "./docs/examples/ping.js", | ||
"dependencies": { | ||
"long": "^3.2.0", | ||
"prism-media": "^0.0.1", | ||
"snekfetch": "^3.6.1", | ||
"long": "^4.0.0", | ||
"prism-media": "^0.0.2", | ||
"snekfetch": "^3.6.4", | ||
"tweetnacl": "^1.0.0", | ||
@@ -49,12 +49,12 @@ "ws": "^4.0.0" | ||
"sodium": "^2.0.3", | ||
"libsodium-wrappers": "^0.5.4", | ||
"libsodium-wrappers": "^0.7.3", | ||
"uws": "^9.14.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^8.5.7", | ||
"discord.js-docgen": "hydrabolt/discord.js-docgen", | ||
"eslint": "^4.15.0", | ||
"@types/node": "^9.4.6", | ||
"discord.js-docgen": "discordjs/docgen", | ||
"eslint": "^4.18.0", | ||
"parallel-webpack": "^2.2.0", | ||
"uglifyjs-webpack-plugin": "^1.1.6", | ||
"webpack": "^3.10.0" | ||
"uglifyjs-webpack-plugin": "^1.2.0", | ||
"webpack": "^3.11.0" | ||
}, | ||
@@ -61,0 +61,0 @@ "engines": { |
@@ -11,4 +11,4 @@ <div align="center"> | ||
<a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600" alt="NPM downloads" /></a> | ||
<a href="https://travis-ci.org/hydrabolt/discord.js"><img src="https://travis-ci.org/hydrabolt/discord.js.svg" alt="Build status" /></a> | ||
<a href="https://david-dm.org/hydrabolt/discord.js"><img src="https://img.shields.io/david/hydrabolt/discord.js.svg?maxAge=3600" alt="Dependencies" /></a> | ||
<a href="https://travis-ci.org/discordjs/discord.js"><img src="https://travis-ci.org/discordjs/discord.js.svg" alt="Build status" /></a> | ||
<a href="https://david-dm.org/discordjs/discord.js"><img src="https://img.shields.io/david/discordjs/discord.js.svg?maxAge=3600" alt="Dependencies" /></a> | ||
</p> | ||
@@ -33,5 +33,5 @@ <p> | ||
Without voice support: `npm install discord.js --save` | ||
With voice support ([node-opus](https://www.npmjs.com/package/node-opus)): `npm install discord.js node-opus --save` | ||
With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discord.js opusscript --save` | ||
Without voice support: `npm install discord.js` | ||
With voice support ([node-opus](https://www.npmjs.com/package/node-opus)): `npm install discord.js node-opus` | ||
With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discord.js opusscript` | ||
@@ -44,8 +44,8 @@ ### Audio engines | ||
### Optional packages | ||
- [bufferutil](https://www.npmjs.com/package/bufferutil) to greatly speed up the WebSocket when *not* using uws (`npm install bufferutil --save`) | ||
- [erlpack](https://github.com/hammerandchisel/erlpack) for significantly faster WebSocket data (de)serialisation (`npm install hammerandchisel/erlpack --save`) | ||
- [bufferutil](https://www.npmjs.com/package/bufferutil) to greatly speed up the WebSocket when *not* using uws (`npm install bufferutil`) | ||
- [erlpack](https://github.com/hammerandchisel/erlpack) for significantly faster WebSocket data (de)serialisation (`npm install hammerandchisel/erlpack`) | ||
- One of the following packages can be installed for faster voice packet encryption and decryption: | ||
- [sodium](https://www.npmjs.com/package/sodium) (`npm install sodium --save`) | ||
- [libsodium.js](https://www.npmjs.com/package/libsodium-wrappers) (`npm install libsodium-wrappers --save`) | ||
- [uws](https://www.npmjs.com/package/uws) for a much faster WebSocket connection (`npm install uws --save`) | ||
- [sodium](https://www.npmjs.com/package/sodium) (`npm install sodium`) | ||
- [libsodium.js](https://www.npmjs.com/package/libsodium-wrappers) (`npm install libsodium-wrappers`) | ||
- [uws](https://www.npmjs.com/package/uws) for a much faster WebSocket connection (`npm install uws`) | ||
@@ -58,27 +58,31 @@ ## Example usage | ||
client.on('ready', () => { | ||
console.log('I am ready!'); | ||
console.log(`Logged in as ${client.user.tag}!`); | ||
}); | ||
client.on('message', message => { | ||
if (message.content === 'ping') { | ||
message.reply('pong'); | ||
client.on('message', msg => { | ||
if (msg.content === 'ping') { | ||
msg.reply('pong'); | ||
} | ||
}); | ||
client.login('your token'); | ||
client.login('token'); | ||
``` | ||
## Links | ||
* [Website](https://discord.js.org/) ([source](https://github.com/hydrabolt/discord.js-site)) | ||
* [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website)) | ||
* [Documentation](https://discord.js.org/#/docs) | ||
* [Discord.js server](https://discord.gg/bRCvFy9) | ||
* [Discord API server](https://discord.gg/rV4BwdK) | ||
* [GitHub](https://github.com/hydrabolt/discord.js) | ||
* [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide)) | ||
* [Discord.js Discord server](https://discord.gg/bRCvFy9) | ||
* [Discord API Discord server](https://discord.gg/discord-api) | ||
* [GitHub](https://github.com/discordjs/discord.js) | ||
* [NPM](https://www.npmjs.com/package/discord.js) | ||
* [Related libraries](https://discordapi.com/unofficial/libs.html) (see also [discord-rpc](https://www.npmjs.com/package/discord-rpc)) | ||
* [Related libraries](https://discordapi.com/unofficial/libs.html) | ||
### Extensions | ||
* [RPC](https://www.npmjs.com/package/discord-rpc) ([source](https://github.com/discordjs/RPC)) | ||
## Contributing | ||
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the | ||
[documentation](https://discord.js.org/#/docs). | ||
See [the contribution guide](https://github.com/hydrabolt/discord.js/blob/master/.github/CONTRIBUTING.md) if you'd like to submit a PR. | ||
See [the contribution guide](https://github.com/discordjs/discord.js/blob/master/.github/CONTRIBUTING.md) if you'd like to submit a PR. | ||
@@ -85,0 +89,0 @@ ## Help |
@@ -31,2 +31,5 @@ const Action = require('./Action'); | ||
for (const channel of guild.channels.values()) this.client.channels.delete(channel.id); | ||
if (guild.voiceConnection) guild.voiceConnection.disconnect(); | ||
// Delete guild | ||
@@ -33,0 +36,0 @@ client.guilds.delete(guild.id); |
@@ -7,13 +7,17 @@ const Action = require('./Action'); | ||
handle(data) { | ||
const client = this.client; | ||
const channel = client.channels.get(data.channel_id); | ||
const messages = new Collection(); | ||
const ids = data.ids; | ||
const messages = new Collection(); | ||
for (const id of ids) { | ||
const message = channel.messages.get(id); | ||
if (message) messages.set(message.id, message); | ||
if (!data.messages) { | ||
const channel = this.client.channels.get(data.channel_id); | ||
for (const id of data.ids) { | ||
const message = channel.messages.get(id); | ||
if (message) messages.set(message.id, message); | ||
} | ||
} else { | ||
for (const msg of data.messages) { | ||
messages.set(msg.id, msg); | ||
} | ||
} | ||
if (messages.size > 0) client.emit(Constants.Events.MESSAGE_BULK_DELETE, messages); | ||
if (messages.size > 0) this.client.emit(Constants.Events.MESSAGE_BULK_DELETE, messages); | ||
return { messages }; | ||
@@ -20,0 +24,0 @@ } |
@@ -197,3 +197,3 @@ const EventEmitter = require('events'); | ||
/** | ||
* How long it has been since the client last entered the `READY` state | ||
* How long it has been since the client last entered the `READY` state in milliseconds | ||
* @type {?number} | ||
@@ -216,3 +216,3 @@ * @readonly | ||
/** | ||
* All active voice connections that have been established, mapped by channel ID | ||
* All active voice connections that have been established, mapped by guild ID | ||
* @type {Collection<Snowflake, VoiceConnection>} | ||
@@ -219,0 +219,0 @@ * @readonly |
@@ -354,2 +354,3 @@ const path = require('path'); | ||
if (color === 'RANDOM') return Math.floor(Math.random() * (0xFFFFFF + 1)); | ||
if (color === 'DEFAULT') return 0; | ||
color = Constants.Colors[color] || parseInt(color.replace('#', ''), 16); | ||
@@ -356,0 +357,0 @@ } else if (color instanceof Array) { |
@@ -19,4 +19,4 @@ const UserAgentManager = require('./UserAgentManager'); | ||
destroy() { | ||
for (const handlerID in this.handlers) { | ||
this.handlers[handlerID].destroy(); | ||
for (const handler of Object.values(this.handlers)) { | ||
if (handler.destroy) handler.destroy(); | ||
} | ||
@@ -23,0 +23,0 @@ } |
@@ -7,3 +7,2 @@ const querystring = require('querystring'); | ||
const Collection = require('../../util/Collection'); | ||
const Snowflake = require('../../util/Snowflake'); | ||
const Util = require('../../util/Util'); | ||
@@ -176,14 +175,9 @@ | ||
bulkDeleteMessages(channel, messages, filterOld) { | ||
if (filterOld) { | ||
messages = messages.filter(id => | ||
Date.now() - Snowflake.deconstruct(id).date.getTime() < 1209600000 | ||
); | ||
} | ||
bulkDeleteMessages(channel, messages) { | ||
return this.rest.makeRequest('post', Endpoints.Channel(channel).messages.bulkDelete, true, { | ||
messages, | ||
messages: messages.map(m => m.id), | ||
}).then(() => | ||
this.client.actions.MessageDeleteBulk.handle({ | ||
channel_id: channel.id, | ||
ids: messages, | ||
messages, | ||
}).messages | ||
@@ -265,3 +259,3 @@ ); | ||
const role = this.client.resolver.resolveRole(this, overwrite.id); | ||
const role = this.client.resolver.resolveRole(guild, overwrite.id); | ||
if (role) { | ||
@@ -348,3 +342,3 @@ overwrite.id = role.id; | ||
data.bitrate = _data.bitrate || (channel.bitrate ? channel.bitrate * 1000 : undefined); | ||
data.user_limit = _data.userLimit || channel.userLimit; | ||
data.user_limit = typeof _data.userLimit !== 'undefined' ? _data.userLimit : channel.userLimit; | ||
data.parent_id = _data.parent || (channel.parent ? channel.parent.id : undefined); | ||
@@ -813,3 +807,6 @@ return this.rest.makeRequest('patch', Endpoints.Channel(channel), true, data, undefined, reason).then(newData => | ||
embeds, | ||
}, files).then(resolve, reject); | ||
}, files).then(data => { | ||
if (!this.client.channels) resolve(data); | ||
else resolve(this.client.actions.MessageCreate.handle(data).message); | ||
}, reject); | ||
} | ||
@@ -816,0 +813,0 @@ }); |
@@ -166,3 +166,3 @@ const VolumeInterface = require('../util/VolumeInterface'); | ||
packetBuffer.copy(nonce, 0, 0, 12); | ||
buffer = secretbox.close(buffer, nonce, this.player.voiceConnection.authentication.secretKey.key); | ||
buffer = secretbox.methods.close(buffer, nonce, this.player.voiceConnection.authentication.secretKey.key); | ||
for (let i = 0; i < buffer.length; i++) packetBuffer[i + 12] = buffer[i]; | ||
@@ -288,3 +288,3 @@ | ||
data.sequence = data.sequence < 65535 ? data.sequence + 1 : 0; | ||
data.timestamp = data.timestamp + 4294967295 ? data.timestamp + 960 : 0; | ||
data.timestamp = (data.timestamp + 960) < 4294967295 ? data.timestamp + 960 : 0; | ||
} | ||
@@ -291,0 +291,0 @@ |
@@ -159,4 +159,4 @@ const EventEmitter = require('events').EventEmitter; | ||
createDispatcher(stream, { seek = 0, volume = 1, passes = 1 } = {}) { | ||
const options = { seek, volume, passes }; | ||
createDispatcher(stream, { seek = 0, volume = 1, passes = 1, opus } = {}) { | ||
const options = { seek, volume, passes, opus }; | ||
@@ -163,0 +163,0 @@ const dispatcher = new StreamDispatcher(this, stream, options); |
@@ -150,3 +150,3 @@ const EventEmitter = require('events').EventEmitter; | ||
msg.copy(nonce, 0, 0, 12); | ||
let data = secretbox.open(msg.slice(12), nonce, this.voiceConnection.authentication.secretKey.key); | ||
let data = secretbox.methods.open(msg.slice(12), nonce, this.voiceConnection.authentication.secretKey.key); | ||
if (!data) { | ||
@@ -153,0 +153,0 @@ /** |
@@ -16,8 +16,19 @@ const libs = { | ||
exports.methods = {}; | ||
for (const libName of Object.keys(libs)) { | ||
try { | ||
const lib = require(libName); | ||
module.exports = libs[libName](lib); | ||
if (libName === 'libsodium-wrappers' && lib.ready) { | ||
lib.ready.then(() => { | ||
exports.methods = libs[libName](lib); | ||
}).catch(() => { | ||
const tweetnacl = require('tweetnacl'); | ||
exports.methods = libs.tweetnacl(tweetnacl); | ||
}).catch(() => undefined); | ||
} else { | ||
exports.methods = libs[libName](lib); | ||
} | ||
break; | ||
} catch (err) {} // eslint-disable-line no-empty | ||
} |
@@ -20,3 +20,3 @@ const AbstractHandler = require('./AbstractHandler'); | ||
for (const guild of data.guilds) client.dataManager.newGuild(guild); | ||
for (const guild of data.guilds) if (!client.guilds.has(guild.id)) client.dataManager.newGuild(guild); | ||
for (const privateDM of data.private_channels) client.dataManager.newChannel(privateDM); | ||
@@ -23,0 +23,0 @@ |
@@ -85,3 +85,5 @@ const browser = typeof window !== 'undefined'; | ||
remaining: 120, | ||
resetTime: -1, | ||
total: 120, | ||
time: 60e3, | ||
resetTimer: null, | ||
}; | ||
@@ -194,6 +196,6 @@ this.connect(gateway); | ||
if (this.ratelimit.remaining === 120) { | ||
this.ratelimit.resetTimer = setTimeout(() => { | ||
this.ratelimit.remaining = 120; | ||
this.ratelimit.resetTimer = this.client.setTimeout(() => { | ||
this.ratelimit.remaining = 60; | ||
this.processQueue(); | ||
}, 120e3); // eslint-disable-line | ||
}, this.ratelimit.time); | ||
} | ||
@@ -200,0 +202,0 @@ while (this.ratelimit.remaining > 0) { |
@@ -30,2 +30,3 @@ const Util = require('./util/Util'); | ||
Attachment: require('./structures/Attachment'), | ||
CategoryChannel: require('./structures/CategoryChannel'), | ||
Channel: require('./structures/Channel'), | ||
@@ -32,0 +33,0 @@ ClientUser: require('./structures/ClientUser'), |
@@ -8,2 +8,6 @@ const GuildChannel = require('./GuildChannel'); | ||
class CategoryChannel extends GuildChannel { | ||
constructor(guild, data) { | ||
super(guild, data); | ||
this.type = 'category'; | ||
} | ||
/** | ||
@@ -10,0 +14,0 @@ * The channels that are part of this category |
@@ -22,2 +22,3 @@ const Snowflake = require('../util/Snowflake'); | ||
* * `voice` - a guild voice channel | ||
* * `category` - a guild category channel | ||
* @type {string} | ||
@@ -24,0 +25,0 @@ */ |
@@ -24,3 +24,4 @@ const User = require('./User'); | ||
* The email of this account | ||
* @type {string} | ||
* <warn>This is only filled when using a user account.</warn> | ||
* @type {?string} | ||
*/ | ||
@@ -177,2 +178,7 @@ this.email = data.email; | ||
* @returns {Promise<ClientUser>} | ||
* @example | ||
* // Set the client user's presence | ||
* client.user.setPresence({ game: { name: 'with discord.js' }, status: 'idle' }) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -245,2 +251,7 @@ setPresence(data) { | ||
* @returns {Promise<ClientUser>} | ||
* @example | ||
* // Set the client user's status | ||
* client.user.setStatus('idle') | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -275,5 +286,9 @@ setStatus(status) { | ||
* @returns {Promise<Presence>} | ||
* @example | ||
* client.user.setActivity('YouTube', { type: 'WATCHING' }) | ||
* .then(presence => console.log(`Activity set to ${presence.game ? presence.game.name : 'none'}`)) | ||
* .catch(console.error); | ||
*/ | ||
setActivity(name, { url, type } = {}) { | ||
if (!name) return this.setPresence({ activity: null }); | ||
if (!name) return this.setPresence({ game: null }); | ||
return this.setPresence({ | ||
@@ -299,4 +314,16 @@ game: { name, type, url }, | ||
* @param {boolean} [options.everyone=true] Whether to include everyone/here mentions | ||
* @param {Guild|Snowflake} [options.guild] Limit the search to a specific guild | ||
* @param {GuildResolvable} [options.guild] Limit the search to a specific guild | ||
* @returns {Promise<Message[]>} | ||
* @example | ||
* // Fetch mentions | ||
* client.user.fetchMentions() | ||
* .then(console.log) | ||
* .catch(console.error); | ||
* @example | ||
* // Fetch mentions from a guild | ||
* client.user.fetchMentions({ | ||
* guild: '222078108977594368' | ||
* }) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -361,2 +388,10 @@ fetchMentions(options = {}) { | ||
* @returns {Promise<GroupDMChannel>} | ||
* @example | ||
* // Create a Group DM with a token provided from OAuth | ||
* client.user.createGroupDM([{ | ||
* user: '66564597481480192', | ||
* accessToken: token | ||
* }]) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -363,0 +398,0 @@ createGroupDM(recipients) { |
@@ -444,6 +444,10 @@ const util = require('util'); | ||
* @returns {Promise<Collection<Snowflake, User>>} | ||
* @example | ||
* // Fetch bans in guild | ||
* guild.fetchBans() | ||
* .then(bans => console.log(`This guild has ${bans.size} bans`)) | ||
* .catch(console.error); | ||
*/ | ||
fetchBans() { | ||
return this.client.rest.methods.getGuildBans(this) | ||
// This entire re-mapping can be removed in the next major release | ||
.then(bans => { | ||
@@ -460,2 +464,12 @@ const users = new Collection(); | ||
* @returns {Promise<Collection<string, Invite>>} | ||
* @example | ||
* // Fetch invites | ||
* guild.fetchInvites() | ||
* .then(invites => console.log(`Fetched ${invites.size} invites`)) | ||
* .catch(console.error); | ||
* @example | ||
* // Fetch invite creator by their id | ||
* guild.fetchInvites() | ||
* .then(invites => console.log(invites.find(invite => invite.inviter.id === '84484653687267328'))) | ||
* .then(console.error); | ||
*/ | ||
@@ -468,3 +482,8 @@ fetchInvites() { | ||
* Fetch all webhooks for the guild. | ||
* @returns {Collection<Snowflake, Webhook>} | ||
* @returns {Promise<Collection<Snowflake, Webhook>>} | ||
* @example | ||
* // Fetch webhooks | ||
* guild.fetchWebhooks() | ||
* .then(webhooks => console.log(`Fetched ${webhooks.size} webhooks`)) | ||
* .catch(console.error); | ||
*/ | ||
@@ -477,3 +496,8 @@ fetchWebhooks() { | ||
* Fetch available voice regions. | ||
* @returns {Collection<string, VoiceRegion>} | ||
* @returns {Promise<Collection<string, VoiceRegion>>} | ||
* @example | ||
* // Fetch voice regions | ||
* guild.fetchVoiceRegions() | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -496,3 +520,3 @@ fetchVoiceRegions() { | ||
* guild.fetchAuditLogs() | ||
* .then(audit => console.log(audit.entries)) | ||
* .then(audit => console.log(audit.entries.first())) | ||
* .catch(console.error); | ||
@@ -535,3 +559,3 @@ */ | ||
user = this.client.resolver.resolveUser(user); | ||
if (!user) return Promise.reject(new Error('User is not cached. Use Client.fetchUser first.')); | ||
if (!user) return Promise.reject(new Error('Invalid or uncached id provided.')); | ||
if (this.members.has(user.id)) return Promise.resolve(this.members.get(user.id)); | ||
@@ -547,2 +571,12 @@ return this.client.rest.methods.getGuildMember(this, user, cache); | ||
* @returns {Promise<Guild>} | ||
* @example | ||
* // Fetch guild members | ||
* guild.fetchMembers() | ||
* .then(console.log) | ||
* .catch(console.error); | ||
* @example | ||
* // Fetches a maximum of 1 member with the given query | ||
* guild.fetchMembers('hydrabolt', 1) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -552,4 +586,2 @@ fetchMembers(query = '', limit = 0) { | ||
if (this.memberCount === this.members.size) { | ||
// Uncomment in v12 | ||
// resolve(this.members) | ||
resolve(this); | ||
@@ -570,4 +602,2 @@ return; | ||
this.client.removeListener(Constants.Events.GUILD_MEMBERS_CHUNK, handler); | ||
// Uncomment in v12 | ||
// resolve(this.members) | ||
resolve(this); | ||
@@ -590,6 +620,8 @@ } | ||
* before: '2016-11-17' | ||
* }).then(res => { | ||
* const hit = res.messages[0].find(m => m.hit).content; | ||
* console.log(`I found: **${hit}**, total results: ${res.totalResults}`); | ||
* }).catch(console.error); | ||
* }) | ||
* .then(res => { | ||
* const hit = res.messages[0].find(m => m.hit).content; | ||
* console.log(`I found: **${hit}**, total results: ${res.totalResults}`); | ||
* }) | ||
* .catch(console.error); | ||
*/ | ||
@@ -626,3 +658,3 @@ search(options = {}) { | ||
* }) | ||
* .then(updated => console.log(`New guild name ${updated.name} in region ${updated.region}`)) | ||
* .then(g => console.log(`Changed guild name to ${g} and region to ${g.region}`)) | ||
* .catch(console.error); | ||
@@ -669,3 +701,3 @@ */ | ||
* guild.setName('Discord Guild') | ||
* .then(updated => console.log(`Updated guild name to ${guild.name}`)) | ||
* .then(g => console.log(`Updated guild name to ${g}`)) | ||
* .catch(console.error); | ||
@@ -685,3 +717,3 @@ */ | ||
* guild.setRegion('london') | ||
* .then(updated => console.log(`Updated guild region to ${guild.region}`)) | ||
* .then(g => console.log(`Updated guild region to ${g.region}`)) | ||
* .catch(console.error); | ||
@@ -701,3 +733,3 @@ */ | ||
* guild.setVerificationLevel(1) | ||
* .then(updated => console.log(`Updated guild verification level to ${guild.verificationLevel}`)) | ||
* .then(g => console.log(`Updated guild verification level to ${g.verificationLevel}`)) | ||
* .catch(console.error); | ||
@@ -717,3 +749,3 @@ */ | ||
* guild.setAFKChannel(channel) | ||
* .then(updated => console.log(`Updated guild AFK channel to ${guild.afkChannel}`)) | ||
* .then(g => console.log(`Updated guild AFK channel to ${g.afkChannel.name}`)) | ||
* .catch(console.error); | ||
@@ -743,3 +775,3 @@ */ | ||
* guild.setAFKTimeout(60) | ||
* .then(updated => console.log(`Updated guild AFK timeout to ${guild.afkTimeout}`)) | ||
* .then(g => console.log(`Updated guild AFK timeout to ${g.afkTimeout}`)) | ||
* .catch(console.error); | ||
@@ -759,3 +791,3 @@ */ | ||
* guild.setIcon('./icon.png') | ||
* .then(updated => console.log('Updated the guild icon')) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
@@ -775,3 +807,3 @@ */ | ||
* guild.setOwner(guild.members.first()) | ||
* .then(updated => console.log(`Updated the guild owner to ${updated.owner.username}`)) | ||
* .then(g => console.log(`Updated the guild owner to ${g.owner.displayName}`)) | ||
* .catch(console.error); | ||
@@ -791,3 +823,3 @@ */ | ||
* guild.setSplash('./splash.png') | ||
* .then(updated => console.log('Updated the guild splash')) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
@@ -845,6 +877,11 @@ */ | ||
* @example | ||
* // Ban a user by ID (or with a user/guild member object) | ||
* // Ban a user by ID | ||
* guild.ban('some user ID') | ||
* .then(user => console.log(`Banned ${user.username || user.id || user} from ${guild.name}`)) | ||
* .then(user => console.log(`Banned ${user.username || user.id || user} from ${guild}`)) | ||
* .catch(console.error); | ||
* @example | ||
* // Ban a user by object with reason and days | ||
* guild.ban(user, { days: 7, reason: 'He needed to go' }) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -869,3 +906,3 @@ ban(user, options = {}) { | ||
* guild.unban('some user ID') | ||
* .then(user => console.log(`Unbanned ${user.username} from ${guild.name}`)) | ||
* .then(user => console.log(`Unbanned ${user.username} from ${guild}`)) | ||
* .catch(console.error); | ||
@@ -925,4 +962,13 @@ */ | ||
* guild.createChannel('new-general', 'text') | ||
* .then(channel => console.log(`Created new channel ${channel}`)) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
* @example | ||
* // Create a new category channel with permission overwrites | ||
* guild.createChannel('new-category', 'category', [{ | ||
* id: guild.id, | ||
* deny: ['MANAGE_MESSAGES'], | ||
* allow: ['SEND_MESSAGES'] | ||
* }]) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -946,3 +992,3 @@ createChannel(name, type, overwrites, reason) { | ||
* guild.updateChannels([{ channel: channelID, position: newChannelIndex }]) | ||
* .then(guild => console.log(`Updated channel positions for ${guild.id}`)) | ||
* .then(g => console.log(`Updated channel positions for ${g}`)) | ||
* .catch(console.error); | ||
@@ -955,3 +1001,3 @@ */ | ||
/** | ||
* Creates a new role in the guild with given information | ||
* Creates a new role in the guild with given information. | ||
* @param {RoleData} [data] The data to update the role with | ||
@@ -963,3 +1009,3 @@ * @param {string} [reason] Reason for creating this role | ||
* guild.createRole() | ||
* .then(role => console.log(`Created role ${role}`)) | ||
* .then(role => console.log(`Created new role with name ${role.name}`)) | ||
* .catch(console.error); | ||
@@ -972,3 +1018,3 @@ * @example | ||
* }) | ||
* .then(role => console.log(`Created role ${role}`)) | ||
* .then(role => console.log(`Created new role with name ${role.name} and color ${role.color}`)) | ||
* .catch(console.error) | ||
@@ -990,3 +1036,3 @@ */ | ||
* guild.createEmoji('https://i.imgur.com/w3duR07.png', 'rip') | ||
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`)) | ||
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}`)) | ||
* .catch(console.error); | ||
@@ -996,3 +1042,3 @@ * @example | ||
* guild.createEmoji('./memes/banana.png', 'banana') | ||
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`)) | ||
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}`)) | ||
* .catch(console.error); | ||
@@ -999,0 +1045,0 @@ */ |
const Collection = require('../util/Collection'); | ||
const Snowflake = require('../util/Snowflake'); | ||
const Webhook = require('./Webhook'); | ||
const Invite = require('./Invite'); | ||
@@ -331,8 +332,11 @@ /** | ||
} else if (targetType === Targets.INVITE) { | ||
const change = this.changes.find(c => c.key === 'code'); | ||
this.target = guild.fetchInvites() | ||
.then(invites => { | ||
this.target = invites.find(i => i.code === (change.new_value || change.old_value)); | ||
return this.target; | ||
}); | ||
const changes = this.changes.reduce((o, c) => { | ||
o[c.key] = c.new || c.old; | ||
return o; | ||
}, { | ||
id: data.target_id, | ||
guild, | ||
}); | ||
changes.channel = guild.channels.get(changes.channel_id); | ||
this.target = new Invite(guild.client, changes); | ||
} else if (targetType === Targets.MESSAGE) { | ||
@@ -339,0 +343,0 @@ this.target = guild.client.users.get(data.target_id); |
@@ -164,3 +164,3 @@ const Channel = require('./Channel'); | ||
* }) | ||
* .then(() => console.log('Done!')) | ||
* .then(updated => console.log(updated.permissionOverwrites.get(message.author.id))) | ||
* .catch(console.error); | ||
@@ -267,5 +267,10 @@ */ | ||
* Set a new parent for the guild channel. | ||
* @param {GuildChannel|SnowFlake} parent The new parent for the guild channel | ||
* @param {CategoryChannel|SnowFlake} parent The new parent for the guild channel | ||
* @param {string} [reason] Reason for changing the guild channel's parent | ||
* @returns {Promise<GuildChannel>} | ||
* @example | ||
* // Sets the parent of a channel | ||
* channel.setParent('174674066072928256') | ||
* .then(updated => console.log(`Set the category of ${updated.name} to ${updated.parent.name}`)) | ||
* .catch(console.error); | ||
*/ | ||
@@ -284,4 +289,4 @@ setParent(parent, reason) { | ||
* // Set a new channel topic | ||
* channel.setTopic('needs more rate limiting') | ||
* .then(newChannel => console.log(`Channel's new topic is ${newChannel.topic}`)) | ||
* channel.setTopic('Needs more rate limiting') | ||
* .then(updated => console.log(`Channel's new topic is ${updated.topic}`)) | ||
* .catch(console.error); | ||
@@ -321,2 +326,7 @@ */ | ||
* @returns {Promise<GuildChannel>} | ||
* @example | ||
* // Clone a channel | ||
* channel.clone(undefined, true, false, 'Needed a clone') | ||
* .then(clone => console.log(`Cloned ${channel.name} to make a channel called ${clone.name}`)) | ||
* .catch(console.error); | ||
*/ | ||
@@ -334,5 +344,5 @@ clone(name = this.name, withPermissions = true, withTopic = true, reason) { | ||
* // Delete the channel | ||
* channel.delete('making room for new channels') | ||
* .then(channel => console.log(`Deleted ${channel.name} to make room for new channels`)) | ||
* .catch(console.error); // Log error | ||
* channel.delete('Making room for new channels') | ||
* .then(deleted => console.log(`Deleted ${deleted.name} to make room for new channels`)) | ||
* .catch(console.error); | ||
*/ | ||
@@ -339,0 +349,0 @@ delete(reason) { |
@@ -339,3 +339,3 @@ const TextBasedChannel = require('./interfaces/TextBasedChannel'); | ||
* @property {string} [nick] The nickname to set for the member | ||
* @property {Collection<Snowflake, Role>|Role[]|Snowflake[]} [roles] The roles or role IDs to apply | ||
* @property {Collection<Snowflake, Role>|RoleResolvable[]} [roles] The roles or role IDs to apply | ||
* @property {boolean} [mute] Whether or not the member should be muted | ||
@@ -351,2 +351,10 @@ * @property {boolean} [deaf] Whether or not the member should be deafened | ||
* @returns {Promise<GuildMember>} | ||
* @example | ||
* // Set a member's nickname and clear their roles | ||
* message.member.edit({ | ||
* nick: 'Cool Name', | ||
* roles: [] | ||
* }) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -362,2 +370,7 @@ edit(data, reason) { | ||
* @returns {Promise<GuildMember>} | ||
* @example | ||
* // Mute a member with a reason | ||
* message.member.setMute(true, 'It needed to be done') | ||
* .then(() => console.log(`Muted ${message.member.displayName}`))) | ||
* .catch(console.error); | ||
*/ | ||
@@ -373,2 +386,7 @@ setMute(mute, reason) { | ||
* @returns {Promise<GuildMember>} | ||
* @example | ||
* // Deafen a member | ||
* message.member.setDeaf(true) | ||
* .then(() => console.log(`Deafened ${message.member.displayName}`)) | ||
* .catch(console.error); | ||
*/ | ||
@@ -383,2 +401,7 @@ setDeaf(deaf, reason) { | ||
* @returns {Promise<GuildMember>} | ||
* @example | ||
* // Moves a member to a voice channel | ||
* member.setVoiceChannel('174674066072928256') | ||
* .then(() => console.log(`Moved ${member.displayName}`)) | ||
* .catch(console.error); | ||
*/ | ||
@@ -391,3 +414,3 @@ setVoiceChannel(channel) { | ||
* Sets the roles applied to the member. | ||
* @param {Collection<Snowflake, Role>|Role[]|Snowflake[]} roles The roles or role IDs to apply | ||
* @param {Collection<Snowflake, Role>|RoleResolvable[]} roles The roles or role IDs to apply | ||
* @param {string} [reason] Reason for applying the roles | ||
@@ -401,5 +424,5 @@ * @returns {Promise<GuildMember>} | ||
* @example | ||
* // Remove all the roles from a member | ||
* // Remove all of the member's roles | ||
* guildMember.setRoles([]) | ||
* .then(member => console.log(`Member roles is now of ${member.roles.size} size`)) | ||
* .then(member => console.log(`${member.displayName} now has ${member.roles.size} roles`)) | ||
* .catch(console.error); | ||
@@ -413,5 +436,10 @@ */ | ||
* Adds a single role to the member. | ||
* @param {Role|Snowflake} role The role or ID of the role to add | ||
* @param {RoleResolvable} role The role or ID of the role to add | ||
* @param {string} [reason] Reason for adding the role | ||
* @returns {Promise<GuildMember>} | ||
* @example | ||
* // Give a role to a member | ||
* message.member.addRole('193654001089118208') | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -426,5 +454,10 @@ addRole(role, reason) { | ||
* Adds multiple roles to the member. | ||
* @param {Collection<Snowflake, Role>|Role[]|Snowflake[]} roles The roles or role IDs to add | ||
* @param {Collection<Snowflake, Role>|RoleResolvable[]} roles The roles or role IDs to add | ||
* @param {string} [reason] Reason for adding the roles | ||
* @returns {Promise<GuildMember>} | ||
* @example | ||
* // Gives a member a few roles | ||
* message.member.addRoles(['193654001089118208', '369308579892690945']) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -444,5 +477,10 @@ addRoles(roles, reason) { | ||
* Removes a single role from the member. | ||
* @param {Role|Snowflake} role The role or ID of the role to remove | ||
* @param {RoleResolvable} role The role or ID of the role to remove | ||
* @param {string} [reason] Reason for removing the role | ||
* @returns {Promise<GuildMember>} | ||
* @example | ||
* // Remove a role from a member | ||
* message.member.removeRole('193654001089118208') | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -457,5 +495,10 @@ removeRole(role, reason) { | ||
* Removes multiple roles from the member. | ||
* @param {Collection<Snowflake, Role>|Role[]|Snowflake[]} roles The roles or role IDs to remove | ||
* @param {Collection<Snowflake, Role>|RoleResolvable[]} roles The roles or role IDs to remove | ||
* @param {string} [reason] Reason for removing the roles | ||
* @returns {Promise<GuildMember>} | ||
* @example | ||
* // Removes a few roles from the member | ||
* message.member.removeRoles(['193654001089118208', '369308579892690945']) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -483,2 +526,7 @@ removeRoles(roles, reason) { | ||
* @returns {Promise<GuildMember>} | ||
* @example | ||
* // Update the member's nickname | ||
* message.member.setNickname('Cool Name') | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -509,2 +557,7 @@ setNickname(nick, reason) { | ||
* @returns {Promise<GuildMember>} | ||
* @example | ||
* // Kick a member | ||
* member.kick() | ||
* .then(() => console.log(`Kicked ${member.displayName}`)) | ||
* .catch(console.error); | ||
*/ | ||
@@ -524,4 +577,4 @@ kick(reason) { | ||
* // Ban a guild member | ||
* guildMember.ban(7) | ||
* .then(console.log) | ||
* member.ban(7) | ||
* .then(() => console.log(`Banned ${member.displayName}`)) | ||
* .catch(console.error); | ||
@@ -528,0 +581,0 @@ */ |
@@ -74,7 +74,40 @@ const path = require('path'); | ||
* @example | ||
* // Send a message | ||
* // Send a basic message | ||
* channel.send('hello!') | ||
* .then(message => console.log(`Sent message: ${message.content}`)) | ||
* .catch(console.error); | ||
* @example | ||
* // Send a remote file | ||
* channel.send({ | ||
* files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048'] | ||
* }) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
* @example | ||
* // Send a local file | ||
* channel.send({ | ||
* files: [{ | ||
* attachment: 'entire/path/to/file.jpg', | ||
* name: 'file.jpg' | ||
* }] | ||
* }) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
* @example | ||
* // Send an embed with a local image inside | ||
* channel.send('This is an embed', { | ||
* embed: { | ||
* thumbnail: { | ||
* url: 'attachment://file.jpg' | ||
* } | ||
* }, | ||
* files: [{ | ||
* attachment: 'entire/path/to/file.jpg', | ||
* name: 'file.jpg' | ||
* }] | ||
* }) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
// eslint-disable-next-line complexity | ||
send(content, options) { | ||
@@ -272,2 +305,3 @@ if (!options && typeof content === 'object' && !(content instanceof Array)) { | ||
entry.count = count || entry.count + 1; | ||
return; | ||
} | ||
@@ -406,12 +440,12 @@ | ||
bulkDelete(messages, filterOld = false) { | ||
if (messages instanceof Array || messages instanceof Collection) { | ||
let messageIDs = messages instanceof Collection ? messages.keyArray() : messages.map(m => m.id); | ||
if (messages instanceof Collection) messages = [...messages.values()]; | ||
if (messages instanceof Array) { | ||
if (filterOld) { | ||
messageIDs = messageIDs.filter(id => Date.now() - Snowflake.deconstruct(id).date.getTime() < 1209600000); | ||
messages = messages.filter(m => Date.now() - Snowflake.deconstruct(m.id).date.getTime() < 1209600000); | ||
} | ||
if (messageIDs.length === 0) return new Collection(); | ||
if (messageIDs.length === 1) { | ||
return this.fetchMessage(messageIDs[0]).then(msg => msg.delete().then(() => new Collection([[msg.id, msg]]))); | ||
if (messages.length === 0) return new Collection(); | ||
if (messages.length === 1) { | ||
return messages[0].delete().then(() => new Collection([[messages[0].id, messages[0]]])); | ||
} | ||
return this.client.rest.methods.bulkDeleteMessages(this, messageIDs, filterOld); | ||
return this.client.rest.methods.bulkDeleteMessages(this, messages); | ||
} | ||
@@ -418,0 +452,0 @@ if (!isNaN(messages)) return this.fetchMessages({ limit: messages }).then(msgs => this.bulkDelete(msgs, filterOld)); |
@@ -44,3 +44,3 @@ const Mentions = require('./MessageMentions'); | ||
* The type of the message | ||
* @type {string} | ||
* @type {MessageType} | ||
*/ | ||
@@ -379,3 +379,3 @@ this.type = Constants.MessageTypes[data.type]; | ||
* message.edit('This is my new content!') | ||
* .then(msg => console.log(`Updated the content of a message from ${msg.author}`)) | ||
* .then(msg => console.log(`New message content: ${msg}`)) | ||
* .catch(console.error); | ||
@@ -426,2 +426,12 @@ */ | ||
* @returns {Promise<MessageReaction>} | ||
* @example | ||
* // React to a message with a unicode emoji | ||
* message.react('🤔') | ||
* .then(console.log) | ||
* .catch(console.error); | ||
* @example | ||
* // React to a message with a custom emoji | ||
* message.react(message.guild.emojis.get('123456789012345678')) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -450,3 +460,3 @@ react(emoji) { | ||
* message.delete() | ||
* .then(msg => console.log(`Deleted message from ${msg.author}`)) | ||
* .then(msg => console.log(`Deleted message from ${msg.author.username}`)) | ||
* .catch(console.error); | ||
@@ -474,3 +484,3 @@ */ | ||
* message.reply('Hey, I\'m a reply!') | ||
* .then(msg => console.log(`Sent a reply to ${msg.author}`)) | ||
* .then(sent => console.log(`Sent a reply to ${sent.author.username}`)) | ||
* .catch(console.error); | ||
@@ -477,0 +487,0 @@ */ |
@@ -66,3 +66,3 @@ /** | ||
*/ | ||
this.createdTimestamp = data.timestamp; | ||
this.timestamp = data.timestamp; | ||
@@ -69,0 +69,0 @@ /** |
@@ -208,5 +208,5 @@ const Snowflake = require('../util/Snowflake'); | ||
* @example | ||
* // Edit a role | ||
* role.edit({name: 'new role'}) | ||
* .then(r => console.log(`Edited role ${r}`)) | ||
* // Edit name of a role | ||
* role.edit({ name: 'New Name' }) | ||
* .then(updated => console.log(`Edited role name from ${role.name} to ${updated.name}`)) | ||
* .catch(console.error); | ||
@@ -225,4 +225,4 @@ */ | ||
* // Set the name of the role | ||
* role.setName('new role') | ||
* .then(r => console.log(`Edited name of role ${r}`)) | ||
* role.setName('New Name') | ||
* .then(updated => console.log(`Edited role name from ${role.name} to ${updated.name}`)) | ||
* .catch(console.error); | ||
@@ -242,3 +242,3 @@ */ | ||
* role.setColor('#FF0000') | ||
* .then(r => console.log(`Set color of role ${r}`)) | ||
* .then(updated => console.log(`Set color of role to ${role.color}`)) | ||
* .catch(console.error); | ||
@@ -258,3 +258,3 @@ */ | ||
* role.setHoist(true) | ||
* .then(r => console.log(`Role hoisted: ${r.hoist}`)) | ||
* .then(updated => console.log(`Role hoisted: ${updated.hoist}`)) | ||
* .catch(console.error); | ||
@@ -274,3 +274,3 @@ */ | ||
* role.setPosition(1) | ||
* .then(r => console.log(`Role position: ${r.position}`)) | ||
* .then(updated => console.log(`Role position: ${updated.position}`)) | ||
* .catch(console.error); | ||
@@ -290,3 +290,3 @@ */ | ||
* role.setPermissions(['KICK_MEMBERS', 'BAN_MEMBERS']) | ||
* .then(r => console.log(`Role updated ${r}`)) | ||
* .then(updated => console.log(`Updated permissions to ${updated.permissions.bitfield}`)) | ||
* .catch(console.error); | ||
@@ -305,4 +305,4 @@ */ | ||
* // Make the role mentionable | ||
* role.setMentionable(true) | ||
* .then(r => console.log(`Role updated ${r}`)) | ||
* role.setMentionable(true, 'Role needs to be pinged') | ||
* .then(updated => console.log(`Role mentionable: ${updated.mentionable}`)) | ||
* .catch(console.error); | ||
@@ -320,4 +320,4 @@ */ | ||
* // Delete a role | ||
* role.delete() | ||
* .then(r => console.log(`Deleted role ${r}`)) | ||
* role.delete('The role needed to go') | ||
* .then(deleted => console.log(`Deleted role ${deleted.name}`)) | ||
* .catch(console.error); | ||
@@ -324,0 +324,0 @@ */ |
@@ -96,10 +96,42 @@ const path = require('path'); | ||
* @param {StringResolvable} content The content to send | ||
* @param {WebhookMessageOptions|Attachment|RichEmbed} [options] The options to provide | ||
* @param {WebhookMessageOptions|Attachment|RichEmbed} [options] The options to provide, | ||
* can also be just a RichEmbed or Attachment | ||
* @returns {Promise<Message|Message[]>} | ||
* @returns {Promise<Message|Message[]|Object|Object[]>} | ||
* @example | ||
* // Send a message | ||
* // Send a basic message | ||
* webhook.send('hello!') | ||
* .then(message => console.log(`Sent message: ${message.content}`)) | ||
* .catch(console.error); | ||
* @example | ||
* // Send a remote file | ||
* webhook.send({ | ||
* files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048'] | ||
* }) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
* @example | ||
* // Send a local file | ||
* webhook.send({ | ||
* files: [{ | ||
* attachment: 'entire/path/to/file.jpg', | ||
* name: 'file.jpg' | ||
* }] | ||
* }) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
* @example | ||
* // Send an embed with a local image inside | ||
* webhook.send('This is an embed', { | ||
* embeds: [{ | ||
* thumbnail: { | ||
* url: 'attachment://file.jpg' | ||
* } | ||
* }], | ||
* files: [{ | ||
* attachment: 'entire/path/to/file.jpg', | ||
* name: 'file.jpg' | ||
* }] | ||
* }) | ||
* .then(console.log) | ||
* .catch(console.error); | ||
*/ | ||
@@ -106,0 +138,0 @@ send(content, options) { // eslint-disable-line complexity |
@@ -42,7 +42,8 @@ /** | ||
* reconstructed if an item is added to or removed from the collection, or if you change the length of the array | ||
* itself. If you don't want this caching behaviour, use `Array.from(collection.values())` instead. | ||
* itself. If you don't want this caching behaviour, use `[...collection.values()]` or | ||
* `Array.from(collection.values())` instead. | ||
* @returns {Array} | ||
*/ | ||
array() { | ||
if (!this._array || this._array.length !== this.size) this._array = Array.from(this.values()); | ||
if (!this._array || this._array.length !== this.size) this._array = [...this.values()]; | ||
return this._array; | ||
@@ -54,7 +55,8 @@ } | ||
* reconstructed if an item is added to or removed from the collection, or if you change the length of the array | ||
* itself. If you don't want this caching behaviour, use `Array.from(collection.keys())` instead. | ||
* itself. If you don't want this caching behaviour, use `[...collection.keys()]` or | ||
* `Array.from(collection.keys())` instead. | ||
* @returns {Array} | ||
*/ | ||
keyArray() { | ||
if (!this._keyArray || this._keyArray.length !== this.size) this._keyArray = Array.from(this.keys()); | ||
if (!this._keyArray || this._keyArray.length !== this.size) this._keyArray = [...this.keys()]; | ||
return this._keyArray; | ||
@@ -424,3 +426,3 @@ } | ||
sort(compareFunction = (x, y) => +(x > y) || +(x === y) - 1) { | ||
return new Collection(Array.from(this.entries()).sort((a, b) => compareFunction(a[1], b[1], a[0], b[0]))); | ||
return new Collection([...this.entries()].sort((a, b) => compareFunction(a[1], b[1], a[0], b[0]))); | ||
} | ||
@@ -427,0 +429,0 @@ } |
Sorry, the diff of this file is not supported yet
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
88
566034
154
16237
+ Addedlibsodium@0.7.15(transitive)
+ Addedlibsodium-wrappers@0.7.15(transitive)
+ Addedlong@4.0.0(transitive)
+ Addedprism-media@0.0.2(transitive)
- Removedlibsodium@0.5.4(transitive)
- Removedlibsodium-wrappers@0.5.4(transitive)
- Removedlong@3.2.0(transitive)
- Removedprism-media@0.0.1(transitive)
Updatedlong@^4.0.0
Updatedprism-media@^0.0.2
Updatedsnekfetch@^3.6.4