meocord 4.1.0 → 4.1.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 +29 -0
- package/dist/cjs/_shared/{controller.decorator-Ds7dj8uZ.cjs → controller.decorator-BywwkU9O.cjs} +8 -1
- package/dist/cjs/_shared/{providers-BSL8vml4.cjs → providers-BMMLp2SN.cjs} +1 -1
- package/dist/cjs/_shared/{sharded-cooldown-store-BGfooXEO.cjs → sharded-cooldown-store-B65iaiAy.cjs} +1 -1
- package/dist/cjs/_shared/{startup-roots-H1ssJOrz.cjs → startup-roots-lFc69AxC.cjs} +3 -3
- package/dist/cjs/_shared/{translate-error-Zwll3hC2.cjs → translate-error-BnM8FbSH.cjs} +1 -1
- package/dist/cjs/common/index.cjs +3 -3
- package/dist/cjs/core/index.cjs +5 -5
- package/dist/cjs/decorator/index.cjs +2 -2
- package/dist/cjs/testing/index.cjs +436 -101
- package/dist/cli.json +1 -1
- package/dist/esm/common/deprecation.js +7 -1
- package/dist/esm/package.json.js +1 -1
- package/dist/esm/testing/discord-defaults.js +43 -5
- package/dist/esm/testing/mock-fn.js +2 -6
- package/dist/esm/testing/mock-interaction.js +389 -87
- package/dist/esm/testing/response.js +3 -2
- package/dist/types/testing/index.d.cts +101 -23
- package/dist/types/testing/index.d.ts +101 -23
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# meocord
|
|
2
2
|
|
|
3
|
+
## 4.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#424](https://github.com/meocord/meocord/pull/424) [`43b9454`](https://github.com/meocord/meocord/commit/43b945447262405f61cced6660cd1d2be881d4b8) Thanks [@l7aromeo](https://github.com/l7aromeo)! - A mock guild's `members.fetch({ user: ids })` now resolves to a collection of each of those members, found in the cache or made the way `members.fetch(id)` makes one. It resolved to an empty collection, so in a test a message command naming two or more members by ID that the guild hasn't cached refused them all as not members of the server, while one such member resolved. Mentioned members were not affected: they come from the message's mentions.
|
|
8
|
+
|
|
9
|
+
- [#422](https://github.com/meocord/meocord/pull/422) [`22daff2`](https://github.com/meocord/meocord/commit/22daff26ac4a694a8d70eace38a4c038d3cef0ef) Thanks [@l7aromeo](https://github.com/l7aromeo)! - `createMockClient()` is typed as a logged-in client, `DeepMocked<Client<true>>`, as the mock already behaves. Pass it straight to `createMockInteraction`, `createMockChannel`, `createMockUser` or `module.init({ ready: { client } })`: each of these failed to compile without a cast, since an interaction's client is `Client<true>`. `client.user` is no longer nullable, so `client.user!.id` can be `client.user.id`. Remove any `as unknown as Client<true>` cast on the mock.
|
|
10
|
+
|
|
11
|
+
- [#430](https://github.com/meocord/meocord/pull/430) [`1d0c0cf`](https://github.com/meocord/meocord/commit/1d0c0cf7d9755e5d24a0f218809a2f95fe403ccc) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Mocks from `meocord/testing` now compute what discord.js computes from them, where they returned `undefined` or a placeholder object:
|
|
12
|
+
|
|
13
|
+
- **Lookups:** a manager's `resolve()` and `resolveId()` read its cache, so `guild.members.resolve(id)` finds a member given to `createMockGuild`. `guild.members.me` is the bot's member, the cached one or one with @everyone. A guild's roles and channels, and the guilds of a client's messages and interactions, belong where discord.js puts them, and everything in a guild shares its client.
|
|
14
|
+
- **Ranking and permissions:** `role.comparePositionTo()`, `channel.permissionsFor()`, `member.permissionsIn()` and an interaction's `appPermissions` compute from the roles, the channel's `permissionOverwrites` and the bot's member. Being real, they keep working after `resetAllMocks()`.
|
|
15
|
+
- **Messages:** `message.member` reads the guild's member cache, so a test that removes the author's member there gets `null`, as discord.js gives for an author it hasn't cached. A default message now caches its author and the author's member, as Discord's message event does. `message.mentions.has(user)` answers from what the content mentions.
|
|
16
|
+
- **Defaults:** a role is not hoisted, managed or mentionable, with no icon, tags or colours. A member's `joinedTimestamp` is when the mock was made, so `partial` is `false`. A message has no `reference`, `poll` or stickers. `avatarURL()` and `iconURL()` are `null` without an avatar or icon, `displayAvatarURL()` is Discord's default avatar, and a mock client `isReady()`.
|
|
17
|
+
- **User context menus:** `targetUser` is the user with `targetId`, the client's cached one or one made, and `targetMember` that user's member in a server. A `targetId` given later picks its user, and both stay assignable.
|
|
18
|
+
|
|
19
|
+
- [#431](https://github.com/meocord/meocord/pull/431) [`b24a0bc`](https://github.com/meocord/meocord/commit/b24a0bca78b72c602718a5a8f496251484f37bfe) Thanks [@l7aromeo](https://github.com/l7aromeo)! - A mock still reads some values discord.js computes as a truthy placeholder: a message's `editable`, `deletable`, `pinnable`, `crosspostable`, `bulkDeletable`, `hasThread` and `partial`, a member's `manageable`, `kickable`, `bannable` and `moderatable`, a role's `editable`, a channel's `viewable`, `manageable` and `deletable` and its thread and voice counterparts, and `partial` on users, channels and reactions. A test that reads one now gets a warning, once per run, that 5.0 computes it as discord.js does, and how to set it on the mock, such as `message.editable = false`, to test either way. A value the test sets is read without a warning.
|
|
20
|
+
|
|
21
|
+
`message.thread` is the thread the message's channel caches under the message's id, as discord.js reads it. Without one it is still a placeholder thread, with a warning that 5.0 gives `null` there.
|
|
22
|
+
|
|
23
|
+
- [#429](https://github.com/meocord/meocord/pull/429) [`961455d`](https://github.com/meocord/meocord/commit/961455d86534be61c2b22739240fa48d53564dd7) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Mocks from `meocord/testing` now pass to one another, and to the testing module, without a cast:
|
|
24
|
+
|
|
25
|
+
- **A mock reached through a property that may be `null`** keeps its mock API, such as `message.member?.fetch.mockResolvedValue(member)` or `message.guild?.members.fetch`.
|
|
26
|
+
- **An overloaded method's mock** takes what any of its overloads takes or resolves to, such as `guild.members.fetch.mockResolvedValue(member)` and `channel.messages.fetch.mockResolvedValue(message)`, where only the list form compiled before.
|
|
27
|
+
- **`createMockInteraction` given `guild: null`, `member: null` or a DM channel** builds an interaction outside a server, typed so its `guild` and `member` may be `null`.
|
|
28
|
+
- **`createMockMessage`** is typed as discord.js emits a message, so `module.emit('messageCreate', createMockMessage())` compiles.
|
|
29
|
+
- **`createMockChannel(ThreadChannel)`** is typed as a public or private thread, as discord.js types every thread, so it fits an interaction's `channel`, a guild's channels and the `threadCreate` event.
|
|
30
|
+
- **`getResponse(interaction).calls[n].payload`** is typed by the call's `method`: after `call.method === 'reply'`, it is the reply's options. `ResponseCall` itself is unchanged, so code that builds or extends one compiles as before.
|
|
31
|
+
|
|
3
32
|
## 4.1.0
|
|
4
33
|
|
|
5
34
|
### Highlights
|
package/dist/cjs/_shared/{controller.decorator-Ds7dj8uZ.cjs → controller.decorator-BywwkU9O.cjs}
RENAMED
|
@@ -119,7 +119,7 @@ let problem;
|
|
|
119
119
|
try {
|
|
120
120
|
// Called through a variable so a bundler does not try to resolve the path while building the
|
|
121
121
|
// application; the file is only there once the build is done.
|
|
122
|
-
const load = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('_shared/controller.decorator-
|
|
122
|
+
const load = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('_shared/controller.decorator-BywwkU9O.cjs', document.baseURI).href)));
|
|
123
123
|
const loaded = load(compiledPath);
|
|
124
124
|
return loaded.default ?? loaded;
|
|
125
125
|
} catch (error) {
|
|
@@ -346,6 +346,12 @@ const warned = new Set();
|
|
|
346
346
|
*/ function warnDeprecatedBehaviour(logger, old, outcome, replacement) {
|
|
347
347
|
warnOnce(logger, `${old} is deprecated; in the next major version (5.0) it ${outcome}. Use ${replacement} instead.`);
|
|
348
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* Warns once per run that a mock reads `value` as a placeholder where discord.js computes it, saying what 5.0 gives
|
|
351
|
+
* and how to set it.
|
|
352
|
+
*/ function warnPlaceholder(logger, value, outcome, how) {
|
|
353
|
+
warnOnce(logger, `${value} reads a placeholder here; in the next major version (5.0) ${outcome}. ${how}`);
|
|
354
|
+
}
|
|
349
355
|
function warnOnce(logger, text) {
|
|
350
356
|
if (warned.has(text)) return;
|
|
351
357
|
warned.add(text);
|
|
@@ -5142,6 +5148,7 @@ exports.useTheme = useTheme;
|
|
|
5142
5148
|
exports.userWords = userWords;
|
|
5143
5149
|
exports.warnDeprecated = warnDeprecated;
|
|
5144
5150
|
exports.warnDeprecatedBehaviour = warnDeprecatedBehaviour;
|
|
5151
|
+
exports.warnPlaceholder = warnPlaceholder;
|
|
5145
5152
|
exports.withRelease = withRelease;
|
|
5146
5153
|
exports.withSendableFiles = withSendableFiles;
|
|
5147
5154
|
exports.withoutFiles = withoutFiles;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var controller_decorator = require('./controller.decorator-
|
|
3
|
+
var controller_decorator = require('./controller.decorator-BywwkU9O.cjs');
|
|
4
4
|
require('reflect-metadata');
|
|
5
5
|
var node_async_hooks = require('node:async_hooks');
|
|
6
6
|
var inversify = require('inversify');
|
package/dist/cjs/_shared/{sharded-cooldown-store-BGfooXEO.cjs → sharded-cooldown-store-B65iaiAy.cjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var node_crypto = require('node:crypto');
|
|
4
|
-
var controller_decorator = require('./controller.decorator-
|
|
4
|
+
var controller_decorator = require('./controller.decorator-BywwkU9O.cjs');
|
|
5
5
|
|
|
6
6
|
/** The `fatal` code of a shard whose app MeoCord refused, which every shard would refuse alike. */ const REFUSED_CODE = 'Refused';
|
|
7
7
|
/** Whether an IPC message is one of MeoCord's own, rather than one of discord.js's. */ function isShardMessage(message) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var discord_js = require('discord.js');
|
|
4
|
-
var controller_decorator = require('./controller.decorator-
|
|
5
|
-
var providers = require('./providers-
|
|
4
|
+
var controller_decorator = require('./controller.decorator-BywwkU9O.cjs');
|
|
5
|
+
var providers = require('./providers-BMMLp2SN.cjs');
|
|
6
6
|
var enum_index = require('../enum/index.cjs');
|
|
7
|
-
var translateError = require('./translate-error-
|
|
7
|
+
var translateError = require('./translate-error-BnM8FbSH.cjs');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Every customId-pattern route of the given controllers, most specific first, read from metadata alone.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var controller_decorator = require('./controller.decorator-
|
|
3
|
+
var controller_decorator = require('./controller.decorator-BywwkU9O.cjs');
|
|
4
4
|
var discord_js = require('discord.js');
|
|
5
5
|
|
|
6
6
|
/** The longest customId Discord accepts. */ const MAX_CUSTOM_ID_LENGTH = 100;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var controller_decorator = require('../_shared/controller.decorator-
|
|
3
|
+
var controller_decorator = require('../_shared/controller.decorator-BywwkU9O.cjs');
|
|
4
4
|
require('reflect-metadata');
|
|
5
|
-
var translateError = require('../_shared/translate-error-
|
|
6
|
-
var shardedCooldownStore = require('../_shared/sharded-cooldown-store-
|
|
5
|
+
var translateError = require('../_shared/translate-error-BnM8FbSH.cjs');
|
|
6
|
+
var shardedCooldownStore = require('../_shared/sharded-cooldown-store-B65iaiAy.cjs');
|
|
7
7
|
require('../enum/index.cjs');
|
|
8
8
|
require('discord.js');
|
|
9
9
|
require('path');
|
package/dist/cjs/core/index.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('reflect-metadata');
|
|
4
|
-
var providers = require('../_shared/providers-
|
|
4
|
+
var providers = require('../_shared/providers-BMMLp2SN.cjs');
|
|
5
5
|
var inversify = require('inversify');
|
|
6
6
|
var discord_js = require('discord.js');
|
|
7
|
-
var controller_decorator = require('../_shared/controller.decorator-
|
|
7
|
+
var controller_decorator = require('../_shared/controller.decorator-BywwkU9O.cjs');
|
|
8
8
|
require('node:crypto');
|
|
9
|
-
var shardedCooldownStore = require('../_shared/sharded-cooldown-store-
|
|
9
|
+
var shardedCooldownStore = require('../_shared/sharded-cooldown-store-B65iaiAy.cjs');
|
|
10
10
|
var path$1 = require('path');
|
|
11
|
-
var startupRoots = require('../_shared/startup-roots-
|
|
11
|
+
var startupRoots = require('../_shared/startup-roots-lFc69AxC.cjs');
|
|
12
12
|
var enum_index = require('../enum/index.cjs');
|
|
13
13
|
var node_fs = require('node:fs');
|
|
14
14
|
var path = require('node:path');
|
|
@@ -23,7 +23,7 @@ require('dayjs/plugin/utc.js');
|
|
|
23
23
|
require('dayjs/plugin/timezone.js');
|
|
24
24
|
require('module');
|
|
25
25
|
require('chalk');
|
|
26
|
-
require('../_shared/translate-error-
|
|
26
|
+
require('../_shared/translate-error-BnM8FbSH.cjs');
|
|
27
27
|
|
|
28
28
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
29
29
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('reflect-metadata');
|
|
4
|
-
var providers = require('../_shared/providers-
|
|
5
|
-
var controller_decorator = require('../_shared/controller.decorator-
|
|
4
|
+
var providers = require('../_shared/providers-BMMLp2SN.cjs');
|
|
5
|
+
var controller_decorator = require('../_shared/controller.decorator-BywwkU9O.cjs');
|
|
6
6
|
var inversify = require('inversify');
|
|
7
7
|
require('node:async_hooks');
|
|
8
8
|
require('../enum/index.cjs');
|