Skip to content

Commit

Permalink
fix: Keep symbols in actions manager (#9293)
Browse files Browse the repository at this point in the history
fix: keep symbols in actions manager
  • Loading branch information
Jiralite committed Mar 29, 2023
1 parent 3cf4f4b commit 984bd55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 12 additions & 1 deletion packages/discord.js/scripts/generateRequires.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ async function writeWebsocketHandlerImports() {
}

async function writeClientActionImports() {
const lines = ["'use strict';\n", 'class ActionsManager {', ' constructor(client) {', ' this.client = client;\n'];
const lines = [
"'use strict';\n",
'class ActionsManager {',
' // These symbols represent fully built data that we inject at times when calling actions manually.',
' // Action#getUser, for example, will return the injected data (which is assumed to be a built structure)',
' // instead of trying to make it from provided data',
" injectedUser = Symbol('djs.actions.injectedUser');",
" injectedChannel = Symbol('djs.actions.injectedChannel');",
" injectedMessage = Symbol('djs.actions.injectedMessage');\n",
' constructor(client) {',
' this.client = client;\n',
];

const actionsDirectory = new URL('../src/client/actions', import.meta.url);
for (const file of (await readdir(actionsDirectory)).sort()) {
Expand Down
6 changes: 3 additions & 3 deletions packages/discord.js/src/client/actions/ActionsManager.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

class ActionsManager {
// These symbols represent fully built data that we inject at times when calling actions manually. Action#getUser,
// for example, will return the injected data (which is assumed to be a built structure) instead of trying to make it
// from provided data
// These symbols represent fully built data that we inject at times when calling actions manually.
// Action#getUser, for example, will return the injected data (which is assumed to be a built structure)
// instead of trying to make it from provided data
injectedUser = Symbol('djs.actions.injectedUser');
injectedChannel = Symbol('djs.actions.injectedChannel');
injectedMessage = Symbol('djs.actions.injectedMessage');
Expand Down

2 comments on commit 984bd55

@vercel
Copy link

@vercel vercel bot commented on 984bd55 Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 984bd55 Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.