disgroove 2.2.3-dev.933ac5e → 2.2.3-dev.e049f9f
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/dist/lib/Client.d.ts +7 -12
- package/dist/lib/Client.js +11 -44
- package/dist/lib/constants.d.ts +6 -0
- package/dist/lib/constants.js +9 -2
- package/dist/lib/gateway/Shard.d.ts +1 -0
- package/dist/lib/gateway/Shard.js +8 -2
- package/dist/lib/gateway/index.d.ts +0 -1
- package/dist/lib/gateway/index.js +0 -1
- package/dist/lib/transformers/AutoModeration.d.ts +5 -1
- package/dist/lib/transformers/AutoModeration.js +44 -32
- package/dist/lib/transformers/Channels.js +28 -2
- package/dist/lib/transformers/Guilds.js +16 -0
- package/dist/lib/transformers/Presences.d.ts +0 -3
- package/dist/lib/transformers/Presences.js +52 -44
- package/dist/lib/transformers/Users.js +16 -2
- package/dist/lib/types/channel.d.ts +14 -3
- package/dist/lib/types/gateway-events.d.ts +4 -4
- package/dist/lib/types/guild.d.ts +3 -1
- package/dist/lib/types/user.d.ts +2 -2
- package/dist/lib/utils/errors.js +4 -4
- package/dist/lib/utils/formatters.d.ts +7 -0
- package/dist/lib/utils/formatters.js +7 -1
- package/dist/package.json +1 -1
- package/package.json +35 -35
- package/dist/lib/gateway/ShardManager.d.ts +0 -10
- package/dist/lib/gateway/ShardManager.js +0 -18
package/dist/lib/Client.d.ts
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
import { GatewayIntents, type OAuth2Scopes, type ActionTypes, type ImageWidgetStyleOptions, type MFALevel, type ReactionTypes, type ApplicationCommandTypes, type EventTypes, type TriggerTypes, type ChannelTypes, type VideoQualityModes, type SortOrderTypes, type ForumLayoutTypes, type InviteTargetTypes, type VerificationLevel, type DefaultMessageNotificationLevel, type ExplicitContentFilterLevel, type SystemChannelFlags, type ApplicationFlags, type ApplicationIntegrationTypes, type ChannelFlags, type GuildFeatures, type GuildScheduledEventEntityTypes, type GuildScheduledEventPrivacyLevel, type GuildScheduledEventStatus, type MessageFlags, type OnboardingMode, type PrivacyLevel, type GuildMemberFlags, type InteractionContextTypes } from "./constants";
|
3
3
|
import { RequestManager, type File } from "./rest";
|
4
4
|
import EventEmitter from "node:events";
|
5
|
-
import {
|
5
|
+
import { Shard } from "./gateway";
|
6
6
|
import type { Application, ApplicationIntegrationTypeConfiguration, InstallParams } from "./types/application";
|
7
7
|
import type { ApplicationCommand, GuildApplicationCommandPermissions, ApplicationCommandOption, ApplicationCommandPermission } from "./types/application-command";
|
8
8
|
import type { ApplicationRoleConnectionMetadata } from "./types/application-role-connection-metadata";
|
@@ -50,7 +50,7 @@ export declare class Client extends EventEmitter {
|
|
50
50
|
intents: GatewayIntents | number;
|
51
51
|
shardsCount: number | "auto";
|
52
52
|
auth: "Bot" | "Bearer";
|
53
|
-
shards:
|
53
|
+
shards: Map<number, Shard>;
|
54
54
|
rest: RequestManager;
|
55
55
|
guildShardMap: Record<string, number>;
|
56
56
|
user: User | null;
|
@@ -104,7 +104,6 @@ export declare class Client extends EventEmitter {
|
|
104
104
|
descriptionLocalizations?: LocaleMap | null;
|
105
105
|
options?: Array<ApplicationCommandOption>;
|
106
106
|
defaultMemberPermissions?: string | null;
|
107
|
-
defaultPermission?: boolean | null;
|
108
107
|
integrationTypes: Array<ApplicationIntegrationTypes>;
|
109
108
|
contexts: Array<InteractionContextTypes>;
|
110
109
|
type?: ApplicationCommandTypes;
|
@@ -119,7 +118,6 @@ export declare class Client extends EventEmitter {
|
|
119
118
|
descriptionLocalizations?: LocaleMap | null;
|
120
119
|
options?: Array<ApplicationCommandOption>;
|
121
120
|
defaultMemberPermissions?: string | null;
|
122
|
-
defaultPermission?: boolean | null;
|
123
121
|
type?: ApplicationCommandTypes;
|
124
122
|
nsfw?: boolean;
|
125
123
|
}>): Promise<Array<ApplicationCommand>>;
|
@@ -186,14 +184,13 @@ export declare class Client extends EventEmitter {
|
|
186
184
|
descriptionLocalizations?: LocaleMap | null;
|
187
185
|
options?: Array<ApplicationCommandOption>;
|
188
186
|
defaultMemberPermissions?: string | null;
|
189
|
-
defaultPermission?: boolean | null;
|
190
187
|
integrationTypes?: Array<ApplicationIntegrationTypes>;
|
191
188
|
contexts?: Array<InteractionContextTypes>;
|
192
189
|
type?: ApplicationCommandTypes;
|
193
190
|
nsfw?: boolean;
|
194
191
|
}): Promise<ApplicationCommand>;
|
195
192
|
/** https://discord.com/developers/docs/resources/user#create-group-dm */
|
196
|
-
|
193
|
+
createGroup(options: {
|
197
194
|
accessTokens: Array<string>;
|
198
195
|
nicks: Array<string>;
|
199
196
|
}): Promise<Channel>;
|
@@ -232,7 +229,6 @@ export declare class Client extends EventEmitter {
|
|
232
229
|
descriptionLocalizations?: LocaleMap | null;
|
233
230
|
options?: Array<ApplicationCommandOption>;
|
234
231
|
defaultMemberPermissions?: string | null;
|
235
|
-
defaultPermission?: boolean | null;
|
236
232
|
type?: ApplicationCommandTypes;
|
237
233
|
nsfw?: boolean;
|
238
234
|
}): Promise<ApplicationCommand>;
|
@@ -509,7 +505,6 @@ export declare class Client extends EventEmitter {
|
|
509
505
|
descriptionLocalizations?: LocaleMap | null;
|
510
506
|
options?: Array<ApplicationCommandOption>;
|
511
507
|
defaultMemberPermissions?: string | null;
|
512
|
-
defaultPermission?: boolean | null;
|
513
508
|
integrationTypes?: Array<ApplicationIntegrationTypes>;
|
514
509
|
contexts?: Array<InteractionContextTypes>;
|
515
510
|
nsfw?: boolean;
|
@@ -545,7 +540,6 @@ export declare class Client extends EventEmitter {
|
|
545
540
|
descriptionLocalizations?: LocaleMap | null;
|
546
541
|
options?: Array<ApplicationCommandOption>;
|
547
542
|
defaultMemberPermissions?: string | null;
|
548
|
-
defaultPermission?: boolean | null;
|
549
543
|
nsfw?: boolean;
|
550
544
|
}): Promise<ApplicationCommand>;
|
551
545
|
/** https://discord.com/developers/docs/resources/emoji#modify-guild-emoji */
|
@@ -805,7 +799,7 @@ export declare class Client extends EventEmitter {
|
|
805
799
|
after?: snowflake;
|
806
800
|
limit?: number;
|
807
801
|
withCounts?: boolean;
|
808
|
-
}): Promise<Array<Pick<Guild, "id" | "name" | "icon" | "owner" | "permissions" | "features" | "approximateMemberCount" | "approximatePresenceCount">>>;
|
802
|
+
}): Promise<Array<Pick<Guild, "id" | "name" | "icon" | "banner" | "owner" | "permissions" | "features" | "approximateMemberCount" | "approximatePresenceCount">>>;
|
809
803
|
/** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command */
|
810
804
|
getGuildApplicationCommand(applicationID: snowflake, guildID: snowflake, commandID: snowflake): Promise<ApplicationCommand>;
|
811
805
|
/** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */
|
@@ -1029,8 +1023,9 @@ export declare interface Client extends EventEmitter {
|
|
1029
1023
|
removeListener<K extends keyof ClientEvents>(eventName: K, listener: (...args: ClientEvents[K]) => void): this;
|
1030
1024
|
}
|
1031
1025
|
export interface ClientEvents {
|
1032
|
-
dispatch: [packet: RawPayload];
|
1033
|
-
|
1026
|
+
dispatch: [packet: RawPayload, shard: number];
|
1027
|
+
heartbeatACK: [shard: number];
|
1028
|
+
hello: [interval: number, shard: number];
|
1034
1029
|
ready: [];
|
1035
1030
|
resumed: [];
|
1036
1031
|
reconnect: [];
|
package/dist/lib/Client.js
CHANGED
@@ -40,7 +40,7 @@ class Client extends node_events_1.default {
|
|
40
40
|
: 0;
|
41
41
|
this.shardsCount = options?.shardsCount ?? "auto";
|
42
42
|
this.auth = options?.auth ?? "Bot";
|
43
|
-
this.shards = new
|
43
|
+
this.shards = new Map();
|
44
44
|
this.rest = new rest_1.RequestManager(token, this.auth);
|
45
45
|
this.guildShardMap = {};
|
46
46
|
this.user = null;
|
@@ -125,7 +125,6 @@ class Client extends node_events_1.default {
|
|
125
125
|
description_localizations: command.descriptionLocalizations,
|
126
126
|
options: command.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
|
127
127
|
default_member_permissions: command.defaultMemberPermissions,
|
128
|
-
default_permissions: command.defaultPermission,
|
129
128
|
integration_types: command.integrationTypes,
|
130
129
|
contexts: command.contexts,
|
131
130
|
type: command.type,
|
@@ -145,7 +144,6 @@ class Client extends node_events_1.default {
|
|
145
144
|
description_localizations: command.descriptionLocalizations,
|
146
145
|
options: command.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
|
147
146
|
default_member_permissions: command.defaultMemberPermissions,
|
148
|
-
default_permissions: command.defaultPermission,
|
149
147
|
type: command.type,
|
150
148
|
nsfw: command.nsfw,
|
151
149
|
})),
|
@@ -160,7 +158,7 @@ class Client extends node_events_1.default {
|
|
160
158
|
: this.shardsCount;
|
161
159
|
for (let i = 0; i < this.shardsCount; i++)
|
162
160
|
this.shards.set(i, new gateway_1.Shard(i, this));
|
163
|
-
this.shards.connect();
|
161
|
+
this.shards.forEach((shard) => shard.connect());
|
164
162
|
}
|
165
163
|
/** https://discord.com/developers/docs/monetization/entitlements#consume-an-entitlement */
|
166
164
|
consumeEntitlement(applicationID, entitlementID) {
|
@@ -174,23 +172,9 @@ class Client extends node_events_1.default {
|
|
174
172
|
event_type: options.eventType,
|
175
173
|
trigger_type: options.triggerType,
|
176
174
|
trigger_metadata: options.triggerMetadata !== undefined
|
177
|
-
?
|
178
|
-
keyword_filter: options.triggerMetadata.keywordFilter,
|
179
|
-
regex_patterns: options.triggerMetadata.regexPatterns,
|
180
|
-
presets: options.triggerMetadata.presets,
|
181
|
-
allow_list: options.triggerMetadata.allowList,
|
182
|
-
mention_total_limit: options.triggerMetadata.mentionTotalLimit,
|
183
|
-
mention_raid_protection: options.triggerMetadata.mentionRaidProtection,
|
184
|
-
}
|
175
|
+
? transformers_1.AutoModeration.triggerMetadataToRaw(options.triggerMetadata)
|
185
176
|
: undefined,
|
186
|
-
actions: options.actions.map((action) => (
|
187
|
-
type: action.type,
|
188
|
-
metadata: {
|
189
|
-
channel_id: action.metadata.channelID,
|
190
|
-
duration_seconds: action.metadata.durationSeconds,
|
191
|
-
custom_message: action.metadata.customMessage,
|
192
|
-
},
|
193
|
-
})),
|
177
|
+
actions: options.actions.map((action) => transformers_1.AutoModeration.actionToRaw(action)),
|
194
178
|
enabled: options.enabled,
|
195
179
|
exempt_roles: options.exemptRoles,
|
196
180
|
exempt_channels: options.exemptChannels,
|
@@ -279,7 +263,6 @@ class Client extends node_events_1.default {
|
|
279
263
|
description_localizations: options.descriptionLocalizations,
|
280
264
|
options: options.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
|
281
265
|
default_member_permissions: options.defaultMemberPermissions,
|
282
|
-
default_permissions: options.defaultPermission,
|
283
266
|
integration_types: options.integrationTypes,
|
284
267
|
contexts: options.contexts,
|
285
268
|
type: options.type,
|
@@ -289,7 +272,7 @@ class Client extends node_events_1.default {
|
|
289
272
|
return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
|
290
273
|
}
|
291
274
|
/** https://discord.com/developers/docs/resources/user#create-group-dm */
|
292
|
-
async
|
275
|
+
async createGroup(options) {
|
293
276
|
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.userChannels(), {
|
294
277
|
json: {
|
295
278
|
access_tokens: options.accessTokens,
|
@@ -340,7 +323,6 @@ class Client extends node_events_1.default {
|
|
340
323
|
description_localizations: options.descriptionLocalizations,
|
341
324
|
options: options.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
|
342
325
|
default_member_permissions: options.defaultMemberPermissions,
|
343
|
-
default_permissions: options.defaultPermission,
|
344
326
|
type: options.type,
|
345
327
|
nsfw: options.nsfw,
|
346
328
|
},
|
@@ -840,7 +822,7 @@ class Client extends node_events_1.default {
|
|
840
822
|
});
|
841
823
|
}
|
842
824
|
disconnect() {
|
843
|
-
this.shards.disconnect();
|
825
|
+
this.shards.forEach((shard) => shard.disconnect());
|
844
826
|
}
|
845
827
|
/** https://discord.com/developers/docs/resources/auto-moderation#modify-auto-moderation-rule */
|
846
828
|
async editAutoModerationRule(guildID, autoModerationRuleID, options, reason) {
|
@@ -850,23 +832,9 @@ class Client extends node_events_1.default {
|
|
850
832
|
event_type: options.eventType,
|
851
833
|
trigger_type: options.triggerType,
|
852
834
|
trigger_metadata: options.triggerMetadata !== undefined
|
853
|
-
?
|
854
|
-
keyword_filter: options.triggerMetadata.keywordFilter,
|
855
|
-
regex_patterns: options.triggerMetadata.regexPatterns,
|
856
|
-
presets: options.triggerMetadata.presets,
|
857
|
-
allow_list: options.triggerMetadata.allowList,
|
858
|
-
mention_total_limit: options.triggerMetadata.mentionTotalLimit,
|
859
|
-
mention_raid_protection: options.triggerMetadata.mentionRaidProtection,
|
860
|
-
}
|
835
|
+
? transformers_1.AutoModeration.triggerMetadataToRaw(options.triggerMetadata)
|
861
836
|
: undefined,
|
862
|
-
actions: options.actions?.map((action) => (
|
863
|
-
type: action.type,
|
864
|
-
metadata: {
|
865
|
-
channel_id: action.metadata.channelID,
|
866
|
-
duration_seconds: action.metadata.durationSeconds,
|
867
|
-
custom_message: action.metadata.customMessage,
|
868
|
-
},
|
869
|
-
})),
|
837
|
+
actions: options.actions?.map((action) => transformers_1.AutoModeration.actionToRaw(action)),
|
870
838
|
enabled: options.enabled,
|
871
839
|
exempt_roles: options.exemptRoles,
|
872
840
|
exempt_channels: options.exemptChannels,
|
@@ -1015,7 +983,6 @@ class Client extends node_events_1.default {
|
|
1015
983
|
description_localizations: options.descriptionLocalizations,
|
1016
984
|
options: options.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
|
1017
985
|
default_member_permissions: options.defaultMemberPermissions,
|
1018
|
-
default_permissions: options.defaultPermission,
|
1019
986
|
integration_types: options.integrationTypes,
|
1020
987
|
contexts: options.contexts,
|
1021
988
|
nsfw: options.nsfw,
|
@@ -1062,7 +1029,6 @@ class Client extends node_events_1.default {
|
|
1062
1029
|
description_localizations: options.descriptionLocalizations,
|
1063
1030
|
options: options.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
|
1064
1031
|
default_member_permissions: options.defaultMemberPermissions,
|
1065
|
-
default_permissions: options.defaultPermission,
|
1066
1032
|
nsfw: options.nsfw,
|
1067
1033
|
},
|
1068
1034
|
});
|
@@ -1709,6 +1675,7 @@ class Client extends node_events_1.default {
|
|
1709
1675
|
return response.map((guild) => ({
|
1710
1676
|
id: guild.id,
|
1711
1677
|
name: guild.name,
|
1678
|
+
banner: guild.banner,
|
1712
1679
|
icon: guild.icon,
|
1713
1680
|
owner: guild.owner,
|
1714
1681
|
permissions: guild.permissions,
|
@@ -2152,7 +2119,7 @@ class Client extends node_events_1.default {
|
|
2152
2119
|
}
|
2153
2120
|
/** https://discord.com/developers/docs/resources/channel#leave-thread */
|
2154
2121
|
leaveThread(channelID) {
|
2155
|
-
this.rest.request(rest_1.RESTMethods.Delete, rest_1.Endpoints.threadMembers(channelID));
|
2122
|
+
this.rest.request(rest_1.RESTMethods.Delete, rest_1.Endpoints.threadMembers(channelID, "@me"));
|
2156
2123
|
}
|
2157
2124
|
/** https://discord.com/developers/docs/topics/gateway-events#update-voice-state */
|
2158
2125
|
leaveVoiceChannel(guildID) {
|
@@ -2207,7 +2174,7 @@ class Client extends node_events_1.default {
|
|
2207
2174
|
}
|
2208
2175
|
/** https://discord.com/developers/docs/topics/gateway-events#update-presence */
|
2209
2176
|
setPresence(options) {
|
2210
|
-
this.shards.updatePresence(options);
|
2177
|
+
this.shards.forEach((shard) => shard.updatePresence(options));
|
2211
2178
|
}
|
2212
2179
|
/** https://discord.com/developers/docs/resources/guild-template#sync-guild-template */
|
2213
2180
|
async syncGuildTemplate(guildID, code) {
|
package/dist/lib/constants.d.ts
CHANGED
@@ -353,6 +353,11 @@ export declare enum MessageFlags {
|
|
353
353
|
SuppressNotifications = 4096,
|
354
354
|
IsVoiceMessage = 8192
|
355
355
|
}
|
356
|
+
/** https://discord.com/developers/docs/resources/channel#message-object-message-reference-types */
|
357
|
+
export declare enum MessageReferenceTypes {
|
358
|
+
Default = 0,
|
359
|
+
Forward = 1
|
360
|
+
}
|
356
361
|
/** https://discord.com/developers/docs/resources/channel#attachment-object-attachment-flags */
|
357
362
|
export declare enum AttachmentFlags {
|
358
363
|
IsRemix = 4
|
@@ -569,6 +574,7 @@ export declare enum Services {
|
|
569
574
|
Playstation = "playstation",
|
570
575
|
Reddit = "reddit",
|
571
576
|
RiotGames = "riotgames",
|
577
|
+
Roblox = "roblox",
|
572
578
|
Spotify = "spotify",
|
573
579
|
Skype = "skype",
|
574
580
|
Steam = "steam",
|
package/dist/lib/constants.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
4
|
-
exports.EntitlementTypes = exports.SKUFlags = exports.SKUTypes = exports.MembershipState = exports.TeamMemberRoleTypes = exports.RoleFlags = exports.BitwisePermissionFlags = exports.RPCCloseEventCodes = exports.RPCErrorCodes = exports.JSONErrorCodes = exports.HTTPResponseCodes = exports.VoiceCloseEventCodes = exports.VoiceOPCodes = exports.GatewayCloseEventCodes = exports.GatewayOPCodes = exports.OAuth2Scopes = exports.ActivityFlags = exports.ActivityType = exports.GatewayEvents = exports.StatusTypes = exports.GatewayIntents = exports.DeviceType = exports.WebhookTypes = exports.VisibilityTypes = exports.Services = exports.PremiumTypes = exports.UserFlags = exports.StickerFormatTypes = exports.StickerTypes = exports.PrivacyLevel = exports.LayoutType = exports.InviteTargetTypes = void 0;
|
3
|
+
exports.GuildScheduledEventStatus = exports.GuildScheduledEventEntityTypes = exports.GuildScheduledEventPrivacyLevel = exports.ImageWidgetStyleOptions = exports.PromptTypes = exports.OnboardingMode = exports.IntegrationExpireBehaviors = exports.GuildMemberFlags = exports.MutableGuildFeatures = exports.GuildFeatures = exports.SystemChannelFlags = exports.PremiumTier = exports.GuildNSFWLevel = exports.VerificationLevel = exports.MFALevel = exports.ExplicitContentFilterLevel = exports.DefaultMessageNotificationLevel = exports.ReactionTypes = exports.AllowedMentionTypes = exports.AttachmentFlags = exports.MessageReferenceTypes = exports.MessageFlags = exports.MessageActivityTypes = exports.MessageTypes = exports.ForumLayoutTypes = exports.SortOrderTypes = exports.ChannelFlags = exports.VideoQualityModes = exports.ChannelTypes = exports.ActionTypes = exports.EventTypes = exports.KeywordPresetTypes = exports.TriggerTypes = exports.AuditLogEvents = exports.ApplicationRoleConnectionMetadataType = exports.ApplicationFlags = exports.ApplicationIntegrationTypes = exports.TextInputStyles = exports.ButtonStyles = exports.InteractionCallbackType = exports.ComponentTypes = exports.InteractionContextTypes = exports.InteractionType = exports.ApplicationCommandPermissionType = exports.ApplicationCommandOptionType = exports.ApplicationCommandTypes = exports.Locales = exports.ImageFormats = exports.GuildNavigationTypes = exports.TimestampStyles = void 0;
|
4
|
+
exports.EntitlementTypes = exports.SKUFlags = exports.SKUTypes = exports.MembershipState = exports.TeamMemberRoleTypes = exports.RoleFlags = exports.BitwisePermissionFlags = exports.RPCCloseEventCodes = exports.RPCErrorCodes = exports.JSONErrorCodes = exports.HTTPResponseCodes = exports.VoiceCloseEventCodes = exports.VoiceOPCodes = exports.GatewayCloseEventCodes = exports.GatewayOPCodes = exports.OAuth2Scopes = exports.ActivityFlags = exports.ActivityType = exports.GatewayEvents = exports.StatusTypes = exports.GatewayIntents = exports.DeviceType = exports.WebhookTypes = exports.VisibilityTypes = exports.Services = exports.PremiumTypes = exports.UserFlags = exports.StickerFormatTypes = exports.StickerTypes = exports.PrivacyLevel = exports.LayoutType = exports.InviteTargetTypes = exports.InviteTypes = void 0;
|
5
5
|
/** https://discord.com/developers/docs/reference#message-formatting-timestamp-styles */
|
6
6
|
var TimestampStyles;
|
7
7
|
(function (TimestampStyles) {
|
@@ -386,6 +386,12 @@ var MessageFlags;
|
|
386
386
|
MessageFlags[MessageFlags["SuppressNotifications"] = 4096] = "SuppressNotifications";
|
387
387
|
MessageFlags[MessageFlags["IsVoiceMessage"] = 8192] = "IsVoiceMessage";
|
388
388
|
})(MessageFlags || (exports.MessageFlags = MessageFlags = {}));
|
389
|
+
/** https://discord.com/developers/docs/resources/channel#message-object-message-reference-types */
|
390
|
+
var MessageReferenceTypes;
|
391
|
+
(function (MessageReferenceTypes) {
|
392
|
+
MessageReferenceTypes[MessageReferenceTypes["Default"] = 0] = "Default";
|
393
|
+
MessageReferenceTypes[MessageReferenceTypes["Forward"] = 1] = "Forward";
|
394
|
+
})(MessageReferenceTypes || (exports.MessageReferenceTypes = MessageReferenceTypes = {}));
|
389
395
|
/** https://discord.com/developers/docs/resources/channel#attachment-object-attachment-flags */
|
390
396
|
var AttachmentFlags;
|
391
397
|
(function (AttachmentFlags) {
|
@@ -631,6 +637,7 @@ var Services;
|
|
631
637
|
Services["Playstation"] = "playstation";
|
632
638
|
Services["Reddit"] = "reddit";
|
633
639
|
Services["RiotGames"] = "riotgames";
|
640
|
+
Services["Roblox"] = "roblox";
|
634
641
|
Services["Spotify"] = "spotify";
|
635
642
|
Services["Skype"] = "skype";
|
636
643
|
Services["Steam"] = "steam";
|
@@ -38,12 +38,14 @@ class Shard {
|
|
38
38
|
client;
|
39
39
|
ws;
|
40
40
|
sessionID;
|
41
|
+
resumeGatewayURL;
|
41
42
|
constructor(id, client) {
|
42
43
|
this.id = id;
|
43
44
|
this.heartbeatInterval = null;
|
44
45
|
this.client = client;
|
45
46
|
this.ws = new ws_1.default("wss://gateway.discord.gg/?v=10&encoding=json", client.ws);
|
46
47
|
this.sessionID = null;
|
48
|
+
this.resumeGatewayURL = null;
|
47
49
|
}
|
48
50
|
/** https://discord.com/developers/docs/topics/gateway#connections */
|
49
51
|
connect() {
|
@@ -86,11 +88,12 @@ class Shard {
|
|
86
88
|
}));
|
87
89
|
}
|
88
90
|
onDispatch(packet) {
|
89
|
-
this.client.emit("dispatch", packet);
|
91
|
+
this.client.emit("dispatch", packet, this.id);
|
90
92
|
switch (packet.t) {
|
91
93
|
case constants_1.GatewayEvents.Ready:
|
92
94
|
{
|
93
95
|
this.sessionID = packet.d.session_id;
|
96
|
+
this.resumeGatewayURL = packet.d.resume_gateway_url;
|
94
97
|
this.client.user = transformers_1.Users.userFromRaw(packet.d.user);
|
95
98
|
this.client.application = packet.d.application;
|
96
99
|
this.client.emit("ready");
|
@@ -542,9 +545,12 @@ class Shard {
|
|
542
545
|
case constants_1.GatewayOPCodes.Hello:
|
543
546
|
{
|
544
547
|
this.heartbeatInterval = setInterval(() => this.heartbeat(null), packet.d.heartbeat_interval);
|
545
|
-
this.client.emit("hello");
|
548
|
+
this.client.emit("hello", packet.d.heartbeat_interval, this.id);
|
546
549
|
}
|
547
550
|
break;
|
551
|
+
case constants_1.GatewayOPCodes.HeartbeatACK:
|
552
|
+
this.client.emit("heartbeatACK", this.id);
|
553
|
+
break;
|
548
554
|
}
|
549
555
|
}
|
550
556
|
onWebSocketError(err) {
|
@@ -1,5 +1,9 @@
|
|
1
|
-
import type { AutoModerationRule, RawAutoModerationRule } from "../types/auto-moderation";
|
1
|
+
import type { AutoModerationAction, AutoModerationRule, RawAutoModerationAction, RawAutoModerationRule, RawTriggerMetadata, TriggerMetadata } from "../types/auto-moderation";
|
2
2
|
export declare class AutoModeration {
|
3
|
+
static actionFromRaw(action: RawAutoModerationAction): AutoModerationAction;
|
4
|
+
static actionToRaw(action: AutoModerationAction): RawAutoModerationAction;
|
3
5
|
static autoModerationRuleFromRaw(autoModerationRule: RawAutoModerationRule): AutoModerationRule;
|
4
6
|
static autoModerationRuleToRaw(autoModerationRule: AutoModerationRule): RawAutoModerationRule;
|
7
|
+
static triggerMetadataFromRaw(triggerMetadata: RawTriggerMetadata): TriggerMetadata;
|
8
|
+
static triggerMetadataToRaw(triggerMetadata: TriggerMetadata): RawTriggerMetadata;
|
5
9
|
}
|
@@ -2,6 +2,26 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.AutoModeration = void 0;
|
4
4
|
class AutoModeration {
|
5
|
+
static actionFromRaw(action) {
|
6
|
+
return {
|
7
|
+
type: action.type,
|
8
|
+
metadata: {
|
9
|
+
channelID: action.metadata.channel_id,
|
10
|
+
durationSeconds: action.metadata.duration_seconds,
|
11
|
+
customMessage: action.metadata.custom_message,
|
12
|
+
},
|
13
|
+
};
|
14
|
+
}
|
15
|
+
static actionToRaw(action) {
|
16
|
+
return {
|
17
|
+
type: action.type,
|
18
|
+
metadata: {
|
19
|
+
channel_id: action.metadata.channelID,
|
20
|
+
duration_seconds: action.metadata.durationSeconds,
|
21
|
+
custom_message: action.metadata.customMessage,
|
22
|
+
},
|
23
|
+
};
|
24
|
+
}
|
5
25
|
static autoModerationRuleFromRaw(autoModerationRule) {
|
6
26
|
return {
|
7
27
|
id: autoModerationRule.id,
|
@@ -10,22 +30,8 @@ class AutoModeration {
|
|
10
30
|
creatorID: autoModerationRule.creator_id,
|
11
31
|
eventType: autoModerationRule.event_type,
|
12
32
|
triggerType: autoModerationRule.trigger_type,
|
13
|
-
triggerMetadata:
|
14
|
-
|
15
|
-
regexPatterns: autoModerationRule.trigger_metadata.regex_patterns,
|
16
|
-
presets: autoModerationRule.trigger_metadata.presets,
|
17
|
-
allowList: autoModerationRule.trigger_metadata.allow_list,
|
18
|
-
mentionTotalLimit: autoModerationRule.trigger_metadata.mention_total_limit,
|
19
|
-
mentionRaidProtection: autoModerationRule.trigger_metadata.mention_raid_protection,
|
20
|
-
},
|
21
|
-
actions: autoModerationRule.actions.map((action) => ({
|
22
|
-
type: action.type,
|
23
|
-
metadata: {
|
24
|
-
channelID: action.metadata.channel_id,
|
25
|
-
durationSeconds: action.metadata.duration_seconds,
|
26
|
-
customMessage: action.metadata.custom_message,
|
27
|
-
},
|
28
|
-
})),
|
33
|
+
triggerMetadata: this.triggerMetadataFromRaw(autoModerationRule.trigger_metadata),
|
34
|
+
actions: autoModerationRule.actions.map((action) => this.actionFromRaw(action)),
|
29
35
|
enabled: autoModerationRule.enabled,
|
30
36
|
exemptRoles: autoModerationRule.exempt_roles,
|
31
37
|
exemptChannels: autoModerationRule.exempt_channels,
|
@@ -39,26 +45,32 @@ class AutoModeration {
|
|
39
45
|
creator_id: autoModerationRule.creatorID,
|
40
46
|
event_type: autoModerationRule.eventType,
|
41
47
|
trigger_type: autoModerationRule.triggerType,
|
42
|
-
trigger_metadata:
|
43
|
-
|
44
|
-
regex_patterns: autoModerationRule.triggerMetadata.regexPatterns,
|
45
|
-
presets: autoModerationRule.triggerMetadata.presets,
|
46
|
-
allow_list: autoModerationRule.triggerMetadata.allowList,
|
47
|
-
mention_total_limit: autoModerationRule.triggerMetadata.mentionTotalLimit,
|
48
|
-
mention_raid_protection: autoModerationRule.triggerMetadata.mentionRaidProtection,
|
49
|
-
},
|
50
|
-
actions: autoModerationRule.actions.map((action) => ({
|
51
|
-
type: action.type,
|
52
|
-
metadata: {
|
53
|
-
channel_id: action.metadata.channelID,
|
54
|
-
duration_seconds: action.metadata.durationSeconds,
|
55
|
-
custom_message: action.metadata.customMessage,
|
56
|
-
},
|
57
|
-
})),
|
48
|
+
trigger_metadata: this.triggerMetadataToRaw(autoModerationRule.triggerMetadata),
|
49
|
+
actions: autoModerationRule.actions.map((action) => this.actionToRaw(action)),
|
58
50
|
enabled: autoModerationRule.enabled,
|
59
51
|
exempt_roles: autoModerationRule.exemptRoles,
|
60
52
|
exempt_channels: autoModerationRule.exemptChannels,
|
61
53
|
};
|
62
54
|
}
|
55
|
+
static triggerMetadataFromRaw(triggerMetadata) {
|
56
|
+
return {
|
57
|
+
keywordFilter: triggerMetadata.keyword_filter,
|
58
|
+
regexPatterns: triggerMetadata.regex_patterns,
|
59
|
+
presets: triggerMetadata.presets,
|
60
|
+
allowList: triggerMetadata.allow_list,
|
61
|
+
mentionTotalLimit: triggerMetadata.mention_total_limit,
|
62
|
+
mentionRaidProtection: triggerMetadata.mention_raid_protection,
|
63
|
+
};
|
64
|
+
}
|
65
|
+
static triggerMetadataToRaw(triggerMetadata) {
|
66
|
+
return {
|
67
|
+
keyword_filter: triggerMetadata.keywordFilter,
|
68
|
+
regex_patterns: triggerMetadata.regexPatterns,
|
69
|
+
presets: triggerMetadata.presets,
|
70
|
+
allow_list: triggerMetadata.allowList,
|
71
|
+
mention_total_limit: triggerMetadata.mentionTotalLimit,
|
72
|
+
mention_raid_protection: triggerMetadata.mentionRaidProtection,
|
73
|
+
};
|
74
|
+
}
|
63
75
|
}
|
64
76
|
exports.AutoModeration = AutoModeration;
|
@@ -499,6 +499,7 @@ class Channels {
|
|
499
499
|
? Applications_1.Applications.applicationFromRaw(message.application)
|
500
500
|
: undefined,
|
501
501
|
applicationID: message.application_id,
|
502
|
+
flags: message.flags,
|
502
503
|
messageReference: message.message_reference !== undefined
|
503
504
|
? {
|
504
505
|
messageID: message.message_reference.message_id,
|
@@ -507,7 +508,19 @@ class Channels {
|
|
507
508
|
failIfNotExists: message.message_reference.fail_if_not_exists,
|
508
509
|
}
|
509
510
|
: undefined,
|
510
|
-
|
511
|
+
messageSnapshots: message.message_snapshots?.map((messageSnapshot) => ({
|
512
|
+
message: {
|
513
|
+
type: messageSnapshot.message.type,
|
514
|
+
content: messageSnapshot.message.content,
|
515
|
+
embeds: messageSnapshot.message.embeds.map((embed) => this.embedFromRaw(embed)),
|
516
|
+
attachments: messageSnapshot.message.attachments.map((attachment) => this.attachmentFromRaw(attachment)),
|
517
|
+
timestamp: messageSnapshot.message.timestamp,
|
518
|
+
editedTimestamp: messageSnapshot.message.edited_timestamp,
|
519
|
+
flags: messageSnapshot.message.flags,
|
520
|
+
mentions: messageSnapshot.message.mentions.map((user) => Users_1.Users.userFromRaw(user)),
|
521
|
+
mentionRoles: messageSnapshot.message.mention_roles,
|
522
|
+
},
|
523
|
+
})),
|
511
524
|
referencedMessage: message.referenced_message !== undefined
|
512
525
|
? message.referenced_message !== null
|
513
526
|
? Channels.messageFromRaw(message.referenced_message)
|
@@ -594,6 +607,7 @@ class Channels {
|
|
594
607
|
? Applications_1.Applications.applicationToRaw(message.application)
|
595
608
|
: undefined,
|
596
609
|
application_id: message.applicationID,
|
610
|
+
flags: message.flags,
|
597
611
|
message_reference: message.messageReference !== undefined
|
598
612
|
? {
|
599
613
|
message_id: message.messageReference.messageID,
|
@@ -602,7 +616,19 @@ class Channels {
|
|
602
616
|
fail_if_not_exists: message.messageReference.failIfNotExists,
|
603
617
|
}
|
604
618
|
: undefined,
|
605
|
-
|
619
|
+
message_snapshots: message.messageSnapshots?.map((messageSnapshot) => ({
|
620
|
+
message: {
|
621
|
+
type: messageSnapshot.message.type,
|
622
|
+
content: messageSnapshot.message.content,
|
623
|
+
embeds: messageSnapshot.message.embeds.map((embed) => this.embedToRaw(embed)),
|
624
|
+
attachments: messageSnapshot.message.attachments.map((attachment) => this.attachmentToRaw(attachment)),
|
625
|
+
timestamp: messageSnapshot.message.timestamp,
|
626
|
+
edited_timestamp: messageSnapshot.message.editedTimestamp,
|
627
|
+
flags: messageSnapshot.message.flags,
|
628
|
+
mentions: messageSnapshot.message.mentions.map((user) => Users_1.Users.userToRaw(user)),
|
629
|
+
mention_roles: messageSnapshot.message.mentionRoles,
|
630
|
+
},
|
631
|
+
})),
|
606
632
|
referenced_message: message.referencedMessage !== undefined
|
607
633
|
? message.referencedMessage !== null
|
608
634
|
? Channels.messageToRaw(message.referencedMessage)
|
@@ -103,6 +103,14 @@ class Guilds {
|
|
103
103
|
pending: guildMember.pending,
|
104
104
|
permissions: guildMember.permissions,
|
105
105
|
communicationDisabledUntil: guildMember.communication_disabled_until,
|
106
|
+
avatarDecorationData: guildMember.avatar_decoration_data !== undefined
|
107
|
+
? guildMember.avatar_decoration_data !== null
|
108
|
+
? {
|
109
|
+
asset: guildMember.avatar_decoration_data.asset,
|
110
|
+
skuID: guildMember.avatar_decoration_data.sku_id,
|
111
|
+
}
|
112
|
+
: null
|
113
|
+
: undefined,
|
106
114
|
};
|
107
115
|
}
|
108
116
|
static guildMemberToRaw(guildMember) {
|
@@ -121,6 +129,14 @@ class Guilds {
|
|
121
129
|
pending: guildMember.pending,
|
122
130
|
permissions: guildMember.permissions,
|
123
131
|
communication_disabled_until: guildMember.communicationDisabledUntil,
|
132
|
+
avatar_decoration_data: guildMember.avatarDecorationData !== undefined
|
133
|
+
? guildMember.avatarDecorationData !== null
|
134
|
+
? {
|
135
|
+
asset: guildMember.avatarDecorationData.asset,
|
136
|
+
sku_id: guildMember.avatarDecorationData.skuID,
|
137
|
+
}
|
138
|
+
: null
|
139
|
+
: undefined,
|
124
140
|
};
|
125
141
|
}
|
126
142
|
static guildToRaw(guild) {
|
@@ -1,8 +1,5 @@
|
|
1
1
|
import type { RawPresenceUpdateEventFields, PresenceUpdateEventFields } from "../types/gateway-events";
|
2
|
-
import type { RawUser, User } from "../types/user";
|
3
2
|
export declare class Presences {
|
4
3
|
static presenceFromRaw(presence: RawPresenceUpdateEventFields): PresenceUpdateEventFields;
|
5
4
|
static presenceToRaw(presence: PresenceUpdateEventFields): RawPresenceUpdateEventFields;
|
6
|
-
static presenceUserFromRaw(user: Pick<RawUser, "id"> & Partial<RawUser>): Pick<User, "id"> & Partial<User>;
|
7
|
-
static presenceUserToRaw(user: Pick<User, "id"> & Partial<User>): Pick<RawUser, "id"> & Partial<RawUser>;
|
8
5
|
}
|
@@ -4,7 +4,32 @@ exports.Presences = void 0;
|
|
4
4
|
class Presences {
|
5
5
|
static presenceFromRaw(presence) {
|
6
6
|
return {
|
7
|
-
user:
|
7
|
+
user: {
|
8
|
+
id: presence.user.id,
|
9
|
+
username: presence.user.username,
|
10
|
+
discriminator: presence.user.discriminator,
|
11
|
+
globalName: presence.user.global_name,
|
12
|
+
avatar: presence.user.avatar,
|
13
|
+
bot: presence.user.bot,
|
14
|
+
system: presence.user.system,
|
15
|
+
mfaEnabled: presence.user.mfa_enabled,
|
16
|
+
banner: presence.user.banner,
|
17
|
+
accentColor: presence.user.accent_color,
|
18
|
+
locale: presence.user.locale,
|
19
|
+
verified: presence.user.verified,
|
20
|
+
email: presence.user.email,
|
21
|
+
flags: presence.user.flags,
|
22
|
+
premiumType: presence.user.premium_type,
|
23
|
+
publicFlags: presence.user.public_flags,
|
24
|
+
avatarDecorationData: presence.user.avatar_decoration_data !== undefined
|
25
|
+
? presence.user.avatar_decoration_data !== null
|
26
|
+
? {
|
27
|
+
asset: presence.user.avatar_decoration_data.asset,
|
28
|
+
skuID: presence.user.avatar_decoration_data.sku_id,
|
29
|
+
}
|
30
|
+
: null
|
31
|
+
: undefined,
|
32
|
+
},
|
8
33
|
guildID: presence.guild_id,
|
9
34
|
status: presence.status,
|
10
35
|
activities: presence.activities.map((activity) => ({
|
@@ -34,7 +59,32 @@ class Presences {
|
|
34
59
|
}
|
35
60
|
static presenceToRaw(presence) {
|
36
61
|
return {
|
37
|
-
user:
|
62
|
+
user: {
|
63
|
+
id: presence.user.id,
|
64
|
+
username: presence.user.username,
|
65
|
+
discriminator: presence.user.discriminator,
|
66
|
+
global_name: presence.user.globalName,
|
67
|
+
avatar: presence.user.avatar,
|
68
|
+
bot: presence.user.bot,
|
69
|
+
system: presence.user.system,
|
70
|
+
mfa_enabled: presence.user.mfaEnabled,
|
71
|
+
banner: presence.user.banner,
|
72
|
+
accent_color: presence.user.accentColor,
|
73
|
+
locale: presence.user.locale,
|
74
|
+
verified: presence.user.verified,
|
75
|
+
email: presence.user.email,
|
76
|
+
flags: presence.user.flags,
|
77
|
+
premium_type: presence.user.premiumType,
|
78
|
+
public_flags: presence.user.publicFlags,
|
79
|
+
avatar_decoration_data: presence.user.avatarDecorationData !== undefined
|
80
|
+
? presence.user.avatarDecorationData !== null
|
81
|
+
? {
|
82
|
+
asset: presence.user.avatarDecorationData.asset,
|
83
|
+
sku_id: presence.user.avatarDecorationData.skuID,
|
84
|
+
}
|
85
|
+
: null
|
86
|
+
: undefined,
|
87
|
+
},
|
38
88
|
guild_id: presence.guildID,
|
39
89
|
status: presence.status,
|
40
90
|
activities: presence.activities.map((activity) => ({
|
@@ -62,47 +112,5 @@ class Presences {
|
|
62
112
|
client_status: presence.clientStatus,
|
63
113
|
};
|
64
114
|
}
|
65
|
-
static presenceUserFromRaw(user) {
|
66
|
-
return {
|
67
|
-
id: user.id,
|
68
|
-
username: user.username,
|
69
|
-
discriminator: user.discriminator,
|
70
|
-
globalName: user.global_name,
|
71
|
-
avatar: user.avatar,
|
72
|
-
bot: user.bot,
|
73
|
-
system: user.system,
|
74
|
-
mfaEnabled: user.mfa_enabled,
|
75
|
-
banner: user.banner,
|
76
|
-
accentColor: user.accent_color,
|
77
|
-
locale: user.locale,
|
78
|
-
verified: user.verified,
|
79
|
-
email: user.email,
|
80
|
-
flags: user.flags,
|
81
|
-
premiumType: user.premium_type,
|
82
|
-
publicFlags: user.public_flags,
|
83
|
-
avatarDecoration: user.avatar_decoration,
|
84
|
-
};
|
85
|
-
}
|
86
|
-
static presenceUserToRaw(user) {
|
87
|
-
return {
|
88
|
-
id: user.id,
|
89
|
-
username: user.username,
|
90
|
-
discriminator: user.discriminator,
|
91
|
-
global_name: user.globalName,
|
92
|
-
avatar: user.avatar,
|
93
|
-
bot: user.bot,
|
94
|
-
system: user.system,
|
95
|
-
mfa_enabled: user.mfaEnabled,
|
96
|
-
banner: user.banner,
|
97
|
-
accent_color: user.accentColor,
|
98
|
-
locale: user.locale,
|
99
|
-
verified: user.verified,
|
100
|
-
email: user.email,
|
101
|
-
flags: user.flags,
|
102
|
-
premium_type: user.premiumType,
|
103
|
-
public_flags: user.publicFlags,
|
104
|
-
avatar_decoration: user.avatarDecoration,
|
105
|
-
};
|
106
|
-
}
|
107
115
|
}
|
108
116
|
exports.Presences = Presences;
|
@@ -20,7 +20,14 @@ class Users {
|
|
20
20
|
flags: user.flags,
|
21
21
|
premiumType: user.premium_type,
|
22
22
|
publicFlags: user.public_flags,
|
23
|
-
|
23
|
+
avatarDecorationData: user.avatar_decoration_data !== undefined
|
24
|
+
? user.avatar_decoration_data !== null
|
25
|
+
? {
|
26
|
+
asset: user.avatar_decoration_data.asset,
|
27
|
+
skuID: user.avatar_decoration_data.sku_id,
|
28
|
+
}
|
29
|
+
: null
|
30
|
+
: undefined,
|
24
31
|
};
|
25
32
|
}
|
26
33
|
static userToRaw(user) {
|
@@ -41,7 +48,14 @@ class Users {
|
|
41
48
|
flags: user.flags,
|
42
49
|
premium_type: user.premiumType,
|
43
50
|
public_flags: user.publicFlags,
|
44
|
-
|
51
|
+
avatar_decoration_data: user.avatarDecorationData !== undefined
|
52
|
+
? user.avatarDecorationData !== null
|
53
|
+
? {
|
54
|
+
asset: user.avatarDecorationData.asset,
|
55
|
+
sku_id: user.avatarDecorationData.skuID,
|
56
|
+
}
|
57
|
+
: null
|
58
|
+
: undefined,
|
45
59
|
};
|
46
60
|
}
|
47
61
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { AllowedMentionTypes, ApplicationIntegrationTypes, AttachmentFlags, ChannelFlags, ChannelTypes, ForumLayoutTypes, InteractionType, MessageActivityTypes, MessageFlags, MessageTypes, SortOrderTypes, VideoQualityModes } from "../constants";
|
1
|
+
import type { AllowedMentionTypes, ApplicationIntegrationTypes, AttachmentFlags, ChannelFlags, ChannelTypes, ForumLayoutTypes, InteractionType, MessageActivityTypes, MessageFlags, MessageReferenceTypes, MessageTypes, SortOrderTypes, VideoQualityModes } from "../constants";
|
2
2
|
import type { RawApplication, Application } from "./application";
|
3
3
|
import type { snowflake, timestamp } from "./common";
|
4
4
|
import type { RawEmoji, Emoji } from "./emoji";
|
@@ -69,8 +69,9 @@ export interface RawMessage {
|
|
69
69
|
activity?: RawMessageActivity;
|
70
70
|
application?: RawApplication;
|
71
71
|
application_id?: snowflake;
|
72
|
-
message_reference?: RawMessageReference;
|
73
72
|
flags?: MessageFlags;
|
73
|
+
message_reference?: RawMessageReference;
|
74
|
+
message_snapshots?: Array<RawMessageSnapshot>;
|
74
75
|
referenced_message?: RawMessage | null;
|
75
76
|
interaction_metadata?: RawMessageInteractionMetadata;
|
76
77
|
interaction?: RawMessageInteraction;
|
@@ -106,11 +107,16 @@ export interface RawMessageCall {
|
|
106
107
|
}
|
107
108
|
/** https://discord.com/developers/docs/resources/channel#message-reference-object-message-reference-structure */
|
108
109
|
export interface RawMessageReference {
|
110
|
+
type?: MessageReferenceTypes;
|
109
111
|
message_id?: snowflake;
|
110
112
|
channel_id?: snowflake;
|
111
113
|
guild_id?: snowflake;
|
112
114
|
fail_if_not_exists?: boolean;
|
113
115
|
}
|
116
|
+
/** https://discord.com/developers/docs/resources/channel#message-snapshot-object-message-snapshot-structure */
|
117
|
+
export interface RawMessageSnapshot {
|
118
|
+
message: Pick<RawMessage, "type" | "content" | "embeds" | "attachments" | "timestamp" | "edited_timestamp" | "flags" | "mentions" | "mention_roles">;
|
119
|
+
}
|
114
120
|
/** https://discord.com/developers/docs/resources/channel#followed-channel-object-followed-channel-structure */
|
115
121
|
export interface RawFollowedChannel {
|
116
122
|
channel_id: snowflake;
|
@@ -325,8 +331,9 @@ export interface Message {
|
|
325
331
|
activity?: MessageActivity;
|
326
332
|
application?: Application;
|
327
333
|
applicationID?: snowflake;
|
328
|
-
messageReference?: MessageReference;
|
329
334
|
flags?: MessageFlags;
|
335
|
+
messageReference?: MessageReference;
|
336
|
+
messageSnapshots?: Array<MessageSnapshot>;
|
330
337
|
referencedMessage?: Message | null;
|
331
338
|
interactionMetadata?: MessageInteractionMetadata;
|
332
339
|
interaction?: MessageInteraction;
|
@@ -358,11 +365,15 @@ export interface MessageCall {
|
|
358
365
|
endedTimestamp?: timestamp | null;
|
359
366
|
}
|
360
367
|
export interface MessageReference {
|
368
|
+
type?: MessageReferenceTypes;
|
361
369
|
messageID?: snowflake;
|
362
370
|
channelID?: snowflake;
|
363
371
|
guildID?: snowflake;
|
364
372
|
failIfNotExists?: boolean;
|
365
373
|
}
|
374
|
+
export interface MessageSnapshot {
|
375
|
+
message: Pick<Message, "type" | "content" | "embeds" | "attachments" | "timestamp" | "editedTimestamp" | "flags" | "mentions" | "mentionRoles">;
|
376
|
+
}
|
366
377
|
export interface FollowedChannel {
|
367
378
|
channelID: snowflake;
|
368
379
|
webhookID: snowflake;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { ActivityFlags, ActivityType, GatewayIntents, GatewayOPCodes, GuildMemberFlags, InviteTargetTypes, ReactionTypes, StatusTypes, TriggerTypes } from "../constants";
|
1
|
+
import type { ActivityFlags, ActivityType, GatewayEvents, GatewayIntents, GatewayOPCodes, GuildMemberFlags, InviteTargetTypes, ReactionTypes, StatusTypes, TriggerTypes } from "../constants";
|
2
2
|
import type { RawApplication, Application } from "./application";
|
3
3
|
import type { RawAutoModerationAction, AutoModerationAction } from "./auto-moderation";
|
4
4
|
import type { RawChannel, RawThreadMember, Channel, ThreadMember } from "./channel";
|
@@ -11,10 +11,10 @@ import type { RawUser, RawAvatarDecorationData, User, AvatarDecorationData } fro
|
|
11
11
|
import type { RawVoiceState, VoiceState } from "./voice";
|
12
12
|
/** https://discord.com/developers/docs/topics/gateway-events#payload-structure */
|
13
13
|
export interface RawPayload {
|
14
|
-
op:
|
14
|
+
op: GatewayOPCodes;
|
15
15
|
d: any | null;
|
16
16
|
s: number | null;
|
17
|
-
t:
|
17
|
+
t: GatewayEvents | null;
|
18
18
|
}
|
19
19
|
/** https://discord.com/developers/docs/topics/gateway-events#identify-identify-structure */
|
20
20
|
export interface RawIdentify {
|
@@ -356,7 +356,7 @@ export interface Payload {
|
|
356
356
|
op: GatewayOPCodes;
|
357
357
|
d: any | null;
|
358
358
|
s: number | null;
|
359
|
-
t:
|
359
|
+
t: GatewayEvents | null;
|
360
360
|
}
|
361
361
|
export interface Identify {
|
362
362
|
token: string;
|
@@ -4,7 +4,7 @@ import type { snowflake, timestamp } from "./common";
|
|
4
4
|
import type { RawEmoji, Emoji } from "./emoji";
|
5
5
|
import type { RawRole, Role } from "./role";
|
6
6
|
import type { RawSticker, Sticker } from "./sticker";
|
7
|
-
import type { RawUser, User } from "./user";
|
7
|
+
import type { AvatarDecorationData, RawAvatarDecorationData, RawUser, User } from "./user";
|
8
8
|
/** https://discord.com/developers/docs/resources/guild#guild-object-guild-structure */
|
9
9
|
export interface RawGuild {
|
10
10
|
id: snowflake;
|
@@ -98,6 +98,7 @@ export interface RawGuildMember {
|
|
98
98
|
pending?: boolean;
|
99
99
|
permissions?: string;
|
100
100
|
communication_disabled_until?: number | null;
|
101
|
+
avatar_decoration_data?: RawAvatarDecorationData | null;
|
101
102
|
}
|
102
103
|
/** https://discord.com/developers/docs/resources/guild#integration-object-integration-structure */
|
103
104
|
export interface RawIntegration {
|
@@ -265,6 +266,7 @@ export interface GuildMember {
|
|
265
266
|
pending?: boolean;
|
266
267
|
permissions?: string;
|
267
268
|
communicationDisabledUntil?: number | null;
|
269
|
+
avatarDecorationData?: AvatarDecorationData | null;
|
268
270
|
}
|
269
271
|
export interface Integration {
|
270
272
|
id: snowflake;
|
package/dist/lib/types/user.d.ts
CHANGED
@@ -20,7 +20,7 @@ export interface RawUser {
|
|
20
20
|
flags?: UserFlags;
|
21
21
|
premium_type?: PremiumTypes;
|
22
22
|
public_flags?: UserFlags;
|
23
|
-
|
23
|
+
avatar_decoration_data?: RawAvatarDecorationData | null;
|
24
24
|
}
|
25
25
|
/** https://discord.com/developers/docs/resources/user#avatar-decoration-data-object-avatar-decoration-data-structure */
|
26
26
|
export interface RawAvatarDecorationData {
|
@@ -63,7 +63,7 @@ export interface User {
|
|
63
63
|
flags?: UserFlags;
|
64
64
|
premiumType?: PremiumTypes;
|
65
65
|
publicFlags?: UserFlags;
|
66
|
-
|
66
|
+
avatarDecorationData?: AvatarDecorationData | null;
|
67
67
|
}
|
68
68
|
export interface AvatarDecorationData {
|
69
69
|
asset: string;
|
package/dist/lib/utils/errors.js
CHANGED
@@ -11,7 +11,7 @@ class RESTError extends Error {
|
|
11
11
|
this.endpoint = endpoint;
|
12
12
|
}
|
13
13
|
static flattenErrors(errors, prefix = "") {
|
14
|
-
let
|
14
|
+
let message = "";
|
15
15
|
if (errors) {
|
16
16
|
for (const [key, value] of Object.entries(errors)) {
|
17
17
|
if (errors.hasOwnProperty(key)) {
|
@@ -20,17 +20,17 @@ class RESTError extends Error {
|
|
20
20
|
if (typeof error === "object" &&
|
21
21
|
error !== null &&
|
22
22
|
"message" in error) {
|
23
|
-
|
23
|
+
message += `${prefix ? `${prefix}: [${error.code}]` : `[${error.code}]`} ${error.message}\n`;
|
24
24
|
}
|
25
25
|
}
|
26
26
|
}
|
27
27
|
else if (typeof value === "object" && value !== null) {
|
28
|
-
|
28
|
+
message += this.flattenErrors(value, prefix ? `${prefix}.${key}` : key);
|
29
29
|
}
|
30
30
|
}
|
31
31
|
}
|
32
32
|
}
|
33
|
-
return
|
33
|
+
return message;
|
34
34
|
}
|
35
35
|
}
|
36
36
|
exports.RESTError = RESTError;
|
@@ -1,9 +1,16 @@
|
|
1
1
|
import type { GuildNavigationTypes, TimestampStyles } from "../constants";
|
2
2
|
import type { snowflake } from "../types/common";
|
3
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
3
4
|
export declare function userMention(userID: snowflake): string;
|
5
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
4
6
|
export declare function channelMention(channelID: snowflake): string;
|
7
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
5
8
|
export declare function roleMention(roleID: snowflake): string;
|
9
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
6
10
|
export declare function slashCommandMention(commandName: string, commandID: snowflake, subCommandName?: string, subCommandGroupName?: string): string;
|
11
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
7
12
|
export declare function customEmoji(emojiName: string, emojiID: snowflake, animated?: boolean): string;
|
13
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
8
14
|
export declare function unixTimestamp(time: number, style?: TimestampStyles): string;
|
15
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
9
16
|
export declare function guildNavigation(guildID: snowflake, type: GuildNavigationTypes): string;
|
@@ -1,19 +1,22 @@
|
|
1
1
|
"use strict";
|
2
|
-
/* https://discord.com/developers/docs/reference#message-formatting */
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
3
|
exports.guildNavigation = exports.unixTimestamp = exports.customEmoji = exports.slashCommandMention = exports.roleMention = exports.channelMention = exports.userMention = void 0;
|
4
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
5
5
|
function userMention(userID) {
|
6
6
|
return `<@${userID}>`;
|
7
7
|
}
|
8
8
|
exports.userMention = userMention;
|
9
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
9
10
|
function channelMention(channelID) {
|
10
11
|
return `<#${channelID}>`;
|
11
12
|
}
|
12
13
|
exports.channelMention = channelMention;
|
14
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
13
15
|
function roleMention(roleID) {
|
14
16
|
return `<@&${roleID}>`;
|
15
17
|
}
|
16
18
|
exports.roleMention = roleMention;
|
19
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
17
20
|
function slashCommandMention(commandName, commandID, subCommandName, subCommandGroupName) {
|
18
21
|
return subCommandName
|
19
22
|
? subCommandGroupName
|
@@ -22,16 +25,19 @@ function slashCommandMention(commandName, commandID, subCommandName, subCommandG
|
|
22
25
|
: `</${commandName}:${commandID}>`;
|
23
26
|
}
|
24
27
|
exports.slashCommandMention = slashCommandMention;
|
28
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
25
29
|
function customEmoji(emojiName, emojiID, animated) {
|
26
30
|
return animated
|
27
31
|
? `<a:${emojiName}:${emojiID}>`
|
28
32
|
: `<:${emojiName}:${emojiID}>`;
|
29
33
|
}
|
30
34
|
exports.customEmoji = customEmoji;
|
35
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
31
36
|
function unixTimestamp(time, style) {
|
32
37
|
return style ? `<t:${time}:${style}>` : `<t:${time}>`;
|
33
38
|
}
|
34
39
|
exports.unixTimestamp = unixTimestamp;
|
40
|
+
/** https://discord.com/developers/docs/reference#message-formatting-formats */
|
35
41
|
function guildNavigation(guildID, type) {
|
36
42
|
return `<${guildID}:${type}>`;
|
37
43
|
}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
{
|
2
|
-
"name": "disgroove",
|
3
|
-
"version": "2.2.3-dev.
|
4
|
-
"description": "A module to interface with Discord",
|
5
|
-
"main": "./dist/lib/index.js",
|
6
|
-
"types": "./dist/lib/index.d.ts",
|
7
|
-
"repository": {
|
8
|
-
"type": "git",
|
9
|
-
"url": "git+https://github.com/XenKys/disgroove.git"
|
10
|
-
},
|
11
|
-
"keywords": [
|
12
|
-
"api",
|
13
|
-
"bot",
|
14
|
-
"discord",
|
15
|
-
"gateway",
|
16
|
-
"http",
|
17
|
-
"https",
|
18
|
-
"rest",
|
19
|
-
"wrapper"
|
20
|
-
],
|
21
|
-
"author": "XenKys",
|
22
|
-
"license": "MIT",
|
23
|
-
"bugs": {
|
24
|
-
"url": "https://github.com/XenKys/disgroove/issues"
|
25
|
-
},
|
26
|
-
"homepage": "https://github.com/XenKys/disgroove#readme",
|
27
|
-
"devDependencies": {
|
28
|
-
"@types/node": "^20.14.10",
|
29
|
-
"@types/ws": "^8.5.10",
|
30
|
-
"typescript": "^5.5.3"
|
31
|
-
},
|
32
|
-
"dependencies": {
|
33
|
-
"ws": "^8.18.0"
|
34
|
-
}
|
35
|
-
}
|
1
|
+
{
|
2
|
+
"name": "disgroove",
|
3
|
+
"version": "2.2.3-dev.e049f9f",
|
4
|
+
"description": "A module to interface with Discord",
|
5
|
+
"main": "./dist/lib/index.js",
|
6
|
+
"types": "./dist/lib/index.d.ts",
|
7
|
+
"repository": {
|
8
|
+
"type": "git",
|
9
|
+
"url": "git+https://github.com/XenKys/disgroove.git"
|
10
|
+
},
|
11
|
+
"keywords": [
|
12
|
+
"api",
|
13
|
+
"bot",
|
14
|
+
"discord",
|
15
|
+
"gateway",
|
16
|
+
"http",
|
17
|
+
"https",
|
18
|
+
"rest",
|
19
|
+
"wrapper"
|
20
|
+
],
|
21
|
+
"author": "XenKys",
|
22
|
+
"license": "MIT",
|
23
|
+
"bugs": {
|
24
|
+
"url": "https://github.com/XenKys/disgroove/issues"
|
25
|
+
},
|
26
|
+
"homepage": "https://github.com/XenKys/disgroove#readme",
|
27
|
+
"devDependencies": {
|
28
|
+
"@types/node": "^20.14.10",
|
29
|
+
"@types/ws": "^8.5.10",
|
30
|
+
"typescript": "^5.5.3"
|
31
|
+
},
|
32
|
+
"dependencies": {
|
33
|
+
"ws": "^8.18.0"
|
34
|
+
}
|
35
|
+
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { Shard } from ".";
|
2
|
-
import type { GatewayPresenceUpdate } from "../types/gateway-events";
|
3
|
-
export declare class ShardManager extends Map<number, Shard> {
|
4
|
-
/** https://discord.com/developers/docs/topics/gateway#connections */
|
5
|
-
connect(): void;
|
6
|
-
/** https://discord.com/developers/docs/topics/gateway#connections */
|
7
|
-
disconnect(): void;
|
8
|
-
/** https://discord.com/developers/docs/topics/gateway-events#update-presence */
|
9
|
-
updatePresence(options: Partial<Pick<GatewayPresenceUpdate, "activities" | "status" | "afk">>): void;
|
10
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.ShardManager = void 0;
|
4
|
-
class ShardManager extends Map {
|
5
|
-
/** https://discord.com/developers/docs/topics/gateway#connections */
|
6
|
-
connect() {
|
7
|
-
this.forEach((shard) => shard.connect());
|
8
|
-
}
|
9
|
-
/** https://discord.com/developers/docs/topics/gateway#connections */
|
10
|
-
disconnect() {
|
11
|
-
this.forEach((shard) => shard.disconnect());
|
12
|
-
}
|
13
|
-
/** https://discord.com/developers/docs/topics/gateway-events#update-presence */
|
14
|
-
updatePresence(options) {
|
15
|
-
this.forEach((shard) => shard.updatePresence(options));
|
16
|
-
}
|
17
|
-
}
|
18
|
-
exports.ShardManager = ShardManager;
|