@discordeno/gateway 19.0.0-next.fbd26f4 → 19.0.0-next.fc13bdf
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 +1 -1
- package/dist/Shard.d.ts +89 -5
- package/dist/Shard.d.ts.map +1 -1
- package/dist/Shard.js +594 -2
- package/dist/Shard.js.map +1 -0
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -0
- package/dist/manager.d.ts +1 -1
- package/dist/manager.d.ts.map +1 -1
- package/dist/manager.js +220 -2
- package/dist/manager.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +23 -2
- package/dist/types.js.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
package/dist/Shard.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { DiscordGatewayPayload } from '@discordeno/types';
|
|
1
|
+
import type { AtLeastOne, BigString, Camelize, DiscordGatewayPayload, DiscordMember, RequestGuildMembers } from '@discordeno/types';
|
|
2
|
+
import { Collection } from '@discordeno/utils';
|
|
2
3
|
import WebSocket from 'ws';
|
|
3
|
-
import type {
|
|
4
|
+
import type { RequestMemberRequest } from './manager.js';
|
|
5
|
+
import type { BotStatusUpdate, ShardEvents, ShardGatewayConfig, ShardHeart, ShardSocketRequest, StatusUpdate, UpdateVoiceState } from './types.js';
|
|
4
6
|
import { ShardState } from './types.js';
|
|
5
|
-
export declare class
|
|
7
|
+
export declare class DiscordenoShard {
|
|
6
8
|
/** The id of the shard */
|
|
7
9
|
id: number;
|
|
8
10
|
/** The connection config details that this shard will used to connect to discord. */
|
|
@@ -31,6 +33,18 @@ export declare class Shard {
|
|
|
31
33
|
resolves: Map<"READY" | "RESUMED" | "INVALID_SESSION", (payload: DiscordGatewayPayload) => void>;
|
|
32
34
|
/** Shard bucket. Only access this if you know what you are doing. Bucket for handling shard request rate limits. */
|
|
33
35
|
bucket: import("@discordeno/utils").LeakyBucket;
|
|
36
|
+
/** This managers cache related settings. */
|
|
37
|
+
cache: {
|
|
38
|
+
requestMembers: {
|
|
39
|
+
/**
|
|
40
|
+
* Whether or not request member requests should be cached.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
/** The pending requests. */
|
|
45
|
+
pending: Collection<string, RequestMemberRequest>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
34
48
|
constructor(options: ShardCreateOptions);
|
|
35
49
|
/** The gateway configuration which is used to connect to Discord. */
|
|
36
50
|
get gatewayConfig(): ShardGatewayConfig;
|
|
@@ -40,7 +54,7 @@ export declare class Shard {
|
|
|
40
54
|
/** Close the socket connection to discord if present. */
|
|
41
55
|
close(code: number, reason: string): void;
|
|
42
56
|
/** Connect the shard with the gateway and start heartbeating. This will not identify the shard to the gateway. */
|
|
43
|
-
connect(): Promise<
|
|
57
|
+
connect(): Promise<DiscordenoShard>;
|
|
44
58
|
/** Identify the shard to the gateway. If not connected, this will also connect the shard to the gateway. */
|
|
45
59
|
identify(): Promise<void>;
|
|
46
60
|
/** Check whether the connection to Discord is currently open. */
|
|
@@ -55,6 +69,8 @@ export declare class Shard {
|
|
|
55
69
|
shutdown(): Promise<void>;
|
|
56
70
|
/** Handle a gateway connection close. */
|
|
57
71
|
handleClose(close: WebSocket.CloseEvent): Promise<void>;
|
|
72
|
+
/** Handles a incoming gateway packet. */
|
|
73
|
+
handleDiscordPacket(packet: DiscordGatewayPayload): Promise<void>;
|
|
58
74
|
/** Handle an incoming gateway message. */
|
|
59
75
|
handleMessage(message: WebSocket.MessageEvent): Promise<void>;
|
|
60
76
|
/**
|
|
@@ -69,6 +85,74 @@ export declare class Shard {
|
|
|
69
85
|
startHeartbeating(interval: number): void;
|
|
70
86
|
/** Stop the heartbeating process with discord. */
|
|
71
87
|
stopHeartbeating(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Connects the bot user to a voice or stage channel.
|
|
90
|
+
*
|
|
91
|
+
* This function sends the _Update Voice State_ gateway command over the gateway behind the scenes.
|
|
92
|
+
*
|
|
93
|
+
* @param guildId - The ID of the guild the voice channel to leave is in.
|
|
94
|
+
* @param channelId - The ID of the channel you want to join.
|
|
95
|
+
*
|
|
96
|
+
* @remarks
|
|
97
|
+
* Requires the `CONNECT` permission.
|
|
98
|
+
*
|
|
99
|
+
* Fires a _Voice State Update_ gateway event.
|
|
100
|
+
*
|
|
101
|
+
* @see {@link https://discord.com/developers/docs/topics/gateway#update-voice-state}
|
|
102
|
+
*/
|
|
103
|
+
joinVoiceChannel(guildId: BigString, channelId: BigString, options?: AtLeastOne<Omit<UpdateVoiceState, 'guildId' | 'channelId'>>): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Edits the bot status in all shards that this gateway manages.
|
|
106
|
+
*
|
|
107
|
+
* @param data The status data to set the bots status to.
|
|
108
|
+
* @returns Promise<void>
|
|
109
|
+
*/
|
|
110
|
+
editBotStatus(data: StatusUpdate): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Edits the bot's status on one shard.
|
|
113
|
+
*
|
|
114
|
+
* @param shardId The shard id to edit the status for.
|
|
115
|
+
* @param data The status data to set the bots status to.
|
|
116
|
+
* @returns Promise<void>
|
|
117
|
+
*/
|
|
118
|
+
editShardStatus(data: StatusUpdate): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Fetches the list of members for a guild over the gateway.
|
|
121
|
+
*
|
|
122
|
+
* @param guildId - The ID of the guild to get the list of members for.
|
|
123
|
+
* @param options - The parameters for the fetching of the members.
|
|
124
|
+
*
|
|
125
|
+
* @remarks
|
|
126
|
+
* If requesting the entire member list:
|
|
127
|
+
* - Requires the `GUILD_MEMBERS` intent.
|
|
128
|
+
*
|
|
129
|
+
* If requesting presences ({@link RequestGuildMembers.presences | presences} set to `true`):
|
|
130
|
+
* - Requires the `GUILD_PRESENCES` intent.
|
|
131
|
+
*
|
|
132
|
+
* If requesting a prefix ({@link RequestGuildMembers.query | query} non-`undefined`):
|
|
133
|
+
* - Returns a maximum of 100 members.
|
|
134
|
+
*
|
|
135
|
+
* If requesting a users by ID ({@link RequestGuildMembers.userIds | userIds} non-`undefined`):
|
|
136
|
+
* - Returns a maximum of 100 members.
|
|
137
|
+
*
|
|
138
|
+
* Fires a _Guild Members Chunk_ gateway event for every 1000 members fetched.
|
|
139
|
+
*
|
|
140
|
+
* @see {@link https://discord.com/developers/docs/topics/gateway#request-guild-members}
|
|
141
|
+
*/
|
|
142
|
+
requestMembers(guildId: BigString, options?: Omit<RequestGuildMembers, 'guildId'>): Promise<Camelize<DiscordMember[]>>;
|
|
143
|
+
/**
|
|
144
|
+
* Leaves the voice channel the bot user is currently in.
|
|
145
|
+
*
|
|
146
|
+
* This function sends the _Update Voice State_ gateway command over the gateway behind the scenes.
|
|
147
|
+
*
|
|
148
|
+
* @param guildId - The ID of the guild the voice channel to leave is in.
|
|
149
|
+
*
|
|
150
|
+
* @remarks
|
|
151
|
+
* Fires a _Voice State Update_ gateway event.
|
|
152
|
+
*
|
|
153
|
+
* @see {@link https://discord.com/developers/docs/topics/gateway#update-voice-state}
|
|
154
|
+
*/
|
|
155
|
+
leaveVoiceChannel(guildId: BigString): Promise<void>;
|
|
72
156
|
}
|
|
73
157
|
export interface ShardCreateOptions {
|
|
74
158
|
/** The shard id */
|
|
@@ -78,5 +162,5 @@ export interface ShardCreateOptions {
|
|
|
78
162
|
/** The event handlers for events on the shard. */
|
|
79
163
|
events: ShardEvents;
|
|
80
164
|
}
|
|
81
|
-
export default
|
|
165
|
+
export default DiscordenoShard;
|
|
82
166
|
//# sourceMappingURL=Shard.d.ts.map
|
package/dist/Shard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Shard.d.ts","sourceRoot":"","sources":["../src/Shard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Shard.d.ts","sourceRoot":"","sources":["../src/Shard.ts"],"names":[],"m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