meocord 4.0.0-beta.5 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +121 -0
- package/dist/cjs/_shared/{theme-C8w8ivsR.cjs → theme-Bt2Xw_fH.cjs} +35 -6
- package/dist/cjs/common/index.cjs +1 -1
- package/dist/cjs/core/index.cjs +3 -1
- package/dist/esm/common/logger.js +34 -6
- package/dist/esm/core/meocord.app.js +3 -1
- package/dist/esm/package.json.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,126 @@
|
|
|
1
1
|
# meocord
|
|
2
2
|
|
|
3
|
+
## 4.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#290](https://github.com/meocord/meocord/pull/290) [`6e6e68e`](https://github.com/meocord/meocord/commit/6e6e68eff696481b40810b2bf713f2bec769b564) Thanks [@l7aromeo](https://github.com/l7aromeo)! - `Logger` prints objects as `console.log` does, and redacts the bot's credentials from everything it prints: non-enumerable properties no longer appear, and objects print four levels deep.
|
|
8
|
+
|
|
9
|
+
- Nested data a bot logs, such as a payload or its settings, still shows in full, and a discord.js structure prints a few hundred lines instead of everything it reaches.
|
|
10
|
+
- An error prints as before: its stack, its own properties such as `code`, its `cause`, and an `AggregateError`'s errors. Its message and stack are no longer printed a second time below it.
|
|
11
|
+
- Nothing to change in your code.
|
|
12
|
+
|
|
13
|
+
## 4.0.0
|
|
14
|
+
|
|
15
|
+
MeoCord 4 builds with Rsbuild instead of webpack, requires Node.js 22.13 and dotenv 18, and can
|
|
16
|
+
deploy a bot without `node_modules`. Most bots need two changes; see the
|
|
17
|
+
[migration guide](https://github.com/l7aromeo/meocord/blob/main/docs/MIGRATING.md).
|
|
18
|
+
|
|
19
|
+
### Major Changes
|
|
20
|
+
|
|
21
|
+
- [#22](https://github.com/l7aromeo/meocord/pull/22) [`4deb96f`](https://github.com/l7aromeo/meocord/commit/4deb96fd73f86a29c46b9bb080c13e6267246cb1) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Build with [Rsbuild](https://rsbuild.rs) instead of webpack. Production builds are several times
|
|
22
|
+
faster, and webpack and its four loader and plugin packages are no longer installed with MeoCord.
|
|
23
|
+
The output layout is unchanged: `dist/main.js`, and assets under `dist/assets/` with the same names.
|
|
24
|
+
Production source maps now list sources as `../src/...` paths instead of `webpack://` URLs.
|
|
25
|
+
|
|
26
|
+
**Breaking:** the `webpack` hook in `meocord.config.ts` is replaced by `rsbuild`, which receives
|
|
27
|
+
Rsbuild's configuration. A config that still declares `webpack` stops the build with a message
|
|
28
|
+
saying so. `MeoCordWebpackConfig` is removed; import `RsbuildConfig` from `meocord/interface`
|
|
29
|
+
instead. The [migration guide](https://github.com/l7aromeo/meocord/blob/main/docs/MIGRATING.md#2-replace-the-webpack-hook-with-rsbuild) shows where each
|
|
30
|
+
webpack setting goes.
|
|
31
|
+
|
|
32
|
+
- [#44](https://github.com/l7aromeo/meocord/pull/44) [`e48472e`](https://github.com/l7aromeo/meocord/commit/e48472e9ffee2f0371a7a2a71a4063e99ce61674) Thanks [@l7aromeo](https://github.com/l7aromeo)! - **Breaking:** `meocord/decorator` exports only the decorators. The routing helpers it also exported
|
|
33
|
+
— `getCommandMap`, `getMessageHandlers`, `getReactionHandlers`, `getAutocompleteHandlers`,
|
|
34
|
+
`findAmbiguousRoutes` and `PARAM_SEPARATOR` — are internal to MeoCord now. See the
|
|
35
|
+
[migration guide](https://github.com/l7aromeo/meocord/blob/main/docs/MIGRATING.md#internal-helpers-are-no-longer-exported).
|
|
36
|
+
|
|
37
|
+
- [#19](https://github.com/l7aromeo/meocord/pull/19) [`204c7be`](https://github.com/l7aromeo/meocord/commit/204c7bec74886c931732cb771d9178b47fbec5e8) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Require dotenv 18. The `dotenv` peer dependency moves from `^17.4.2` to `^18.0.3`, so install
|
|
38
|
+
`dotenv@18` alongside MeoCord 4. No application code changes — `import 'dotenv/config'` behaves
|
|
39
|
+
the same. See the [migration guide](https://github.com/l7aromeo/meocord/blob/main/docs/MIGRATING.md#1-upgrade-dotenv-to-18).
|
|
40
|
+
|
|
41
|
+
- [#33](https://github.com/l7aromeo/meocord/pull/33) [`21b06ae`](https://github.com/l7aromeo/meocord/commit/21b06ae6810cfe203abadcadc6f7b7247c7b305b) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Require Node.js 22.13 or newer, up from 22.0. A built bot loads its compiled config with `require()`
|
|
42
|
+
of an ES module. Node 22.12 runs that without a flag but still warns on every start and crashes on a
|
|
43
|
+
config that throws; 22.13 is the first 22 release that does neither. Bun is unaffected. See the
|
|
44
|
+
[migration guide](https://github.com/l7aromeo/meocord/blob/main/docs/MIGRATING.md#before-you-start-nodejs-2213).
|
|
45
|
+
|
|
46
|
+
- [#36](https://github.com/l7aromeo/meocord/pull/36) [`45e564e`](https://github.com/l7aromeo/meocord/commit/45e564e6baff17313037372ec56baa1711a3584c) Thanks [@l7aromeo](https://github.com/l7aromeo)! - **Breaking:** `app.start()` rejects when the login fails. It logged the error and resolved, so a bot
|
|
47
|
+
with an invalid token went on to log "Application started" and exit with code 0, which Docker's
|
|
48
|
+
`restart: on-failure`, systemd and CI all read as success. It now sets the exit code to 1 before
|
|
49
|
+
rejecting, so a bot that fails to log in exits 1 with its entry point unchanged. See the
|
|
50
|
+
[migration guide](https://github.com/l7aromeo/meocord/blob/main/docs/MIGRATING.md#4-build-and-start).
|
|
51
|
+
|
|
52
|
+
### Minor Changes
|
|
53
|
+
|
|
54
|
+
- [#22](https://github.com/l7aromeo/meocord/pull/22) [`4deb96f`](https://github.com/l7aromeo/meocord/commit/4deb96fd73f86a29c46b9bb080c13e6267246cb1) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Add `bundleDependencies`, which puts everything a bot needs inside `dist`, so it deploys without
|
|
55
|
+
`node_modules` or an install step. Plain JavaScript dependencies are bundled into `main.js`. Native
|
|
56
|
+
addons such as `sharp` are found while building and copied, with their platform binary, into
|
|
57
|
+
`dist/node_modules` — nothing has to be listed. Only binaries for the platform building are copied,
|
|
58
|
+
whichever package manager installed them.
|
|
59
|
+
|
|
60
|
+
A build carrying native addons records its platform in `dist/meocord.platform.json`, and a bot
|
|
61
|
+
started on another platform stops before going online with a message naming both. Build on the
|
|
62
|
+
platform you deploy to. See
|
|
63
|
+
[Self-contained builds](https://github.com/l7aromeo/meocord#self-contained-builds).
|
|
64
|
+
|
|
65
|
+
- [#47](https://github.com/l7aromeo/meocord/pull/47) [`9652436`](https://github.com/l7aromeo/meocord/commit/965243660323277827a64851f28da9cda2c2fe0c) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Add `resolveRoute` and `findRouteConflicts` to `meocord/testing`, for testing which handler a
|
|
66
|
+
component's customId reaches. `resolveRoute(App, { type, customId })` gives the answer dispatch
|
|
67
|
+
gives — across every controller the app registers, for that component type, most specific pattern
|
|
68
|
+
first — as the controller, the handler method and its name, and the captured params, or `undefined`.
|
|
69
|
+
`findRouteConflicts(App)` returns the pattern pairs that can match the same customId, which MeoCord
|
|
70
|
+
otherwise only warns about at startup. Both read decorator metadata only, and dispatch runs on the
|
|
71
|
+
same matcher.
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- [#22](https://github.com/l7aromeo/meocord/pull/22) [`4deb96f`](https://github.com/l7aromeo/meocord/commit/4deb96fd73f86a29c46b9bb080c13e6267246cb1) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Read `meocord.config.ts` on every build. `meocord build` read the compiled `dist/meocord.config.mjs`
|
|
76
|
+
left by the previous build, so a config edit took effect one build late, and the watcher's reload
|
|
77
|
+
on a config change reloaded nothing.
|
|
78
|
+
|
|
79
|
+
- [#22](https://github.com/l7aromeo/meocord/pull/22) [`4deb96f`](https://github.com/l7aromeo/meocord/commit/4deb96fd73f86a29c46b9bb080c13e6267246cb1) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Start the bot with `bun --no-install` from `meocord start`. Without it, bun downloads any package it
|
|
80
|
+
cannot find while the bot runs, which a bot deployed without `node_modules` would do in
|
|
81
|
+
production. If you start `dist/main.js` with bun yourself, pass the flag too.
|
|
82
|
+
|
|
83
|
+
- [#37](https://github.com/l7aromeo/meocord/pull/37) [`a9452c2`](https://github.com/l7aromeo/meocord/commit/a9452c256beace70141bb87ed33c693d14064d14) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Type the CommonJS build as CommonJS. Every entry point's `require` condition resolved to the ESM
|
|
84
|
+
declarations, so a CommonJS TypeScript project was told `meocord/core` is an ES module it cannot
|
|
85
|
+
`require`, even with `skipLibCheck`. Each entry now ships `.d.cts` declarations for `require`, and
|
|
86
|
+
`meocord/eslint` types its `module.exports` array as what `require` returns.
|
|
87
|
+
|
|
88
|
+
- [#33](https://github.com/l7aromeo/meocord/pull/33) [`21b06ae`](https://github.com/l7aromeo/meocord/commit/21b06ae6810cfe203abadcadc6f7b7247c7b305b) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Load the compiled config without a transpiler. A built bot reads `dist/meocord.config.mjs` with
|
|
89
|
+
`require()` and no longer falls back to `meocord.config.ts` when it is missing, so jiti stays out of
|
|
90
|
+
a bot bundled with `bundleDependencies`. `meocord build` fails when the config does not compile,
|
|
91
|
+
instead of warning and producing a bot that cannot start.
|
|
92
|
+
|
|
93
|
+
- [#35](https://github.com/l7aromeo/meocord/pull/35) [`b93a771`](https://github.com/l7aromeo/meocord/commit/b93a771b19664345fec4222d5a2c29dcf5b31a0d) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Generate code that passes a new application's own `lint`. A generated guard failed `tsc` and ESLint
|
|
94
|
+
— `GuardInterface` imported as a value, and an unused `context` parameter — and generated message and
|
|
95
|
+
reaction controllers imported names they never used, which only the application's ESLint, run in the
|
|
96
|
+
background after generating, removed. New applications also typecheck `meocord.config.ts`: the
|
|
97
|
+
template's `tsconfig.json` includes it instead of excluding it, so a type error in the config fails
|
|
98
|
+
`lint`, and editors resolve `paths` aliases imported there. `noEmit` stays on, so `tsc` writes nothing
|
|
99
|
+
beside it.
|
|
100
|
+
|
|
101
|
+
- [#25](https://github.com/l7aromeo/meocord/pull/25) [`2179f85`](https://github.com/l7aromeo/meocord/commit/2179f85c2912d45e3fefbf996ca267c19a1a773c) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Stop `meocord generate` overwriting files. Slash, context-menu and primary entry point controllers
|
|
102
|
+
all wrote one shared `builders/sample.builder.ts`, so generating a second controller replaced a
|
|
103
|
+
builder you had already edited. Each controller now gets its own `builders/<name>.builder.ts`
|
|
104
|
+
exporting `<Name>CommandBuilder`, and registers a command named after it — `admin/ban` registers
|
|
105
|
+
`admin-ban` — rather than every one registering `sample-slash`. Generating a controller, service or
|
|
106
|
+
guard refuses if any file it would write already exists.
|
|
107
|
+
|
|
108
|
+
- [#40](https://github.com/l7aromeo/meocord/pull/40) [`3629edd`](https://github.com/l7aromeo/meocord/commit/3629eddaf20bd0947d24e5582aa167b2c0ca0d47) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Lint `meocord.config.ts`. The shared ESLint config from `meocord/eslint` ignored it, so the config
|
|
109
|
+
alone skipped the rules every other file follows — unused imports, formatting. It is linted like the
|
|
110
|
+
rest now; the typecheck it already gets is unchanged.
|
|
111
|
+
|
|
112
|
+
- [#24](https://github.com/l7aromeo/meocord/pull/24) [`5e2a54b`](https://github.com/l7aromeo/meocord/commit/5e2a54b67a1f9f51c4c3a3e8cf51247de2ac2528) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Type `deleted` on `createMockMessage()`. The mock tracks and documents it, but it was missing from
|
|
113
|
+
the type, so `message.deleted` did not compile.
|
|
114
|
+
|
|
115
|
+
- [#24](https://github.com/l7aromeo/meocord/pull/24) [`5e2a54b`](https://github.com/l7aromeo/meocord/commit/5e2a54b67a1f9f51c4c3a3e8cf51247de2ac2528) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Accept slash command builders that add options. `@CommandBuilder(CommandType.SLASH)` rejected
|
|
116
|
+
`new SlashCommandBuilder().addStringOption(...)`, whose type narrows to
|
|
117
|
+
`SlashCommandOptionsOnlyBuilder`, so the most common builder — one command with an option — did
|
|
118
|
+
not compile.
|
|
119
|
+
|
|
120
|
+
- [#21](https://github.com/l7aromeo/meocord/pull/21) [`bebf116`](https://github.com/l7aromeo/meocord/commit/bebf1168466595546017a317b62acd3707ff2d1c) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Generate applications with current test tooling: vitest and `@vitest/coverage-istanbul` 5,
|
|
121
|
+
`unplugin-swc` 2, and current eslint, prettier and typescript-eslint. A new application's
|
|
122
|
+
`test:coverage` no longer fails on its decorated entry files.
|
|
123
|
+
|
|
3
124
|
## 4.0.0-beta.5
|
|
4
125
|
|
|
5
126
|
### Minor Changes
|
|
@@ -31,7 +31,7 @@ let configLoaded = false;
|
|
|
31
31
|
try {
|
|
32
32
|
// Called through a variable so a bundler does not try to resolve the path while building the
|
|
33
33
|
// application; the file is only there once the build is done.
|
|
34
|
-
const load = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('_shared/theme-
|
|
34
|
+
const load = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('_shared/theme-Bt2Xw_fH.cjs', document.baseURI).href)));
|
|
35
35
|
const loaded = load(compiledPath);
|
|
36
36
|
return loaded.default ?? loaded;
|
|
37
37
|
} catch (error) {
|
|
@@ -42,6 +42,34 @@ let configLoaded = false;
|
|
|
42
42
|
|
|
43
43
|
dayjs.extend(utc);
|
|
44
44
|
dayjs.extend(timezone);
|
|
45
|
+
/**
|
|
46
|
+
* How deep an object argument prints: nested data a bot logs, such as a payload or its settings, shows in full, while
|
|
47
|
+
* a discord.js structure, which reaches its client and every cache, stops at a few hundred lines.
|
|
48
|
+
*/ const OBJECT_DEPTH = 4;
|
|
49
|
+
/** What a value registered with {@link hideInLogs} prints as. */ const REDACTED = '[redacted]';
|
|
50
|
+
/**
|
|
51
|
+
* The shortest value registered: a bot's credential is far longer, and a short value, such as a test's placeholder,
|
|
52
|
+
* would replace ordinary words in every line.
|
|
53
|
+
*/ const MIN_HIDDEN_LENGTH = 16;
|
|
54
|
+
const hiddenValues = new Set();
|
|
55
|
+
/**
|
|
56
|
+
* Keeps `value`, such as the bot's credential, out of every line Logger prints from now on, whatever object, string
|
|
57
|
+
* or error carries it: as given, trimmed, and without the `Bot ` or `Bearer ` prefix discord.js strips.
|
|
58
|
+
*/ function hideInLogs(value) {
|
|
59
|
+
if (typeof value !== 'string') return;
|
|
60
|
+
const trimmed = value.trim();
|
|
61
|
+
for (const form of [
|
|
62
|
+
trimmed,
|
|
63
|
+
trimmed.replace(/^(Bot|Bearer)\s*/i, '')
|
|
64
|
+
]){
|
|
65
|
+
if (form.length >= MIN_HIDDEN_LENGTH) hiddenValues.add(form);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const redact = (text)=>{
|
|
69
|
+
let out = text;
|
|
70
|
+
for (const value of hiddenValues)out = out.replaceAll(value, REDACTED);
|
|
71
|
+
return out;
|
|
72
|
+
};
|
|
45
73
|
class Logger {
|
|
46
74
|
log(...args) {
|
|
47
75
|
this.logWithContext('log', args);
|
|
@@ -63,12 +91,11 @@ class Logger {
|
|
|
63
91
|
}
|
|
64
92
|
formatMessage(message, logType) {
|
|
65
93
|
if (typeof message === 'object' && message !== null) {
|
|
94
|
+
// As console.log inspects: without non-enumerable properties, which discord.js uses to keep its internals out of logs
|
|
66
95
|
return node_util.inspect(message, {
|
|
67
|
-
|
|
68
|
-
depth: null,
|
|
96
|
+
depth: OBJECT_DEPTH,
|
|
69
97
|
colors: true,
|
|
70
|
-
compact: false
|
|
71
|
-
showProxy: true
|
|
98
|
+
compact: false
|
|
72
99
|
});
|
|
73
100
|
}
|
|
74
101
|
return (this.colorMap[logType] || ((msg)=>msg))(message);
|
|
@@ -76,6 +103,7 @@ class Logger {
|
|
|
76
103
|
logWithContext(logLevel, messages) {
|
|
77
104
|
if (messages.length === 0) return;
|
|
78
105
|
const config = loadMeoCordConfig();
|
|
106
|
+
hideInLogs(config?.discordToken);
|
|
79
107
|
const logType = logLevel.toUpperCase();
|
|
80
108
|
const applyColor = this.colorMap[logType] || ((msg)=>msg);
|
|
81
109
|
const formattedMessages = messages.map((message)=>this.formatMessage(message, logType));
|
|
@@ -90,7 +118,7 @@ class Logger {
|
|
|
90
118
|
coloredContext,
|
|
91
119
|
...formattedMessages
|
|
92
120
|
].filter((log)=>!!log);
|
|
93
|
-
console[logLevel](...logTexts);
|
|
121
|
+
console[logLevel](...logTexts.map(redact));
|
|
94
122
|
}
|
|
95
123
|
constructor(context){
|
|
96
124
|
this.context = context;
|
|
@@ -113,4 +141,5 @@ Theme.warningColor = '#FFC107';
|
|
|
113
141
|
|
|
114
142
|
exports.Logger = Logger;
|
|
115
143
|
exports.Theme = Theme;
|
|
144
|
+
exports.hideInLogs = hideInLogs;
|
|
116
145
|
exports.loadMeoCordConfig = loadMeoCordConfig;
|
package/dist/cjs/core/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require('reflect-metadata');
|
|
4
4
|
var inversify = require('inversify');
|
|
5
5
|
var discord_js = require('discord.js');
|
|
6
|
-
var theme = require('../_shared/theme-
|
|
6
|
+
var theme = require('../_shared/theme-Bt2Xw_fH.cjs');
|
|
7
7
|
var controller_decorator = require('../_shared/controller.decorator-DnKZ29W4.cjs');
|
|
8
8
|
var lodashEs = require('lodash-es');
|
|
9
9
|
var enum_index = require('../enum/index.cjs');
|
|
@@ -467,6 +467,8 @@ class MeoCordApp {
|
|
|
467
467
|
this.isShuttingDown = false;
|
|
468
468
|
this.activityInterval = null;
|
|
469
469
|
this.controllerInstancesCache = new Map();
|
|
470
|
+
// First, so nothing logged from here on, before login or after, prints it
|
|
471
|
+
theme.hideInLogs(discordToken);
|
|
470
472
|
this.bot = this.discordClient;
|
|
471
473
|
process.on('SIGINT', ()=>this.gracefulShutdown());
|
|
472
474
|
process.on('SIGTERM', ()=>this.gracefulShutdown());
|
|
@@ -7,6 +7,34 @@ import chalk from 'chalk';
|
|
|
7
7
|
|
|
8
8
|
dayjs.extend(utc);
|
|
9
9
|
dayjs.extend(timezone);
|
|
10
|
+
/**
|
|
11
|
+
* How deep an object argument prints: nested data a bot logs, such as a payload or its settings, shows in full, while
|
|
12
|
+
* a discord.js structure, which reaches its client and every cache, stops at a few hundred lines.
|
|
13
|
+
*/ const OBJECT_DEPTH = 4;
|
|
14
|
+
/** What a value registered with {@link hideInLogs} prints as. */ const REDACTED = '[redacted]';
|
|
15
|
+
/**
|
|
16
|
+
* The shortest value registered: a bot's credential is far longer, and a short value, such as a test's placeholder,
|
|
17
|
+
* would replace ordinary words in every line.
|
|
18
|
+
*/ const MIN_HIDDEN_LENGTH = 16;
|
|
19
|
+
const hiddenValues = new Set();
|
|
20
|
+
/**
|
|
21
|
+
* Keeps `value`, such as the bot's credential, out of every line Logger prints from now on, whatever object, string
|
|
22
|
+
* or error carries it: as given, trimmed, and without the `Bot ` or `Bearer ` prefix discord.js strips.
|
|
23
|
+
*/ function hideInLogs(value) {
|
|
24
|
+
if (typeof value !== 'string') return;
|
|
25
|
+
const trimmed = value.trim();
|
|
26
|
+
for (const form of [
|
|
27
|
+
trimmed,
|
|
28
|
+
trimmed.replace(/^(Bot|Bearer)\s*/i, '')
|
|
29
|
+
]){
|
|
30
|
+
if (form.length >= MIN_HIDDEN_LENGTH) hiddenValues.add(form);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const redact = (text)=>{
|
|
34
|
+
let out = text;
|
|
35
|
+
for (const value of hiddenValues)out = out.replaceAll(value, REDACTED);
|
|
36
|
+
return out;
|
|
37
|
+
};
|
|
10
38
|
class Logger {
|
|
11
39
|
log(...args) {
|
|
12
40
|
this.logWithContext('log', args);
|
|
@@ -28,12 +56,11 @@ class Logger {
|
|
|
28
56
|
}
|
|
29
57
|
formatMessage(message, logType) {
|
|
30
58
|
if (typeof message === 'object' && message !== null) {
|
|
59
|
+
// As console.log inspects: without non-enumerable properties, which discord.js uses to keep its internals out of logs
|
|
31
60
|
return inspect(message, {
|
|
32
|
-
|
|
33
|
-
depth: null,
|
|
61
|
+
depth: OBJECT_DEPTH,
|
|
34
62
|
colors: true,
|
|
35
|
-
compact: false
|
|
36
|
-
showProxy: true
|
|
63
|
+
compact: false
|
|
37
64
|
});
|
|
38
65
|
}
|
|
39
66
|
return (this.colorMap[logType] || ((msg)=>msg))(message);
|
|
@@ -41,6 +68,7 @@ class Logger {
|
|
|
41
68
|
logWithContext(logLevel, messages) {
|
|
42
69
|
if (messages.length === 0) return;
|
|
43
70
|
const config = loadMeoCordConfig();
|
|
71
|
+
hideInLogs(config?.discordToken);
|
|
44
72
|
const logType = logLevel.toUpperCase();
|
|
45
73
|
const applyColor = this.colorMap[logType] || ((msg)=>msg);
|
|
46
74
|
const formattedMessages = messages.map((message)=>this.formatMessage(message, logType));
|
|
@@ -55,7 +83,7 @@ class Logger {
|
|
|
55
83
|
coloredContext,
|
|
56
84
|
...formattedMessages
|
|
57
85
|
].filter((log)=>!!log);
|
|
58
|
-
console[logLevel](...logTexts);
|
|
86
|
+
console[logLevel](...logTexts.map(redact));
|
|
59
87
|
}
|
|
60
88
|
constructor(context){
|
|
61
89
|
this.context = context;
|
|
@@ -69,4 +97,4 @@ class Logger {
|
|
|
69
97
|
}
|
|
70
98
|
}
|
|
71
99
|
|
|
72
|
-
export { Logger };
|
|
100
|
+
export { Logger, REDACTED, hideInLogs };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApplicationCommandType, SlashCommandBuilder, MessageFlagsBitField } from 'discord.js';
|
|
2
|
-
import { Logger } from '../common/logger.js';
|
|
2
|
+
import { Logger, hideInLogs } from '../common/logger.js';
|
|
3
3
|
import '../common/theme.js';
|
|
4
4
|
import { getCommandMap, PARAM_SEPARATOR, getAutocompleteHandlers, getMessageHandlers, getReactionHandlers } from '../decorator/controller.decorator.js';
|
|
5
5
|
import { sample } from 'lodash-es';
|
|
@@ -450,6 +450,8 @@ class MeoCordApp {
|
|
|
450
450
|
this.isShuttingDown = false;
|
|
451
451
|
this.activityInterval = null;
|
|
452
452
|
this.controllerInstancesCache = new Map();
|
|
453
|
+
// First, so nothing logged from here on, before login or after, prints it
|
|
454
|
+
hideInLogs(discordToken);
|
|
453
455
|
this.bot = this.discordClient;
|
|
454
456
|
process.on('SIGINT', ()=>this.gracefulShutdown());
|
|
455
457
|
process.on('SIGTERM', ()=>this.gracefulShutdown());
|
package/dist/esm/package.json.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meocord",
|
|
3
3
|
"description": "Decorator-based Discord bot framework built on discord.js. Brings NestJS-style controllers, dependency injection, guards, and testing utilities to bot development — with a full CLI and TypeScript-first design.",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=22.13"
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"bin": "./dist/esm/bin/meocord.js",
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
|
-
"url": "git+https://github.com/
|
|
29
|
+
"url": "git+https://github.com/meocord/meocord.git"
|
|
30
30
|
},
|
|
31
|
-
"homepage": "https://
|
|
31
|
+
"homepage": "https://meocord.dev",
|
|
32
32
|
"bugs": {
|
|
33
|
-
"url": "https://github.com/
|
|
33
|
+
"url": "https://github.com/meocord/meocord/issues"
|
|
34
34
|
},
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"exports": {
|