Skip to content

Commit

Permalink
update from stable (#1)
Browse files Browse the repository at this point in the history
* Docs: document ChannelData.parent and .permissionOverwrites, fix typedefs to not include Collection of ChannelCreationOverwrite  (discordjs#2734)

* document ChannelData.parent

* document ChannelData.permissionOverwrites

* Overwrites also take other things, account for it

* note to self: stop copy-pasting

* remove eslint madness, fix param defs

* fix property slip

* Bump to 11.4.2

* refactor: Merge typings into 11.4-dev branch

* fix(Message): properly check for an edited_timestamp in patch

Fixes discordjs#2750

* fix(Permissions): Permissions itself is a valid PermissionResolvable

fixes discordjs#2753

* typings: make PermissionResolvable recursive

* backport: handle async stacktraces correctly (discordjs#2768)

* fix: WebhookClient should handle ratelimits properly

* fix: pin & update deps

* fix: disable getter-return

* fix(webpack): properly emitting process deprecation warnings

* backport: User#dmChannel perf enhancement (discordjs#2780)

* docs(Emoji): fix typo of the word "emoji" (discordjs#2791)

* fix: Guild#addMember incorrectly resolving userID

* backport: WEBHOOKS_UPDATE event (discordjs#2779)

* typings: add WEBHOOKS_UPDATE

* typings: clean up permissionResolvable

* backport: Deprecate allowed/denied as discordjs#2765 (discordjs#2792)

* fix(GuildChannel#lockPermissions): Properties allow and deny always returning undefined (discordjs#2800)

* fix undefined properties

* requested changes

* backport: `GUILD_INTEGRATIONS_UPDATE` event (discordjs#2794)

* backport: Client#on{guildIntegrationsUpdate,webhookUpdate}

misc: Update Constants.WSEvents and WSEventType

backport: Add guildIntegrationsUpdate event handler

* docs: Updated typings

* backport: Guild#{fetchEmbed,setEmbed} (discordjs#2778)

*  backport: Guild Embeds

* fix: Added missing return

* docs: Updated typings

* backport: UNKNOWN_WEBHOOK (discordjs#2777)

* docs: Added `url` to Invite's warning comment (discordjs#2804)

And added the [serial comma](https://en.wikipedia.org/wiki/Serial_comma)

* fix(Guild#deleteEmoji): reject non emojis / emoji IDs (discordjs#2793)

* fix(Guild#deleteEmoji): Performing wrong checks

* fix: requested changes

`a string` -> `an id`

* fix: requested changes

`id` -> `ID`

* docs: correct Guild#memberCount (discordjs#2812)

* build(peer-deps): use uws fork backport (discordjs#2782)

* build(peer-deps): uws backport

* chore: update to 149 for uws

* docs(User): clarify what User#tag represents

Closes discordjs#2828

* backport(ClientOptions): add retryLimit (discordjs#2869)

* backport: rateLimitPerUser (discordjs#2874)

* backport(Guild): add fetchVanityCode (discordjs#2871)

* docs(Game): document possible values for type property

See discordjs#2865

* typings: fix lint script and linter errors

* backport(TextBasedChannel): add lastPinTimestamp and lastPinAt (discordjs#2870)

And clarify Client#channelPinsUpdate's 'time' parameter.

* backport(Guild): support for createChannel with options object (discordjs#2888)

* fix: revert discordjs#2768 (discordjs#2848)

* fix: revert discordjs#2768

* fix merge

* Fix discordjs#2928 (member not being removed from voice channel after leaving guild)

* fix:(GuilChannel): clone method not taking overwrites into account (discordjs#2932)

* docs(GuildChannel): add rateLimitPerUser to ChannelData typdef

* backport(Guild): support for rateLimitPerUser when creating a channel

PR: discordjs#2878
Commit: 8ec3b51

* typings(RichEmbed): add MessageEmbed as valid data in constructor

See discordjs#2970

* docs:(TextChannel): add documentation for messages and lastMessage (discordjs#2986)

* [docs] add missing docs for <TextChannel>.messages

* add missing doc for <TextChannel>.lastMessage

* fix(TextBasedChannel): added missing lastMessage functionality in textchannels (discordjs#2999)

* docs(Webhook): add mising '@name' to Webhook#token's docstring

* typings(Guild): fix typos in method names

Fixes discordjs#3009

* typings(TextBasedChannel): fix create(Message)Collector's options type

* docs(Guild): use AuditLogAction for fetchAuditLogs' type option

* docs(Client): add missing parenthesis in fetchInvite example (discordjs#3023)

This is already fixed in master, resolves discordjs#3022

* docs(Client): add missing example tag and closing parenthesis (discordjs#3024)

* fix(Guild): ignore voice states referencing an invalid channel

This was causing an uncaught exception on startup (or whenever receiving such a payload) which is crashing the process.

* typings(SnowflakeUtil): add optional "timestamp" parameter to generate (discordjs#2998)

* feat(Constants): add error code 50020 (discordjs#2953)

* feat(Constants): Add error code 50020

Which is throw when using the vanity-url endpoint: discord/discord-api-docs#748

* docs: Document the new code

* feat(Util): add WHITE as color resolvable (discordjs#3062)

* feat(Presence): add clientStatus (discordjs#3056)

* feat(RichEmbed): add length getter (discordjs#3057)

* feat(Guild): add position to createChannel's implementation (discordjs#3058)

* fix(GuildMember): add explicit channel resolve error to member edit (discordjs#3059)

* fix(Util): splitMessage throws an error if a chunk is too large (discordjs#3060)

* feat(RichEmbed): add timestamp support for setTimestamp (discordjs#3061)

* fix(Emoji): reject explicit error when MANAGE_EMOJI permissions are missing (discordjs#3063)

* Mark peer dependencies as optional (discordjs#3066)

* docs(Guild): update createChannel examples to not use deprecated overload

* fix typo

* docs/typings: RateLimitInfo#limit instead of requestLimit (discordjs#3132)

* fix doc for ratelimit data, fixes discordjs#3131

* adapt typings

* typings: unindent #region comments

* fix discordjs#3150: can now create dispatcher with 0 volume

* feat(Guild): add fetchBan and withReasons to fetchBans (discordjs#3170)

* add Guild#fetchBan() & backport BanInfo

* and the typings

* requested changes

* typings overloads

Co-Authored-By: izexi <43889168+izexi@users.noreply.github.com>

* nullable reason typings

Co-Authored-By: izexi <43889168+izexi@users.noreply.github.com>

* typings(Collection): add typings for partition (discordjs#3166)

* fix(Guild): sort roles with the same position in the correct order (discordjs#3184)

* docs(Collection): fix findKey jsdoc (discordjs#3204)

* typings(GuildChannel): add manageable getter

* fix(WebSocketConnection): stringify data when no websocket is available

[object Object] is not really descriptive

* fix/docs(Client): type status and do not throw an error if accessed before login

* feat(GuildMember): add support for voice kicking (discordjs#3246)

This backports e64773e (discordjs#3242)

* Backport news/store channels

* Remove unnecessary import

* Add news/store channel support to CHANNEL_CREATE

* Document news/store channel types on Guild#createChannel

* Update typings for news/store channels

* Add testing for Node.js 8-12

* Bump version to 11.5.0

* docs(Guild): fix typo in example of createChannel

* docs(TextChanne): specify unit of rateLimitPerUser (discordjs#3272)

* Update TextChannel.js

Update `setRateLimitPerUser` description to specify the `number` is in seconds, per the Discord docs

* Update TextChannel.js

Add unit to the rateLimitPerUser property

* Update GuildChannel.js

* docs(ChannelCreationOverwrites): revert incorrect rename of "id" property (discordjs#3273)

Reverts one incorrect change made in discordjs#2734 (discordjs@3021e5c#diff-e5c54069adfa0d32480eb3cc9faeee20L979)

* Fix incorrect docs in Guild.js

* Update src/structures/Guild.js

Co-Authored-By: SpaceEEC <spaceeec@yahoo.com>

* Update Guild.js

* fix(GuildMember): do not create a channel key when editing

This is to not break GuildMember#setNickname for the current user

* fix(Message#pinnable): you can't pin system messages (discordjs#3279)

* chore: explicitly mark everything deprecated as `@ deprecated` (discordjs#3307)

* v11.5.1
  • Loading branch information
theLAZYmd committed Aug 14, 2019
1 parent b5df860 commit 1f799a4
Show file tree
Hide file tree
Showing 58 changed files with 3,037 additions and 157 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"no-undef-init": "error",

"callback-return": "error",
"getter-return": "off",
"handle-callback-err": "error",
"no-mixed-requires": "error",
"no-new-require": "error",
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ webpack/
webpack.config.js
.github/
test/
tsconfig.json
tslint.json
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
language: node_js
node_js:
- "6"
- "7"
- "8"
- "10"
- "12"
cache:
directories:
- node_modules
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ For production bots, using node-opus should be considered a necessity, especiall
- 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`)
- [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`)
- [uws](https://www.npmjs.com/package/@discordjs/uws) for a much faster WebSocket connection (`npm install @discordjs/uws`)

## Example usage
```js
Expand Down
4 changes: 4 additions & 0 deletions docs/general/updating.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 11.5.0
v11.5.0 backports new features from the in-development v12, and fixes bugs in the v11.4.x releases.
See [the changelog](https://github.com/discordjs/discord.js/releases/tag/11.5.0) for a full list of changes, including information about deprecations.

# Version 11.4.0
v11.4.0 backports many new features such as Rich Presence and bugfixes from v11.3.0.
See [the changelog](https://github.com/discordjs/discord.js/releases/tag/11.4.0) for a full list of changes, including information about deprecations.
Expand Down
6 changes: 3 additions & 3 deletions docs/general/welcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
</div>

# Welcome!
Welcome to the discord.js v11.4 documentation.
The v11.4 release contains bugfixes from v11.3 and backports features such as Rich Presence.
Welcome to the discord.js v11.5 documentation.
The v11.5 release contains bugfixes from v11.4 and backports features from the in-development v12.

v12 is still very much a work-in-progress, as we're aiming to make it the best it can possibly be before releasing.
If you are fond of living life on the bleeding-edge, check out the master branch.
Expand Down Expand Up @@ -52,7 +52,7 @@ For production bots, using node-opus should be considered a necessity, especiall
- 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`)
- [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`)
- [uws](https://www.npmjs.com/package/@discordjs/uws) for a much faster WebSocket connection (`npm install @discordjs/uws`)

## Example usage
```js
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/web.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The usage of the API isn't any different from using it in Node.js.

## Example
```html
<script type="text/javascript" src="discord.11.4.1.min.js"></script>
<script type="text/javascript" src="discord.11.5.0.min.js"></script>
<script type="text/javascript">
const client = new Discord.Client();
Expand Down
48 changes: 38 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord.js",
"version": "11.4.1",
"version": "11.5.1",
"description": "A powerful library for interacting with the Discord API",
"main": "./src/index",
"types": "./typings/index.d.ts",
Expand All @@ -10,6 +10,7 @@
"docs:test": "docgen --source src --custom docs/index.yml",
"lint": "eslint src",
"lint:fix": "eslint --fix src",
"lint:typings": "tslint typings/index.d.ts typings/discord.js-test.ts",
"webpack": "parallel-webpack"
},
"repository": {
Expand All @@ -36,31 +37,58 @@
"prism-media": "^0.0.3",
"snekfetch": "^3.6.4",
"tweetnacl": "^1.0.0",
"ws": "^4.0.0"
"ws": "^6.0.0"
},
"peerDependencies": {
"bufferutil": "^3.0.3",
"@discordjs/uws": "^10.149.0",
"bufferutil": "^4.0.0",
"erlpack": "discordapp/erlpack",
"libsodium-wrappers": "^0.7.3",
"node-opus": "^0.2.7",
"opusscript": "^0.0.6",
"sodium": "^2.0.3",
"libsodium-wrappers": "^0.7.3",
"uws": "^9.14.0"
"sodium": "^2.0.3"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"erlpack": {
"optional": true
},
"node-opus": {
"optional": true
},
"opusscript": {
"optional": true
},
"sodium": {
"optional": true
},
"libsodium-wrappers": {
"optional": true
},
"uws": {
"optional": true
}
},
"devDependencies": {
"@types/node": "^9.4.6",
"discord.js-docgen": "discordjs/docgen",
"eslint": "^4.18.0",
"parallel-webpack": "^2.2.0",
"uglifyjs-webpack-plugin": "^1.2.0",
"webpack": "^3.11.0"
"eslint": "^5.4.0",
"parallel-webpack": "^2.3.0",
"tslint": "^3.15.1",
"tslint-config-typings": "^0.2.4",
"typescript": "^3.0.1",
"uglifyjs-webpack-plugin": "^1.3.0",
"webpack": "^4.17.0"
},
"engines": {
"node": ">=6.0.0"
},
"browser": {
"ws": false,
"uws": false,
"@discordjs/uws": false,
"erlpack": false,
"prism-media": false,
"opusscript": false,
Expand Down
16 changes: 11 additions & 5 deletions src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class Client extends EventEmitter {
* Presences that have been received for the client user's friends, mapped by user IDs
* <warn>This is only filled when using a user account.</warn>
* @type {Collection<Snowflake, Presence>}
* @deprecated
*/
this.presences = new Collection();

Expand Down Expand Up @@ -186,11 +187,11 @@ class Client extends EventEmitter {

/**
* Current status of the client's connection to Discord
* @type {?number}
* @type {Status}
* @readonly
*/
get status() {
return this.ws.connection.status;
return this.ws.connection ? this.ws.connection.status : Constants.Status.IDLE;
}

/**
Expand Down Expand Up @@ -296,6 +297,7 @@ class Client extends EventEmitter {
* <info>This can be done automatically every 30 seconds by enabling {@link ClientOptions#sync}.</info>
* <warn>This is only available when using a user account.</warn>
* @param {Guild[]|Collection<Snowflake, Guild>} [guilds=this.guilds] An array or collection of guilds to sync
* @deprecated
*/
syncGuilds(guilds = this.guilds) {
if (this.user.bot) return;
Expand Down Expand Up @@ -323,7 +325,7 @@ class Client extends EventEmitter {
* @returns {Promise<Invite>}
* @example
* client.fetchInvite('https://discord.gg/bRCvFy9')
* .then(invite => console.log(`Obtained invite with code: ${invite.code}`)
* .then(invite => console.log(`Obtained invite with code: ${invite.code}`))
* .catch(console.error);
*/
fetchInvite(invite) {
Expand Down Expand Up @@ -395,8 +397,9 @@ class Client extends EventEmitter {
* <warn>Bots can only fetch their own profile.</warn>
* @param {Snowflake} [id='@me'] ID of application to fetch
* @returns {Promise<OAuth2Application>}
* @example
* client.fetchApplication()
* .then(application => console.log(`Obtained application with name: ${application.name}`)
* .then(application => console.log(`Obtained application with name: ${application.name}`))
* .catch(console.error);
*/
fetchApplication(id = '@me') {
Expand Down Expand Up @@ -509,7 +512,7 @@ class Client extends EventEmitter {
* @param {ClientOptions} [options=this.options] Options to validate
* @private
*/
_validateOptions(options = this.options) {
_validateOptions(options = this.options) { // eslint-disable-line complexity
if (typeof options.shardCount !== 'number' || isNaN(options.shardCount)) {
throw new TypeError('The shardCount option must be a number.');
}
Expand Down Expand Up @@ -540,6 +543,9 @@ class Client extends EventEmitter {
throw new TypeError('The restWsBridgeTimeout option must be a number.');
}
if (!(options.disabledEvents instanceof Array)) throw new TypeError('The disabledEvents option must be an Array.');
if (typeof options.retryLimit !== 'number' || isNaN(options.retryLimit)) {
throw new TypeError('The retryLimit options must be a number.');
}
}
}

Expand Down
35 changes: 23 additions & 12 deletions src/client/ClientDataManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ const Constants = require('../util/Constants');
const Util = require('../util/Util');
const Guild = require('../structures/Guild');
const User = require('../structures/User');
const CategoryChannel = require('../structures/CategoryChannel');
const DMChannel = require('../structures/DMChannel');
const Emoji = require('../structures/Emoji');
const GuildChannel = require('../structures/GuildChannel');
const TextChannel = require('../structures/TextChannel');
const VoiceChannel = require('../structures/VoiceChannel');
const GuildChannel = require('../structures/GuildChannel');
const CategoryChannel = require('../structures/CategoryChannel');
const NewsChannel = require('../structures/NewsChannel');
const StoreChannel = require('../structures/StoreChannel');
const DMChannel = require('../structures/DMChannel');
const GroupDMChannel = require('../structures/GroupDMChannel');

class ClientDataManager {
Expand Down Expand Up @@ -58,16 +60,25 @@ class ClientDataManager {
if (already) {
channel = this.client.channels.get(data.id);
} else if (guild) {
if (data.type === Constants.ChannelTypes.TEXT) {
channel = new TextChannel(guild, data);
guild.channels.set(channel.id, channel);
} else if (data.type === Constants.ChannelTypes.VOICE) {
channel = new VoiceChannel(guild, data);
guild.channels.set(channel.id, channel);
} else if (data.type === Constants.ChannelTypes.CATEGORY) {
channel = new CategoryChannel(guild, data);
guild.channels.set(channel.id, channel);
switch (data.type) {
case Constants.ChannelTypes.TEXT:
channel = new TextChannel(guild, data);
break;
case Constants.ChannelTypes.VOICE:
channel = new VoiceChannel(guild, data);
break;
case Constants.ChannelTypes.CATEGORY:
channel = new CategoryChannel(guild, data);
break;
case Constants.ChannelTypes.NEWS:
channel = new NewsChannel(guild, data);
break;
case Constants.ChannelTypes.STORE:
channel = new StoreChannel(guild, data);
break;
}

guild.channels.set(channel.id, channel);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/client/ClientDataResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ class ClientDataResolver {
* ```
* [
* 'DEFAULT',
* 'WHITE',
* 'AQUA',
* 'GREEN',
* 'BLUE',
Expand Down
44 changes: 42 additions & 2 deletions src/client/actions/ChannelUpdate.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,55 @@
const Action = require('./Action');
const TextChannel = require('../../structures/TextChannel');
const VoiceChannel = require('../../structures/VoiceChannel');
const CategoryChannel = require('../../structures/CategoryChannel');
const NewsChannel = require('../../structures/NewsChannel');
const StoreChannel = require('../../structures/StoreChannel');
const Constants = require('../../util/Constants');
const ChannelTypes = Constants.ChannelTypes;
const Util = require('../../util/Util');

class ChannelUpdateAction extends Action {
handle(data) {
const client = this.client;

const channel = client.channels.get(data.id);
let channel = client.channels.get(data.id);
if (channel) {
const oldChannel = Util.cloneObject(channel);
channel.setup(data);

// If the channel is changing types, we need to follow a different process
if (ChannelTypes[channel.type.toUpperCase()] !== data.type) {
// Determine which channel class we're changing to
let channelClass;
switch (data.type) {
case ChannelTypes.TEXT:
channelClass = TextChannel;
break;
case ChannelTypes.VOICE:
channelClass = VoiceChannel;
break;
case ChannelTypes.CATEGORY:
channelClass = CategoryChannel;
break;
case ChannelTypes.NEWS:
channelClass = NewsChannel;
break;
case ChannelTypes.STORE:
channelClass = StoreChannel;
break;
}

// Create the new channel instance and copy over cached data
const newChannel = new channelClass(channel.guild, data);
if (channel.messages && newChannel.messages) {
for (const [id, message] of channel.messages) newChannel.messages.set(id, message);
}

channel = newChannel;
this.client.channels.set(channel.id, channel);
} else {
channel.setup(data);
}

client.emit(Constants.Events.CHANNEL_UPDATE, oldChannel, channel);
return {
old: oldChannel,
Expand Down
2 changes: 0 additions & 2 deletions src/client/actions/MessageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class MessageCreateAction extends Action {
}
const lastMessage = messages[messages.length - 1];
channel.lastMessageID = lastMessage.id;
channel.lastMessage = lastMessage;
if (user) {
user.lastMessageID = lastMessage.id;
user.lastMessage = lastMessage;
Expand All @@ -31,7 +30,6 @@ class MessageCreateAction extends Action {
} else {
const message = channel._cacheMessage(new Message(channel, data, client));
channel.lastMessageID = data.id;
channel.lastMessage = message;
if (user) {
user.lastMessageID = data.id;
user.lastMessage = message;
Expand Down
1 change: 1 addition & 0 deletions src/client/rest/RESTManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class RESTManager {
request: apiRequest,
resolve,
reject,
retries: 0,
});
});
}
Expand Down

0 comments on commit 1f799a4

Please sign in to comment.