From 4bb876e5f659495d4c17ececeee78af81be3c67f Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Thu, 30 Mar 2023 17:41:04 +0200 Subject: [PATCH] fix: keep symbols in actions manager (#9293) * fix: keep symbols in actions manager Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- scripts/generateRequires.mjs | 13 ++++++++++++- src/client/actions/ActionsManager.js | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/generateRequires.mjs b/scripts/generateRequires.mjs index 4b8ab236ade7..2b3eab7c9c5c 100644 --- a/scripts/generateRequires.mjs +++ b/scripts/generateRequires.mjs @@ -16,7 +16,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 {', + ' constructor(client) {', + ' this.client = client;\n', + ' // 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', + " this.injectedUser = Symbol('djs.actions.injectedUser');", + " this.injectedChannel = Symbol('djs.actions.injectedChannel');", + " this.injectedMessage = Symbol('djs.actions.injectedMessage');\n", + ]; const actionsDirectory = new URL('../src/client/actions', import.meta.url); for (const file of (await readdir(actionsDirectory)).sort()) { diff --git a/src/client/actions/ActionsManager.js b/src/client/actions/ActionsManager.js index 65415dd20af8..1b8ea76c48fa 100644 --- a/src/client/actions/ActionsManager.js +++ b/src/client/actions/ActionsManager.js @@ -4,9 +4,9 @@ class ActionsManager { constructor(client) { this.client = client; - // 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 this.injectedUser = Symbol('djs.actions.injectedUser'); this.injectedChannel = Symbol('djs.actions.injectedChannel'); this.injectedMessage = Symbol('djs.actions.injectedMessage');