@discordjs/core 0.4.0-dev.1672920271-3407e1e.0 → 0.4.0-dev.1672963776-816aed4.0
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 +4 -4
- package/dist/index.d.ts +31 -3
- package/dist/index.js +65 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ pnpm add @discordjs/core
|
|
|
35
35
|
```ts
|
|
36
36
|
import { REST } from '@discordjs/rest';
|
|
37
37
|
import { WebSocketManager } from '@discordjs/ws';
|
|
38
|
-
import { GatewayIntentBits, InteractionType, MessageFlags,
|
|
38
|
+
import { GatewayIntentBits, InteractionType, MessageFlags, Client } from '@discordjs/core';
|
|
39
39
|
|
|
40
40
|
// Create REST and WebSocket managers directly
|
|
41
41
|
const rest = new REST({ version: '10' }).setToken(token);
|
|
@@ -46,11 +46,11 @@ const ws = new WebSocketManager({
|
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
// Create a client to emit relevant events.
|
|
49
|
-
const client =
|
|
49
|
+
const client = new Client({ rest, ws });
|
|
50
50
|
|
|
51
51
|
// Listen for interactions
|
|
52
52
|
// Each event contains an `api` prop along with the event data that allows you to interface with the Discord REST API
|
|
53
|
-
client.on(
|
|
53
|
+
client.on(GatewayDispatchEvents.InteractionCreate, async ({ data: interaction, api }) => {
|
|
54
54
|
if (!(interaction.type === InteractionType.ApplicationCommand) || interaction.data.name !== 'ping') {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
@@ -59,7 +59,7 @@ client.on('interactionCreate', async ({ interaction, api }) => {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
// Listen for the ready event
|
|
62
|
-
client.
|
|
62
|
+
client.once(GatewayDispatchEvents.Ready, () => console.log('Ready!'));
|
|
63
63
|
|
|
64
64
|
// Start the WebSocket connection.
|
|
65
65
|
ws.connect();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { REST, RawFile } from '@discordjs/rest';
|
|
2
2
|
import * as discord_api_types_v10 from 'discord-api-types/v10';
|
|
3
|
-
import { Snowflake, RESTGetAPIApplicationCommandsQuery, RESTGetAPIApplicationCommandsResult, RESTPostAPIApplicationCommandsJSONBody, RESTPatchAPIApplicationCommandJSONBody, RESTPutAPIApplicationCommandsJSONBody, RESTPutAPIApplicationCommandsResult, RESTGetAPIApplicationGuildCommandsQuery, RESTGetAPIGuildApplicationCommandsPermissionsResult, RESTPutAPIApplicationCommandPermissionsJSONBody, RESTPostAPIChannelMessageJSONBody, RESTGetAPIChannelMessageReactionUsersQuery, RESTGetAPIChannelMessageReactionUsersResult, RESTPatchAPIChannelJSONBody, RESTGetAPIChannelMessagesQuery, RESTGetAPIChannelMessagesResult, RESTGetAPIChannelPinsResult, RESTPostAPIChannelInviteJSONBody, RESTGetAPIChannelInvitesResult, RESTGetAPIChannelThreadsArchivedQuery, RESTGetAPIChannelUsersThreadsArchivedResult, RESTPostAPIGuildsJSONBody, RESTPatchAPIGuildJSONBody, RESTGetAPIGuildMembersQuery, RESTGetAPIGuildChannelsResult, RESTPostAPIGuildChannelJSONBody, RESTPatchAPIGuildChannelPositionsJSONBody, RESTGetAPIGuildBansResult, RESTPutAPIGuildBanJSONBody, RESTGetAPIGuildRolesResult, RESTPostAPIGuildRoleJSONBody, RESTPatchAPIGuildRolePositionsJSONBody, RESTPatchAPIGuildRolePositionsResult, RESTPatchAPIGuildRoleJSONBody, GuildMFALevel, RESTGetAPIGuildPruneCountQuery, RESTGetAPIGuildPruneCountResult, RESTPostAPIGuildPruneJSONBody, RESTGetAPIGuildVoiceRegionsResult, RESTGetAPIGuildInvitesResult, RESTGetAPIGuildIntegrationsResult, RESTPatchAPIGuildWidgetSettingsJSONBody, RESTGetAPIGuildVanityUrlResult, GuildWidgetStyle, RESTPatchAPIGuildWelcomeScreenJSONBody, RESTPatchAPIGuildVoiceStateUserJSONBody, RESTGetAPIGuildEmojisResult, RESTPostAPIGuildEmojiJSONBody, RESTPatchAPIGuildEmojiJSONBody, RESTGetAPIGuildScheduledEventsQuery, RESTGetAPIGuildScheduledEventsResult, RESTPostAPIGuildScheduledEventJSONBody, RESTGetAPIGuildScheduledEventQuery, RESTPatchAPIGuildScheduledEventJSONBody, RESTGetAPIGuildScheduledEventUsersQuery, RESTGetAPIGuildScheduledEventUsersResult, RESTGetAPIGuildTemplatesResult, RESTPatchAPIGuildTemplateJSONBody, RESTGetAPIGuildStickersResult, RESTPostAPIGuildStickerFormDataBody, RESTPatchAPIGuildStickerJSONBody, RESTGetAPIAuditLogQuery, RESTGetAPIAutoModerationRulesResult, RESTPostAPIAutoModerationRuleJSONBody, RESTPatchAPIAutoModerationRuleJSONBody, RESTGetAPIGuildMembersSearchQuery, RESTGetAPIGuildMembersSearchResult, RESTPatchAPIGuildMemberJSONBody, RESTPostAPITemplateCreateGuildJSONBody, RESTPostAPIChannelWebhookJSONBody, RESTPatchAPIWebhookJSONBody, RESTPostAPIWebhookWithTokenJSONBody, RESTPostAPIWebhookWithTokenQuery, RESTPostAPIWebhookWithTokenWaitResult, RESTPostAPIWebhookWithTokenSlackQuery, RESTPostAPIWebhookWithTokenGitHubQuery, RESTPatchAPIWebhookWithTokenMessageJSONBody, APIInteractionResponseCallbackData, APICommandAutocompleteInteractionResponseCallbackData, APIModalInteractionResponseCallbackData, RESTGetAPIInviteQuery, RESTOAuth2AuthorizationQuery, RESTPostOAuth2AccessTokenURLEncodedData, RESTPostOAuth2AccessTokenResult, RESTPostOAuth2RefreshTokenURLEncodedData, RESTPostOAuth2ClientCredentialsURLEncodedData, RESTGetAPIOAuth2CurrentApplicationResult, RESTGetAPIOAuth2CurrentAuthorizationResult, RESTGetAPIApplicationRoleConnectionMetadataResult, RESTPutAPIApplicationRoleConnectionMetadataResult, RESTGetNitroStickerPacksResult, RESTPostAPIChannelThreadsJSONBody, RESTPostAPIGuildForumThreadsJSONBody, APIThreadChannel, APIThreadMember, RESTGetAPIChannelThreadMembersResult, RESTGetAPICurrentUserGuildsQuery, RESTGetAPICurrentUserGuildsResult, RESTPatchAPICurrentUserJSONBody, RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody, RESTGetAPICurrentUserConnectionsResult, RESTPutAPICurrentUserApplicationRoleConnectionJSONBody, GatewayDispatchEvents, GatewayChannelCreateDispatchData, GatewayChannelDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayChannelUpdateDispatchData, GatewayGuildBanAddDispatchData, GatewayGuildBanRemoveDispatchData, GatewayGuildCreateDispatchData, GatewayGuildDeleteDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildMemberAddDispatchData, GatewayGuildMemberRemoveDispatchData, GatewayGuildMemberUpdateDispatchData, GatewayGuildMembersChunkDispatchData, GatewayGuildRoleCreateDispatchData, GatewayGuildRoleDeleteDispatchData, GatewayGuildRoleUpdateDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventUserAddDispatchData, GatewayGuildScheduledEventUserRemoveDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildUpdateDispatchData, GatewayIntegrationCreateDispatchData, GatewayIntegrationDeleteDispatchData, GatewayIntegrationUpdateDispatchData, GatewayInteractionCreateDispatchData, GatewayInviteCreateDispatchData, GatewayInviteDeleteDispatchData, GatewayMessageCreateDispatchData, GatewayMessageDeleteDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayMessageUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayReadyDispatchData, GatewayStageInstanceCreateDispatchData, GatewayStageInstanceDeleteDispatchData, GatewayStageInstanceUpdateDispatchData, GatewayThreadCreateDispatchData, GatewayThreadDeleteDispatchData, GatewayThreadListSyncDispatchData, GatewayThreadMemberUpdateDispatchData, GatewayThreadMembersUpdateDispatchData, GatewayThreadUpdateDispatchData, GatewayUserUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayWebhooksUpdateDispatchData, GatewayTypingStartDispatchData, GatewayAutoModerationActionExecutionDispatchData, GatewayAutoModerationRuleCreateDispatchData, GatewayAutoModerationRuleDeleteDispatchData, GatewayAutoModerationRuleUpdateDispatchData } from 'discord-api-types/v10';
|
|
3
|
+
import { Snowflake, RESTGetAPIApplicationCommandsQuery, RESTGetAPIApplicationCommandsResult, RESTPostAPIApplicationCommandsJSONBody, RESTPatchAPIApplicationCommandJSONBody, RESTPutAPIApplicationCommandsJSONBody, RESTPutAPIApplicationCommandsResult, RESTGetAPIApplicationGuildCommandsQuery, RESTGetAPIGuildApplicationCommandsPermissionsResult, RESTPutAPIApplicationCommandPermissionsJSONBody, RESTPostAPIChannelMessageJSONBody, RESTGetAPIChannelMessageReactionUsersQuery, RESTGetAPIChannelMessageReactionUsersResult, RESTPatchAPIChannelJSONBody, RESTGetAPIChannelMessagesQuery, RESTGetAPIChannelMessagesResult, RESTGetAPIChannelPinsResult, RESTPostAPIChannelInviteJSONBody, RESTGetAPIChannelInvitesResult, RESTGetAPIChannelThreadsArchivedQuery, RESTGetAPIChannelUsersThreadsArchivedResult, RESTPostAPIGuildsJSONBody, RESTPatchAPIGuildJSONBody, RESTGetAPIGuildMembersQuery, RESTGetAPIGuildChannelsResult, RESTPostAPIGuildChannelJSONBody, RESTPatchAPIGuildChannelPositionsJSONBody, RESTGetAPIGuildBansResult, RESTPutAPIGuildBanJSONBody, RESTGetAPIGuildRolesResult, RESTPostAPIGuildRoleJSONBody, RESTPatchAPIGuildRolePositionsJSONBody, RESTPatchAPIGuildRolePositionsResult, RESTPatchAPIGuildRoleJSONBody, GuildMFALevel, RESTGetAPIGuildPruneCountQuery, RESTGetAPIGuildPruneCountResult, RESTPostAPIGuildPruneJSONBody, RESTGetAPIGuildVoiceRegionsResult, RESTGetAPIGuildInvitesResult, RESTGetAPIGuildIntegrationsResult, RESTPatchAPIGuildWidgetSettingsJSONBody, RESTGetAPIGuildVanityUrlResult, GuildWidgetStyle, RESTPatchAPIGuildWelcomeScreenJSONBody, RESTPatchAPIGuildVoiceStateUserJSONBody, RESTGetAPIGuildEmojisResult, RESTPostAPIGuildEmojiJSONBody, RESTPatchAPIGuildEmojiJSONBody, RESTGetAPIGuildScheduledEventsQuery, RESTGetAPIGuildScheduledEventsResult, RESTPostAPIGuildScheduledEventJSONBody, RESTGetAPIGuildScheduledEventQuery, RESTPatchAPIGuildScheduledEventJSONBody, RESTGetAPIGuildScheduledEventUsersQuery, RESTGetAPIGuildScheduledEventUsersResult, RESTGetAPIGuildTemplatesResult, RESTPatchAPIGuildTemplateJSONBody, RESTGetAPIGuildStickersResult, RESTPostAPIGuildStickerFormDataBody, RESTPatchAPIGuildStickerJSONBody, RESTGetAPIAuditLogQuery, RESTGetAPIAutoModerationRulesResult, RESTPostAPIAutoModerationRuleJSONBody, RESTPatchAPIAutoModerationRuleJSONBody, RESTGetAPIGuildMembersSearchQuery, RESTGetAPIGuildMembersSearchResult, RESTPatchAPIGuildMemberJSONBody, RESTPostAPITemplateCreateGuildJSONBody, RESTPostAPIChannelWebhookJSONBody, RESTPatchAPIWebhookJSONBody, RESTPostAPIWebhookWithTokenJSONBody, RESTPostAPIWebhookWithTokenQuery, RESTPostAPIWebhookWithTokenWaitResult, RESTPostAPIWebhookWithTokenSlackQuery, RESTPostAPIWebhookWithTokenGitHubQuery, RESTPatchAPIWebhookWithTokenMessageJSONBody, APIInteractionResponseCallbackData, APICommandAutocompleteInteractionResponseCallbackData, APIModalInteractionResponseCallbackData, RESTGetAPIInviteQuery, RESTOAuth2AuthorizationQuery, RESTPostOAuth2AccessTokenURLEncodedData, RESTPostOAuth2AccessTokenResult, RESTPostOAuth2RefreshTokenURLEncodedData, RESTPostOAuth2ClientCredentialsURLEncodedData, RESTGetAPIOAuth2CurrentApplicationResult, RESTGetAPIOAuth2CurrentAuthorizationResult, RESTGetAPIApplicationRoleConnectionMetadataResult, RESTPutAPIApplicationRoleConnectionMetadataResult, RESTGetNitroStickerPacksResult, RESTPostAPIChannelThreadsJSONBody, RESTPostAPIGuildForumThreadsJSONBody, APIThreadChannel, APIThreadMember, RESTGetAPIChannelThreadMembersResult, RESTGetAPICurrentUserGuildsQuery, RESTGetAPICurrentUserGuildsResult, RESTPatchAPICurrentUserJSONBody, RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody, RESTGetAPICurrentUserConnectionsResult, RESTPutAPICurrentUserApplicationRoleConnectionJSONBody, GatewayDispatchEvents, GatewayChannelCreateDispatchData, GatewayChannelDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayChannelUpdateDispatchData, GatewayGuildBanAddDispatchData, GatewayGuildBanRemoveDispatchData, GatewayGuildCreateDispatchData, GatewayGuildDeleteDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildMemberAddDispatchData, GatewayGuildMemberRemoveDispatchData, GatewayGuildMemberUpdateDispatchData, GatewayGuildMembersChunkDispatchData, GatewayGuildRoleCreateDispatchData, GatewayGuildRoleDeleteDispatchData, GatewayGuildRoleUpdateDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventUserAddDispatchData, GatewayGuildScheduledEventUserRemoveDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildUpdateDispatchData, GatewayIntegrationCreateDispatchData, GatewayIntegrationDeleteDispatchData, GatewayIntegrationUpdateDispatchData, GatewayInteractionCreateDispatchData, GatewayInviteCreateDispatchData, GatewayInviteDeleteDispatchData, GatewayMessageCreateDispatchData, GatewayMessageDeleteDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayMessageUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayReadyDispatchData, GatewayStageInstanceCreateDispatchData, GatewayStageInstanceDeleteDispatchData, GatewayStageInstanceUpdateDispatchData, GatewayThreadCreateDispatchData, GatewayThreadDeleteDispatchData, GatewayThreadListSyncDispatchData, GatewayThreadMemberUpdateDispatchData, GatewayThreadMembersUpdateDispatchData, GatewayThreadUpdateDispatchData, GatewayUserUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayWebhooksUpdateDispatchData, GatewayTypingStartDispatchData, GatewayAutoModerationActionExecutionDispatchData, GatewayAutoModerationRuleCreateDispatchData, GatewayAutoModerationRuleDeleteDispatchData, GatewayAutoModerationRuleUpdateDispatchData, GatewayRequestGuildMembersData, APIGuildMember, GatewayVoiceStateUpdateData, GatewayPresenceUpdateData } from 'discord-api-types/v10';
|
|
4
4
|
export * from 'discord-api-types/v10';
|
|
5
5
|
import { WebSocketManager } from '@discordjs/ws';
|
|
6
6
|
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
@@ -1544,7 +1544,35 @@ interface ClientOptions {
|
|
|
1544
1544
|
rest: REST;
|
|
1545
1545
|
ws: WebSocketManager;
|
|
1546
1546
|
}
|
|
1547
|
-
declare
|
|
1547
|
+
declare class Client extends AsyncEventEmitter<ManagerShardEventsMap> {
|
|
1548
|
+
readonly rest: REST;
|
|
1549
|
+
readonly ws: WebSocketManager;
|
|
1550
|
+
readonly api: API;
|
|
1551
|
+
constructor({ rest, ws }: ClientOptions);
|
|
1552
|
+
/**
|
|
1553
|
+
* Requests guild members from the gateway.
|
|
1554
|
+
*
|
|
1555
|
+
* @see {@link https://discord.com/developers/docs/topics/gateway-events#request-guild-members}
|
|
1556
|
+
* @param options - The options for the request
|
|
1557
|
+
* @param timeout - The timeout for waiting for each guild members chunk event
|
|
1558
|
+
*/
|
|
1559
|
+
requestGuildMembers(options: GatewayRequestGuildMembersData, timeout?: number): Promise<APIGuildMember[]>;
|
|
1560
|
+
/**
|
|
1561
|
+
* Updates the voice state of the bot user
|
|
1562
|
+
*
|
|
1563
|
+
* @see {@link https://discord.com/developers/docs/topics/gateway-events#update-voice-state}
|
|
1564
|
+
* @param options - The options for updating the voice state
|
|
1565
|
+
*/
|
|
1566
|
+
updateVoiceState(options: GatewayVoiceStateUpdateData): Promise<void>;
|
|
1567
|
+
/**
|
|
1568
|
+
* Updates the presence of the bot user
|
|
1569
|
+
*
|
|
1570
|
+
* @param shardId - The id of the shard to update the presence in
|
|
1571
|
+
* @param options - The options for updating the presence
|
|
1572
|
+
*/
|
|
1573
|
+
updatePresence(shardId: number, options: GatewayPresenceUpdateData): Promise<void>;
|
|
1574
|
+
private wrapIntrinsicProps;
|
|
1575
|
+
}
|
|
1548
1576
|
|
|
1549
1577
|
interface DescriptiveRawFile extends RawFile {
|
|
1550
1578
|
description?: string;
|
|
@@ -1575,4 +1603,4 @@ declare function withFiles(files: DescriptiveRawFile[], options: APIInteractionR
|
|
|
1575
1603
|
}[];
|
|
1576
1604
|
};
|
|
1577
1605
|
|
|
1578
|
-
export { API, ApplicationCommandsAPI, ChannelsAPI, ClientOptions, DescriptiveRawFile, GuildsAPI, InteractionsAPI, IntrinsicProps, InvitesAPI, ManagerShardEventsMap, MappedEvents, OAuth2API, RoleConnectionsAPI, StartForumThreadOptions, StartThreadOptions, StickersAPI, ThreadsAPI, UsersAPI, VoiceAPI, WebhooksAPI, WithIntrinsicProps,
|
|
1606
|
+
export { API, ApplicationCommandsAPI, ChannelsAPI, Client, ClientOptions, DescriptiveRawFile, GuildsAPI, InteractionsAPI, IntrinsicProps, InvitesAPI, ManagerShardEventsMap, MappedEvents, OAuth2API, RoleConnectionsAPI, StartForumThreadOptions, StartThreadOptions, StickersAPI, ThreadsAPI, UsersAPI, VoiceAPI, WebhooksAPI, WithIntrinsicProps, withFiles };
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(src_exports, {
|
|
|
25
25
|
API: () => API,
|
|
26
26
|
ApplicationCommandsAPI: () => ApplicationCommandsAPI,
|
|
27
27
|
ChannelsAPI: () => ChannelsAPI,
|
|
28
|
+
Client: () => Client,
|
|
28
29
|
GuildsAPI: () => GuildsAPI,
|
|
29
30
|
InteractionsAPI: () => InteractionsAPI,
|
|
30
31
|
InvitesAPI: () => InvitesAPI,
|
|
@@ -35,7 +36,6 @@ __export(src_exports, {
|
|
|
35
36
|
UsersAPI: () => UsersAPI,
|
|
36
37
|
VoiceAPI: () => VoiceAPI,
|
|
37
38
|
WebhooksAPI: () => WebhooksAPI,
|
|
38
|
-
createClient: () => createClient,
|
|
39
39
|
withFiles: () => withFiles
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -896,25 +896,76 @@ var API = class {
|
|
|
896
896
|
__name(API, "API");
|
|
897
897
|
|
|
898
898
|
// src/client.ts
|
|
899
|
+
var import_node_timers = require("timers");
|
|
900
|
+
var import_util = require("@discordjs/util");
|
|
899
901
|
var import_ws = require("@discordjs/ws");
|
|
902
|
+
var import_snowflake = require("@sapphire/snowflake");
|
|
900
903
|
var import_async_event_emitter = require("@vladfrangu/async_event_emitter");
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
904
|
+
var import_v1013 = require("discord-api-types/v10");
|
|
905
|
+
var Client = class extends import_async_event_emitter.AsyncEventEmitter {
|
|
906
|
+
rest;
|
|
907
|
+
ws;
|
|
908
|
+
api;
|
|
909
|
+
constructor({ rest, ws }) {
|
|
910
|
+
super();
|
|
911
|
+
this.rest = rest;
|
|
912
|
+
this.ws = ws;
|
|
913
|
+
this.api = new API(rest);
|
|
914
|
+
this.ws.on(import_ws.WebSocketShardEvents.Dispatch, ({ data: dispatch, shardId }) => {
|
|
915
|
+
this.emit(dispatch.t, this.wrapIntrinsicProps(dispatch.d, shardId));
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
async requestGuildMembers(options, timeout = 1e4) {
|
|
919
|
+
const shardId = (0, import_util.calculateShardId)(options.guild_id, await this.ws.getShardCount());
|
|
920
|
+
const nonce = options.nonce ?? import_snowflake.DiscordSnowflake.generate().toString();
|
|
921
|
+
const promise = new Promise((resolve, reject) => {
|
|
922
|
+
const guildMembers = [];
|
|
923
|
+
const timer = (0, import_node_timers.setTimeout)(() => {
|
|
924
|
+
reject(new Error("Request timed out"));
|
|
925
|
+
}, timeout);
|
|
926
|
+
const handler = /* @__PURE__ */ __name(({ data }) => {
|
|
927
|
+
timer.refresh();
|
|
928
|
+
if (data.nonce !== nonce)
|
|
929
|
+
return;
|
|
930
|
+
guildMembers.push(...data.members);
|
|
931
|
+
if (data.chunk_index >= data.chunk_count - 1) {
|
|
932
|
+
this.off(import_v1013.GatewayDispatchEvents.GuildMembersChunk, handler);
|
|
933
|
+
resolve(guildMembers);
|
|
934
|
+
}
|
|
935
|
+
}, "handler");
|
|
936
|
+
this.on(import_v1013.GatewayDispatchEvents.GuildMembersChunk, handler);
|
|
937
|
+
});
|
|
938
|
+
await this.ws.send(shardId, {
|
|
939
|
+
op: import_v1013.GatewayOpcodes.RequestGuildMembers,
|
|
940
|
+
d: {
|
|
941
|
+
...options,
|
|
942
|
+
nonce
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
return promise;
|
|
946
|
+
}
|
|
947
|
+
async updateVoiceState(options) {
|
|
948
|
+
const shardId = (0, import_util.calculateShardId)(options.guild_id, await this.ws.getShardCount());
|
|
949
|
+
await this.ws.send(shardId, {
|
|
950
|
+
op: import_v1013.GatewayOpcodes.VoiceStateUpdate,
|
|
951
|
+
d: options
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
async updatePresence(shardId, options) {
|
|
955
|
+
await this.ws.send(shardId, {
|
|
956
|
+
op: import_v1013.GatewayOpcodes.PresenceUpdate,
|
|
957
|
+
d: options
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
wrapIntrinsicProps(obj, shardId) {
|
|
905
961
|
return {
|
|
906
|
-
api,
|
|
962
|
+
api: this.api,
|
|
907
963
|
shardId,
|
|
908
964
|
data: obj
|
|
909
965
|
};
|
|
910
966
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
emitter.emit(dispatch.t, wrapIntrinsicProps(dispatch.d, shardId));
|
|
914
|
-
});
|
|
915
|
-
return emitter;
|
|
916
|
-
}
|
|
917
|
-
__name(createClient, "createClient");
|
|
967
|
+
};
|
|
968
|
+
__name(Client, "Client");
|
|
918
969
|
|
|
919
970
|
// src/util/files.ts
|
|
920
971
|
function withFiles(files, options) {
|
|
@@ -940,6 +991,7 @@ __reExport(src_exports, require("discord-api-types/v10"), module.exports);
|
|
|
940
991
|
API,
|
|
941
992
|
ApplicationCommandsAPI,
|
|
942
993
|
ChannelsAPI,
|
|
994
|
+
Client,
|
|
943
995
|
GuildsAPI,
|
|
944
996
|
InteractionsAPI,
|
|
945
997
|
InvitesAPI,
|
|
@@ -950,7 +1002,6 @@ __reExport(src_exports, require("discord-api-types/v10"), module.exports);
|
|
|
950
1002
|
UsersAPI,
|
|
951
1003
|
VoiceAPI,
|
|
952
1004
|
WebhooksAPI,
|
|
953
|
-
createClient,
|
|
954
1005
|
withFiles
|
|
955
1006
|
});
|
|
956
1007
|
//# sourceMappingURL=index.js.map
|