From b8b6be5e34175d893af51eaa8d00da21ef00a9d6 Mon Sep 17 00:00:00 2001 From: iDrunK65 Date: Sat, 3 Jul 2021 08:38:57 +0200 Subject: [PATCH 1/9] fix(embeds): new description limit (#690) --- guide/popular-topics/embeds.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/popular-topics/embeds.md b/guide/popular-topics/embeds.md index 7541b363c..a4f65a045 100644 --- a/guide/popular-topics/embeds.md +++ b/guide/popular-topics/embeds.md @@ -399,7 +399,7 @@ If you want to build the new embed data on a previously sent embed template, mak There are a few limits to be aware of while planning your embeds due to the API's limitations. Here is a quick reference you can come back to: - Embed titles are limited to 256 characters -- Embed descriptions are limited to 2048 characters +- Embed descriptions are limited to 4096 characters - There can be up to 25 fields - A field's name is limited to 256 characters and its value to 1024 characters - The footer text is limited to 2048 characters From 6ab7d3ac4511af5338060616ef9a8baf2e52655c Mon Sep 17 00:00:00 2001 From: Souji Date: Sat, 3 Jul 2021 10:24:16 +0200 Subject: [PATCH 2/9] refactor(intents): improve explanation of intent groups and reading flow (#691) --- guide/popular-topics/intents.md | 64 +++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/guide/popular-topics/intents.md b/guide/popular-topics/intents.md index c4fc46a8c..a43297e73 100644 --- a/guide/popular-topics/intents.md +++ b/guide/popular-topics/intents.md @@ -2,7 +2,7 @@ -Intents are not available in version 11; please update to version 12 of the library if you want to use gateway intents in your bot. +Intents are not available in version 11; please update to version 12 of the library if you want to use gateway intents in your application. @@ -11,35 +11,23 @@ Intents are not available in version 11; please update to version 12 of the libr Version 13 of Discord.js will require you to choose intents (as it uses a new version of Discord's API), it's worthwhile reading this section even if you don't currently want to update, so you know what to do later. ::: -Gateway Intents were introduced by Discord so bot developers can choose which events their bot receives based on which data it needs to function. Intents are named groups of pre-defined WebSocket events, which the Discord.js client will receive. If you omit `DIRECT_MESSAGE_TYPING`, for example, you will no longer receive typing events from direct messages. If you provide no intents, version 12 will receive all events for allowed intents, and version 13 will throw an error. +Discord introduced gateway intents so developers can choose which events their application receives. Intents are named groups of pre-defined WebSocket events, which the discord.js client will receive. -## Privileged Intents - -Discord defines some intents as "privileged" due to the data's sensitive nature. At the time of writing this article, privileged intents are `GUILD_PRESENCES` and `GUILD_MEMBERS`. If your bot is not verified and in less than 100 guilds, you can enable privileged gateway intents in the [Discord Developer Portal](https://discord.com/developers/applications) under "Privileged Gateway Intents" in the "Bot" section. If your bot is already verified or is about to [require verification](https://support.discord.com/hc/en-us/articles/360040720412), you need to request privileged intents. You can do this in your verification application or by reaching out to Discord's [support team](https://dis.gd/contact), including why you require access to each privileged intent. - -Before storming off and doing so, you should stop and carefully think about if you need these events. Discord made them opt-in so users across the platform can enjoy a higher level of [privacy](https://en.wikipedia.org/wiki/Privacy_by_design). Presences can expose quite a bit of personal information through games and online times, for example. You might find it sufficient for your bot to have a little less information about all guild members at all times, considering you still get the command author as GuildMember from the command execution message and can fetch targets separately. - -### Problems in version 12 - -`GUILD_MEMBERS` -- The client events `"guildMemberAdd"`, `"guildMemberRemove"`, `"guildMemberUpdate"` do not emit -- `Guild#memberCount` returns the member count as of ready -- Fetching members times out - -`GUILD_PRESENCES` -- Member caches are empty *(or only have very few entries)* -- User cache is empty *(or has only very few entries)* -- All members appear to be offline +## Enabling Intents -### Error: Disallowed Intents +You can find an up-to-date list of all available intents on the [Discord Developer Documention](https://discord.com/developers/docs/topics/gateway#list-of-intents) in the following format: -Should you receive an error prefixed with `[DISALLOWED_INTENTS]`, please review your developer dashboard settings for all privileged intents you use. This topic's official documentation is on the [Discord API documentation](https://discord.com/developers/docs/topics/gateway#privileged-intents). +``` +INTENT_NAME (0 << 0) + - EVENT_NAME + - OTHER_EVENT_NAME +``` -## Enabling Intents +If you want to listen to `'eventName'` or `'otherEventName'` in discord.js you need to supply `INTENT_NAME` (`0 << 0` is the bit representation for this intent). -To specify which events you want your bot to receive, first think about which events your bot needs to operate. Then select the required intents and add them to your client constructor, as shown below. +Take a look at your event handlers (like `client.on('message', ...)`, `client.on('inviteCreate', ...)`) and figure out which intent corresponds to each event. Note that discord.js event names follow the lowerCamelCase convention, while discord uses MACRO_CASE for WebSocket events. Discord.js also emits both `MESSAGE_CREATE` for direct and guild messages in the `'message'` client event. -All gateway intents, and the events belonging to each, are listed on the [Discord API documentation](https://discord.com/developers/docs/topics/gateway#list-of-intents). If you need your bot to receive messages (`MESSAGE_CREATE` - `"message"` in discord.js), you need the `GUILD_MESSAGES` intent. If you want your bot to post welcome messages for new members (`GUILD_MEMBER_ADD` - `"guildMemberAdd"` in discord.js), you need the `GUILD_MEMBERS` intent, and so on. +In the case of `'message'` for guilds you will find `MESSAGE_CREATE` to be listed under the `GUILD_MESSAGES` intent and so on. After you found all intents, provide them to the Client constructor as shown below: ```js const { Client } = require('discord.js'); @@ -49,14 +37,36 @@ const client = new Client({ ws: { intents: ['GUILDS', 'GUILD_MESSAGES'] } }); ::: warning Note that discord.js relies heavily on caching to provide its functionality. Some methods that seem unrelated might stop working if certain events do not arrive. -Please make sure to provide the list of gateway intents and partials you use in your Client constructor when asking for support on our [Discord server](https://discord.gg/bRCvFy9) or [GitHub repository](https://github.com/discordjs/discord.js). +Please make sure to provide the list of gateway intents and partials you use in your Client constructor when asking for support on our [Discord server](https://discord.gg/djs) or [GitHub repository](https://github.com/discordjs/discord.js). ::: +## Privileged Intents + +Discord defines some intents as "privileged" due to the data's sensitive nature. If your application is not verified and its bot is in less than 100 guilds, you can enable privileged gateway intents in the [Discord Developer Portal](https://discord.com/developers/applications) under "Privileged Gateway Intents" in the "Bot" section. If your application is already verified or is about to [require verification](https://support.discord.com/hc/en-us/articles/360040720412), you need to request privileged intents. You can do this in your verification application or by reaching out to Discord's [support team](https://dis.gd/contact), including an explanation as to why you require access to each privileged intent. + +Before storming off and doing so, you should stop and carefully think about if you need these events. Discord made them opt-in so users across the platform can enjoy a higher level of [privacy](https://en.wikipedia.org/wiki/Privacy_by_design). Presences can expose quite a bit of personal information through games and online times, for example. You might find it sufficient for your application to have a little less information about all guild members at all times, considering you still get the command author as GuildMember from the command execution message and can fetch targets separately. + +### Error: Disallowed Intents + +Should you receive an error prefixed with `[DISALLOWED_INTENTS]`, please review your developer dashboard settings for all privileged intents you use. This topic's official documentation is on the [Discord API documentation](https://discord.com/developers/docs/topics/gateway#privileged-intents). + +### Problems in version 12 + +`GUILD_MEMBERS` +- The client events `"guildMemberAdd"`, `"guildMemberRemove"`, `"guildMemberUpdate"` do not emit +- `Guild#memberCount` returns the member count as of ready +- Fetching members times out + +`GUILD_PRESENCES` +- Member caches are empty *(or only have very few entries)* +- User cache is empty *(or has only very few entries)* +- All members appear to be offline + ## The Intents Bitfield Discord.js provides a utility structure `Intents` which you can use to modify bitfields easily. The class also features static attributes for all (`Intents.ALL`), privileged (`Intents.PRIVILEGED`), and non-privileged (`Intents.NON_PRIVILEGED`) intents. -These primarily serve as templates. While using them directly is possible, we strongly discourage you from using them that way. Instead, think about which events your bot strictly needs access to based on the functionality you want it to provide. +These primarily serve as templates. While using them directly is possible, we strongly discourage you from doing so. Instead, think about which events your bot strictly needs access to based on the functionality you want it to provide. You can use the `.add()` and `.remove()` methods to add or remove flags (Intent string literals representing a certain bit) and modify the bitfield. You can provide single flags as well as an array or bitfield. To use a set of intents as a template you can pass it to the constructor. A few approaches are demonstrated below (note that the empty constructor `new Intents()` creates an empty Intents instance, representing no intents or the bitfield `0`): @@ -76,7 +86,7 @@ const otherIntents2 = new Intents(32509); otherIntents2.remove(4096, 512); ``` -If you want to view the built flags you can utilize the `.toArray()`, `.serialize()` and `.missing()` methods. The first returns an array of flags represented in this bitfield, the second an object mapping all possible flag values to a boolean, based on their representation in this bitfield. The third method can view the flags not represented (you use it by passing a bitfield of specific intents to check for). +If you want to view the built flags you can utilize the `.toArray()` and `.serialize()` methods. The first returns an array of flags represented in this bitfield, the second an object mapping all possible flag values to a boolean, based on their representation in this bitfield. ## More on Bitfields From f71504165275d78b617c7940861cf199d7f44e84 Mon Sep 17 00:00:00 2001 From: almostSouji Date: Mon, 5 Jul 2021 17:02:22 +0200 Subject: [PATCH 3/9] refactor(intents): remove mention of computed groupings --- guide/popular-topics/intents.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/guide/popular-topics/intents.md b/guide/popular-topics/intents.md index a43297e73..5b66c9876 100644 --- a/guide/popular-topics/intents.md +++ b/guide/popular-topics/intents.md @@ -64,11 +64,9 @@ Should you receive an error prefixed with `[DISALLOWED_INTENTS]`, please review ## The Intents Bitfield -Discord.js provides a utility structure `Intents` which you can use to modify bitfields easily. The class also features static attributes for all (`Intents.ALL`), privileged (`Intents.PRIVILEGED`), and non-privileged (`Intents.NON_PRIVILEGED`) intents. +Discord.js provides a utility structure `Intents` which you can use to modify bitfields easily. -These primarily serve as templates. While using them directly is possible, we strongly discourage you from doing so. Instead, think about which events your bot strictly needs access to based on the functionality you want it to provide. - -You can use the `.add()` and `.remove()` methods to add or remove flags (Intent string literals representing a certain bit) and modify the bitfield. You can provide single flags as well as an array or bitfield. To use a set of intents as a template you can pass it to the constructor. A few approaches are demonstrated below (note that the empty constructor `new Intents()` creates an empty Intents instance, representing no intents or the bitfield `0`): +You can use the `.add()` and `.remove()` methods to add or remove flags (Intent string literals representing a certain bit) and modify the bitfield. You can provide single flags as well as an array or bitfield. To use a set of intents as a template you can pass it to the constructor. Note that the empty constructor `new Intents()` creates an empty Intents instance, representing no intents or the bitfield `0`: ```js const { Client, Intents } = require('discord.js'); @@ -77,9 +75,9 @@ myIntents.add('GUILD_PRESENCES', 'GUILD_MEMBERS'); const client = new Client({ ws: { intents: myIntents } }); -// more examples about manipulating the bitfield +// other examples: -const otherIntents = new Intents(Intents.NON_PRIVILEGED); +const otherIntents = new Intents(['GUILDS', 'GUILD_MESSAGES', 'DIRECT_MESSAGES']); otherIntents.remove(['DIRECT_MESSAGES', 'GUILD_MESSAGES']); const otherIntents2 = new Intents(32509); From eaf23ccad77474d7e7ce3aa714f838e82bb34b72 Mon Sep 17 00:00:00 2001 From: JPBM135 <67063134+JPBM135@users.noreply.github.com> Date: Thu, 8 Jul 2021 20:50:49 -0300 Subject: [PATCH 4/9] feat(preparations): Update ESLint `ecmaVersion` to 2021 (#689) --- guide/preparations/setting-up-a-linter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/preparations/setting-up-a-linter.md b/guide/preparations/setting-up-a-linter.md index 19cc50765..a2f74a3af 100644 --- a/guide/preparations/setting-up-a-linter.md +++ b/guide/preparations/setting-up-a-linter.md @@ -67,7 +67,7 @@ Alternatively, if you don't want to go through everything one by one on your own "es6": true }, "parserOptions": { - "ecmaVersion": 2019 + "ecmaVersion": 2021 }, "rules": { "brace-style": ["error", "stroustrup", { "allowSingleLine": true }], From 4c1fbd5b7bfa8df069627b7687f2e27de48559e1 Mon Sep 17 00:00:00 2001 From: Justin Date: Sun, 25 Jul 2021 02:41:16 +0800 Subject: [PATCH 5/9] chore(.github): Update d.js server invite link (#724) --- .github/ISSUE_TEMPLATE/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index ba255f49f..f09ff7984 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,11 +1,11 @@ blank_issues_enabled: false contact_links: - name: Discord server - url: https://discord.gg/bRCvFy9 + url: https://discord.gg/djs about: Visit our Discord server for questions and support requests. - name: Guide discussion boards url: https://github.com/discordjs/discord.js/discussions about: Ask questions and receive answers. - name: Discord.js issues url: https://github.com/discordjs/discord.js/issues/new/choose - about: Issue tracker for the library discord.js. \ No newline at end of file + about: Issue tracker for the library discord.js. From 312b30f49cac9a3fa4516a5cc08a5295f065e6a7 Mon Sep 17 00:00:00 2001 From: Justin Date: Sun, 25 Jul 2021 02:44:12 +0800 Subject: [PATCH 6/9] chore: Update license year (#723) --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index b2cacf6f7..ee37f1b8e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 - 2020 Sanctuary +Copyright (c) 2017 - 2021 Sanctuary Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From bf807cdd55aed02a896a51d50060c48f2a03b952 Mon Sep 17 00:00:00 2001 From: Sanctuary Date: Sun, 1 Aug 2021 15:05:41 -0400 Subject: [PATCH 7/9] chore: Remove Algolia search and Google Analytics --- guide/.vuepress/config.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/guide/.vuepress/config.js b/guide/.vuepress/config.js index 25cb0e879..4ee3b2f53 100644 --- a/guide/.vuepress/config.js +++ b/guide/.vuepress/config.js @@ -61,13 +61,4 @@ for (const group of Object.values(config.themeConfig.sidebar)) { } } -if (process.env.NODE_ENV === 'production') { - config.themeConfig.algolia = { - apiKey: 'c8d9361fb8403f7c5111887e0edf4b5e', - indexName: 'discordjs', - }; - - config.plugins.push(['@vuepress/google-analytics', { ga: 'UA-108513187-1' }]); -} - module.exports = config; From 87165136bc2122b9c4c6e22a84e465ffd442831c Mon Sep 17 00:00:00 2001 From: Sanctuary Date: Sun, 1 Aug 2021 15:39:52 -0400 Subject: [PATCH 8/9] refactor: Rewrite EOLNotice as VersionNotification component --- ...{EOLNotice.vue => VersionNotification.vue} | 41 +++++++++++-------- guide/.vuepress/config.js | 2 +- 2 files changed, 26 insertions(+), 17 deletions(-) rename guide/.vuepress/components/{EOLNotice.vue => VersionNotification.vue} (50%) diff --git a/guide/.vuepress/components/EOLNotice.vue b/guide/.vuepress/components/VersionNotification.vue similarity index 50% rename from guide/.vuepress/components/EOLNotice.vue rename to guide/.vuepress/components/VersionNotification.vue index bfa0203c6..093f2d7aa 100644 --- a/guide/.vuepress/components/EOLNotice.vue +++ b/guide/.vuepress/components/VersionNotification.vue @@ -1,12 +1,18 @@ @@ -23,13 +29,16 @@ export default { }; }, computed: { - showNotice() { - return semver.satisfies(semver.coerce('11.x'), this.selectedBranch) && (!this.hideUntil || Date.now() > parseInt(this.hideUntil)); + showNotification() { + return !this.hideUntil || Date.now() > parseInt(this.hideUntil); + }, + v11() { + return semver.satisfies(semver.coerce('11.x'), this.selectedBranch); }, }, mounted() { eventBus.$on('branch-update', this.updateBranch); - this.hideUntil = localStorage.getItem('eol-notice-expiration'); + this.hideUntil = localStorage.getItem('version-notification-expiration'); }, destroyed() { eventBus.$off('branch-update', this.updateBranch); @@ -38,14 +47,14 @@ export default { dismiss() { const expirationTimestamp = Date.now() + (7 * 60 * 60 * 24 * 1000); this.hideUntil = expirationTimestamp; - localStorage.setItem('eol-notice-expiration', expirationTimestamp); + localStorage.setItem('version-notification-expiration', expirationTimestamp); }, }, }; diff --git a/guide/.vuepress/config.js b/guide/.vuepress/config.js index 4ee3b2f53..8dc88ff0f 100644 --- a/guide/.vuepress/config.js +++ b/guide/.vuepress/config.js @@ -51,7 +51,7 @@ const config = { }, }, }, - globalUIComponents: ['EOLNotice'], + globalUIComponents: ['VersionNotification'], }; for (const group of Object.values(config.themeConfig.sidebar)) { From 17295e98fc9a8fca92ca2064c73474347f7f7769 Mon Sep 17 00:00:00 2001 From: Sanctuary Date: Sat, 14 Aug 2021 18:10:20 -0400 Subject: [PATCH 9/9] feat: Add v13 guide link to nav bar --- guide/.vuepress/config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/guide/.vuepress/config.js b/guide/.vuepress/config.js index 8dc88ff0f..0b592fc7b 100644 --- a/guide/.vuepress/config.js +++ b/guide/.vuepress/config.js @@ -37,6 +37,10 @@ const config = { text: 'Commando', link: '/commando/', }, + { + text: 'v13', + link: 'https://discordjs.guide/', + }, { text: 'Discord.js Documentation', link: 'https://discord.js.org/#/docs/main/stable/general/welcome',