@wolfstar/plugin-gateway 0.11.0 → 0.12.0-next-20261006120125
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/README.md +39 -2
- package/dist/esm/index.d.ts +330 -137
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4423 -4132
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -305,7 +305,7 @@ Every manager exposes its cache as `manager.cache`, the `Cache` of the discord.j
|
|
|
305
305
|
|
|
306
306
|
```typescript
|
|
307
307
|
const user = client.users.cache.get(userId);
|
|
308
|
-
const member =
|
|
308
|
+
const member = guild.members.cache.get(userId);
|
|
309
309
|
|
|
310
310
|
client.users.cache.has(userId);
|
|
311
311
|
client.users.cache.getSize();
|
|
@@ -356,6 +356,32 @@ for most managers, and by `manager.resolveKey(...)` for the ones taking more tha
|
|
|
356
356
|
- `refresh` is `fetch` with `{ force: true }`;
|
|
357
357
|
- `resolve` takes a structure (returned as is) or a cache key, like discord.js's `resolve`.
|
|
358
358
|
|
|
359
|
+
The managers taking more than one argument are also handed out for one guild, channel, or thread, like
|
|
360
|
+
discord.js's: the first ID is filled in, and `cache` takes the ID of the entity alone.
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
const member = await guild.members.cache.get(userId);
|
|
364
|
+
// instead of client.members.cache.get(client.members.resolveKey(guildId, userId))
|
|
365
|
+
|
|
366
|
+
await guild.roles.cache.has(roleId);
|
|
367
|
+
await channel.messages.cache.get(messageId);
|
|
368
|
+
await guild.members.kick(userId, "spam"); // client.members.kick(guildId, userId, "spam")
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
| Manager | From the client | `cache` is keyed by |
|
|
372
|
+
| ------------------- | ------------------------------------ | ------------------- |
|
|
373
|
+
| `guild.members` | `client.guilds.members(guildId)` | `userId` |
|
|
374
|
+
| `guild.roles` | `client.guilds.roles(guildId)` | `roleId` |
|
|
375
|
+
| `guild.voiceStates` | `client.guilds.voiceStates(guildId)` | `userId` |
|
|
376
|
+
| `guild.presences` | `client.guilds.presences(guildId)` | `userId` |
|
|
377
|
+
| `channel.messages` | `new ChannelMessageManager(…)` | `messageId` |
|
|
378
|
+
| `thread.members` | `new ThreadChannelMemberManager(…)` | `userId` |
|
|
379
|
+
|
|
380
|
+
The ones of a guild are the client's managers themselves, built for that guild (`guild.members` is a
|
|
381
|
+
`GuildMemberManager<true>`): their `cache` is a `Cache` like the client's, counting and clearing the entries of the
|
|
382
|
+
guild alone, and synchronous when the client's is. The `cache` of `channel.messages` and `thread.members` has `get`,
|
|
383
|
+
`has`, and `delete`.
|
|
384
|
+
|
|
359
385
|
Every API payload is written to the cache: a cached entry is patched with it (the fields a partial payload lacks
|
|
360
386
|
keep their cached value) and the patched instance, or the newly built structure, is returned. Relations are
|
|
361
387
|
resolved from the cache too: `message.author` is the entry of `client.users`, `message.member` the one of
|
|
@@ -755,7 +781,7 @@ await member.timeout(10 * 60_000, "spam");
|
|
|
755
781
|
if (member.permissions.has("BanMembers")) await member.ban(); // read from the cache, like discord.js
|
|
756
782
|
if (member.kickable) await member.kick();
|
|
757
783
|
|
|
758
|
-
const me =
|
|
784
|
+
const me = guild.members.me; // like discord.js, null when not cached; client.members.me(guildId) without a guild
|
|
759
785
|
const cached = await member.roles.cache; // a Collection of the cached roles, @everyone included
|
|
760
786
|
const highest = await member.roles.highest; // read from the cache, like discord.js
|
|
761
787
|
await highest?.setColors({ primaryColor: 0xff0000 });
|
|
@@ -890,6 +916,17 @@ and disconnects members, and handles stage channels (`setSuppressed`, `setReques
|
|
|
890
916
|
`Presence` has the status and `Activity`s, with their `RichPresenceAssets` URLs. Members have
|
|
891
917
|
`fetchVoiceState()` and `fetchPresence()` (discord.js: `member.voice`, `member.presence`).
|
|
892
918
|
|
|
919
|
+
`guild.voiceStates` and `guild.presences` read them by user ID alone, like discord.js, and so do
|
|
920
|
+
`client.guilds.voiceStates(guildId)` and `client.guilds.presences(guildId)` when you only hold the guild's ID:
|
|
921
|
+
|
|
922
|
+
```ts
|
|
923
|
+
const presence = await guild.presences.cache.get(userId);
|
|
924
|
+
const voiceState = await guild.voiceStates.cache.get(userId);
|
|
925
|
+
|
|
926
|
+
await guild.presences.resolve(member); // null on a miss
|
|
927
|
+
await guild.presences.listCached();
|
|
928
|
+
```
|
|
929
|
+
|
|
893
930
|
```ts
|
|
894
931
|
client.on("voiceStateUpdate", (oldState, newState) => {
|
|
895
932
|
if (!oldState?.channelId && newState.channelId)
|