disgroove 2.2.5 → 2.2.6-dev.4de2c29
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 +23 -21
- package/dist/lib/Client.js +7 -2
- package/dist/lib/constants.d.ts +15 -2
- package/dist/lib/constants.js +16 -2
- package/dist/lib/rest/RequestManager.d.ts +2 -2
- package/dist/lib/transformers/Components.d.ts +27 -0
- package/dist/lib/transformers/Components.js +395 -0
- package/dist/lib/transformers/Messages.d.ts +3 -4
- package/dist/lib/transformers/Messages.js +49 -170
- package/dist/lib/transformers/index.d.ts +1 -0
- package/dist/lib/transformers/index.js +1 -0
- package/dist/lib/types/interaction.d.ts +7 -7
- package/dist/lib/types/message-components.d.ts +131 -6
- package/dist/lib/types/message.d.ts +5 -3
- package/dist/package.json +3 -2
- package/package.json +3 -2
package/dist/lib/Client.d.ts
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
/// <reference types="node" />
|
3
3
|
/// <reference types="node" />
|
4
4
|
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";
|
5
|
-
import { RequestManager, type
|
5
|
+
import { RequestManager, type FileData } from "./rest";
|
6
6
|
import EventEmitter from "node:events";
|
7
7
|
import { Shard } from "./gateway";
|
8
8
|
import type { ActivityInstance, Application, ApplicationIntegrationTypeConfiguration, InstallParams } from "./types/application";
|
@@ -20,7 +20,6 @@ import type { GuildScheduledEvent, GuildScheduledEventUser, GuildScheduledEventE
|
|
20
20
|
import type { GuildTemplate } from "./types/guild-template";
|
21
21
|
import type { Interaction, InteractionCallbackResponse, InteractionResponse } from "./types/interaction";
|
22
22
|
import type { Invite } from "./types/invite";
|
23
|
-
import type { ActionRow } from "./types/message-components";
|
24
23
|
import type { PollCreateParams } from "./types/poll";
|
25
24
|
import type { Role } from "./types/role";
|
26
25
|
import type { SKU } from "./types/sku";
|
@@ -30,7 +29,7 @@ import type { User, ApplicationRoleConnection, Connection } from "./types/user";
|
|
30
29
|
import type { VoiceRegion, VoiceState } from "./types/voice";
|
31
30
|
import type { Webhook } from "./types/webhook";
|
32
31
|
import type { ClientOptions as WebSocketOptions } from "ws";
|
33
|
-
import type { Embed, AllowedMentions, Attachment, Message, MessageReference } from "./types/message";
|
32
|
+
import type { Embed, AllowedMentions, Attachment, Message, MessageReference, MessageTopLevelComponent } from "./types/message";
|
34
33
|
import type { Subscription } from "./types/subscription";
|
35
34
|
import type { SoundboardSound } from "./types/soundboard";
|
36
35
|
export interface GatewayOptions {
|
@@ -286,7 +285,7 @@ export declare class Client extends EventEmitter {
|
|
286
285
|
name: string;
|
287
286
|
description: string;
|
288
287
|
tags: string;
|
289
|
-
file:
|
288
|
+
file: FileData;
|
290
289
|
}, reason?: string): Promise<Sticker>;
|
291
290
|
/** https://discord.com/developers/docs/resources/soundboard#create-guild-soundboard-sound */
|
292
291
|
createGuildSoundboardSound(guildID: snowflake, options: {
|
@@ -307,8 +306,8 @@ export declare class Client extends EventEmitter {
|
|
307
306
|
tts?: boolean;
|
308
307
|
embeds?: Array<Embed>;
|
309
308
|
allowedMentions?: AllowedMentions;
|
310
|
-
components?: Array<
|
311
|
-
files?: Array<
|
309
|
+
components?: Array<MessageTopLevelComponent>;
|
310
|
+
files?: Array<FileData> | null;
|
312
311
|
attachments?: Array<Pick<Attachment, "filename" | "description">>;
|
313
312
|
flags?: MessageFlags;
|
314
313
|
threadName?: string;
|
@@ -327,9 +326,9 @@ export declare class Client extends EventEmitter {
|
|
327
326
|
embeds?: Array<Embed>;
|
328
327
|
allowedMentions?: AllowedMentions;
|
329
328
|
messageReference?: MessageReference;
|
330
|
-
components?: Array<
|
329
|
+
components?: Array<MessageTopLevelComponent>;
|
331
330
|
stickersIDs?: Array<snowflake>;
|
332
|
-
files?: Array<
|
331
|
+
files?: Array<FileData>;
|
333
332
|
attachments?: Array<Pick<Attachment, "filename" | "description">>;
|
334
333
|
flags?: MessageFlags;
|
335
334
|
enforceNonce?: boolean;
|
@@ -360,11 +359,11 @@ export declare class Client extends EventEmitter {
|
|
360
359
|
content?: string;
|
361
360
|
embeds?: Array<Embed>;
|
362
361
|
allowedMentions?: AllowedMentions;
|
363
|
-
components?: Array<
|
362
|
+
components?: Array<MessageTopLevelComponent>;
|
364
363
|
stickerIDs?: Array<snowflake>;
|
365
364
|
attachments?: Array<Pick<Attachment, "filename" | "description">>;
|
366
365
|
flags?: MessageFlags;
|
367
|
-
files?: Array<
|
366
|
+
files?: Array<FileData>;
|
368
367
|
};
|
369
368
|
appliedTags?: Array<snowflake>;
|
370
369
|
}, reason?: string): Promise<Channel>;
|
@@ -666,8 +665,8 @@ export declare class Client extends EventEmitter {
|
|
666
665
|
embeds?: Array<Embed> | null;
|
667
666
|
flags?: MessageFlags | null;
|
668
667
|
allowedMentions?: AllowedMentions | null;
|
669
|
-
components?: Array<
|
670
|
-
files?: Array<
|
668
|
+
components?: Array<MessageTopLevelComponent> | null;
|
669
|
+
files?: Array<FileData> | null;
|
671
670
|
attachments?: Array<Attachment> | null;
|
672
671
|
}): Promise<Message>;
|
673
672
|
/** https://discord.com/developers/docs/resources/stage-instance#modify-stage-instance */
|
@@ -680,8 +679,8 @@ export declare class Client extends EventEmitter {
|
|
680
679
|
content?: string | null;
|
681
680
|
embeds?: Array<Embed> | null;
|
682
681
|
allowedMentions?: AllowedMentions | null;
|
683
|
-
components?: Array<
|
684
|
-
files?: Array<
|
682
|
+
components?: Array<MessageTopLevelComponent> | null;
|
683
|
+
files?: Array<FileData> | null;
|
685
684
|
attachments?: Array<Partial<Attachment>> | null;
|
686
685
|
poll?: PollCreateParams | null;
|
687
686
|
threadID?: snowflake;
|
@@ -691,8 +690,8 @@ export declare class Client extends EventEmitter {
|
|
691
690
|
content?: string | null;
|
692
691
|
embeds?: Array<Embed> | null;
|
693
692
|
allowedMentions?: AllowedMentions | null;
|
694
|
-
components?: Array<
|
695
|
-
files?: Array<
|
693
|
+
components?: Array<MessageTopLevelComponent> | null;
|
694
|
+
files?: Array<FileData> | null;
|
696
695
|
attachments?: Array<Partial<Attachment>> | null;
|
697
696
|
poll?: PollCreateParams | null;
|
698
697
|
threadID?: snowflake;
|
@@ -713,8 +712,8 @@ export declare class Client extends EventEmitter {
|
|
713
712
|
content?: string | null;
|
714
713
|
embeds?: Array<Embed> | null;
|
715
714
|
allowedMentions?: AllowedMentions | null;
|
716
|
-
components?: Array<
|
717
|
-
files?: Array<
|
715
|
+
components?: Array<MessageTopLevelComponent> | null;
|
716
|
+
files?: Array<FileData> | null;
|
718
717
|
attachments?: Array<Partial<Attachment>> | null;
|
719
718
|
poll?: PollCreateParams | null;
|
720
719
|
threadID?: snowflake;
|
@@ -735,8 +734,8 @@ export declare class Client extends EventEmitter {
|
|
735
734
|
tts?: boolean;
|
736
735
|
embeds?: Array<Embed>;
|
737
736
|
allowedMentions?: AllowedMentions;
|
738
|
-
components?: Array<
|
739
|
-
files?: Array<
|
737
|
+
components?: Array<MessageTopLevelComponent>;
|
738
|
+
files?: Array<FileData>;
|
740
739
|
attachments?: Array<Pick<Attachment, "filename" | "description">>;
|
741
740
|
flags?: MessageFlags;
|
742
741
|
threadName?: string;
|
@@ -889,7 +888,10 @@ export declare class Client extends EventEmitter {
|
|
889
888
|
/** https://discord.com/developers/docs/resources/guild#get-guild-member */
|
890
889
|
getGuildMember(guildID: snowflake, userID: snowflake): Promise<GuildMember>;
|
891
890
|
/** https://discord.com/developers/docs/resources/guild#list-guild-members */
|
892
|
-
getGuildMembers(guildID: snowflake
|
891
|
+
getGuildMembers(guildID: snowflake, options: {
|
892
|
+
limit?: number;
|
893
|
+
after?: snowflake;
|
894
|
+
}): Promise<Array<GuildMember>>;
|
893
895
|
/** https://discord.com/developers/docs/resources/guild#get-guild-onboarding */
|
894
896
|
getGuildOnboarding(guildID: snowflake): Promise<GuildOnboarding>;
|
895
897
|
/** https://discord.com/developers/docs/resources/guild#get-guild-preview */
|
package/dist/lib/Client.js
CHANGED
@@ -1926,8 +1926,13 @@ class Client extends node_events_1.default {
|
|
1926
1926
|
return transformers_1.Guilds.guildMemberFromRaw(response);
|
1927
1927
|
}
|
1928
1928
|
/** https://discord.com/developers/docs/resources/guild#list-guild-members */
|
1929
|
-
async getGuildMembers(guildID) {
|
1930
|
-
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildMembers(guildID)
|
1929
|
+
async getGuildMembers(guildID, options) {
|
1930
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildMembers(guildID), {
|
1931
|
+
query: {
|
1932
|
+
limit: options.limit,
|
1933
|
+
after: options.after,
|
1934
|
+
},
|
1935
|
+
});
|
1931
1936
|
return response.map((guildMember) => transformers_1.Guilds.guildMemberFromRaw(guildMember));
|
1932
1937
|
}
|
1933
1938
|
/** https://discord.com/developers/docs/resources/guild#get-guild-onboarding */
|
package/dist/lib/constants.d.ts
CHANGED
@@ -114,7 +114,19 @@ export declare enum ComponentTypes {
|
|
114
114
|
UserSelect = 5,
|
115
115
|
RoleSelect = 6,
|
116
116
|
MentionableSelect = 7,
|
117
|
-
ChannelSelect = 8
|
117
|
+
ChannelSelect = 8,
|
118
|
+
Section = 9,
|
119
|
+
TextDisplay = 10,
|
120
|
+
Thumbnail = 11,
|
121
|
+
MediaGallery = 12,
|
122
|
+
File = 13,
|
123
|
+
Separator = 14,
|
124
|
+
Container = 17
|
125
|
+
}
|
126
|
+
/** https://discord.com/developers/docs/components/reference#separator-separator-structure */
|
127
|
+
export declare enum SeparatorSpacing {
|
128
|
+
Small = 1,
|
129
|
+
Large = 2
|
118
130
|
}
|
119
131
|
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type */
|
120
132
|
export declare enum InteractionCallbackType {
|
@@ -550,7 +562,8 @@ export declare enum MessageFlags {
|
|
550
562
|
FailedToMentionSomeRolesInThread = 256,
|
551
563
|
SuppressNotifications = 4096,
|
552
564
|
IsVoiceMessage = 8192,
|
553
|
-
HasSnapshot = 16384
|
565
|
+
HasSnapshot = 16384,
|
566
|
+
IsComponentsV2 = 32768
|
554
567
|
}
|
555
568
|
/** https://discord.com/developers/docs/resources/message#message-reference-types */
|
556
569
|
export declare enum MessageReferenceTypes {
|
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.AnimationTypes = exports.ActivityFlags = exports.ActivityType = exports.GatewayEvents = exports.StatusTypes = exports.GatewayIntents = exports.DeviceType = exports.WebhookTypes = exports.SubscriptionStatuses = exports.VisibilityTypes = exports.Services = exports.PremiumTypes = exports.UserFlags = exports.StickerFormatTypes = exports.StickerTypes = exports.PrivacyLevel = exports.LayoutType = exports.ReactionTypes = exports.AllowedMentionTypes = exports.AttachmentFlags = exports.EmbedTypes = exports.MessageReferenceTypes = exports.MessageFlags = exports.MessageActivityTypes = exports.MessageTypes = void 0;
|
3
|
+
exports.InviteTypes = exports.GuildScheduledEventRecurrenceRuleMonth = exports.GuildScheduledEventRecurrenceRuleWeekday = exports.GuildScheduledEventRecurrenceRuleFrequency = 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.ForumLayoutTypes = exports.SortOrderTypes = exports.ChannelFlags = exports.VideoQualityModes = exports.ChannelTypes = exports.ActionTypes = exports.EventTypes = exports.KeywordPresetTypes = exports.TriggerTypes = exports.AuditLogEvents = exports.ApplicationRoleConnectionMetadataType = exports.ActivityLocationKind = exports.ApplicationFlags = exports.ApplicationIntegrationTypes = exports.TextInputStyles = exports.ButtonStyles = exports.InteractionCallbackType = exports.SeparatorSpacing = exports.ComponentTypes = exports.InteractionContextTypes = exports.InteractionType = exports.ApplicationCommandPermissionType = exports.EntryPointCommandHandlerTypes = 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.AnimationTypes = exports.ActivityFlags = exports.ActivityType = exports.GatewayEvents = exports.StatusTypes = exports.GatewayIntents = exports.DeviceType = exports.WebhookTypes = exports.SubscriptionStatuses = exports.VisibilityTypes = exports.Services = exports.PremiumTypes = exports.UserFlags = exports.StickerFormatTypes = exports.StickerTypes = exports.PrivacyLevel = exports.LayoutType = exports.ReactionTypes = exports.AllowedMentionTypes = exports.AttachmentFlags = exports.EmbedTypes = exports.MessageReferenceTypes = exports.MessageFlags = exports.MessageActivityTypes = exports.MessageTypes = exports.InviteTargetTypes = void 0;
|
5
5
|
/** https://discord.com/developers/docs/reference#message-formatting-timestamp-styles */
|
6
6
|
var TimestampStyles;
|
7
7
|
(function (TimestampStyles) {
|
@@ -130,7 +130,20 @@ var ComponentTypes;
|
|
130
130
|
ComponentTypes[ComponentTypes["RoleSelect"] = 6] = "RoleSelect";
|
131
131
|
ComponentTypes[ComponentTypes["MentionableSelect"] = 7] = "MentionableSelect";
|
132
132
|
ComponentTypes[ComponentTypes["ChannelSelect"] = 8] = "ChannelSelect";
|
133
|
+
ComponentTypes[ComponentTypes["Section"] = 9] = "Section";
|
134
|
+
ComponentTypes[ComponentTypes["TextDisplay"] = 10] = "TextDisplay";
|
135
|
+
ComponentTypes[ComponentTypes["Thumbnail"] = 11] = "Thumbnail";
|
136
|
+
ComponentTypes[ComponentTypes["MediaGallery"] = 12] = "MediaGallery";
|
137
|
+
ComponentTypes[ComponentTypes["File"] = 13] = "File";
|
138
|
+
ComponentTypes[ComponentTypes["Separator"] = 14] = "Separator";
|
139
|
+
ComponentTypes[ComponentTypes["Container"] = 17] = "Container";
|
133
140
|
})(ComponentTypes || (exports.ComponentTypes = ComponentTypes = {}));
|
141
|
+
/** https://discord.com/developers/docs/components/reference#separator-separator-structure */
|
142
|
+
var SeparatorSpacing;
|
143
|
+
(function (SeparatorSpacing) {
|
144
|
+
SeparatorSpacing[SeparatorSpacing["Small"] = 1] = "Small";
|
145
|
+
SeparatorSpacing[SeparatorSpacing["Large"] = 2] = "Large";
|
146
|
+
})(SeparatorSpacing || (exports.SeparatorSpacing = SeparatorSpacing = {}));
|
134
147
|
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type */
|
135
148
|
var InteractionCallbackType;
|
136
149
|
(function (InteractionCallbackType) {
|
@@ -608,6 +621,7 @@ var MessageFlags;
|
|
608
621
|
MessageFlags[MessageFlags["SuppressNotifications"] = 4096] = "SuppressNotifications";
|
609
622
|
MessageFlags[MessageFlags["IsVoiceMessage"] = 8192] = "IsVoiceMessage";
|
610
623
|
MessageFlags[MessageFlags["HasSnapshot"] = 16384] = "HasSnapshot";
|
624
|
+
MessageFlags[MessageFlags["IsComponentsV2"] = 32768] = "IsComponentsV2";
|
611
625
|
})(MessageFlags || (exports.MessageFlags = MessageFlags = {}));
|
612
626
|
/** https://discord.com/developers/docs/resources/message#message-reference-types */
|
613
627
|
var MessageReferenceTypes;
|
@@ -11,7 +11,7 @@ export declare enum RESTMethods {
|
|
11
11
|
export interface RequestData {
|
12
12
|
json?: unknown;
|
13
13
|
form?: FormData;
|
14
|
-
files?: Array<
|
14
|
+
files?: Array<FileData> | null;
|
15
15
|
reason?: string;
|
16
16
|
query?: Record<string, any>;
|
17
17
|
authorization?: boolean;
|
@@ -22,7 +22,7 @@ export interface ErrorResponse {
|
|
22
22
|
message: string;
|
23
23
|
errors: Record<string, unknown>;
|
24
24
|
}
|
25
|
-
export interface
|
25
|
+
export interface FileData {
|
26
26
|
contents: Buffer;
|
27
27
|
name: string;
|
28
28
|
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { ActionRow, Button, Container, RawActionRow, RawButton, RawContainer, RawFile, File, RawUnfurledMediaItem, UnfurledMediaItem, RawTextDisplay, TextDisplay, RawSeparator, Separator, RawSection, Section, Thumbnail, RawThumbnail, TextInput, RawTextInput, SelectMenu, RawSelectMenu, MediaGallery, RawMediaGallery } from "../types/message-components.js";
|
2
|
+
export declare class Components {
|
3
|
+
static actionRowFromRaw(actionRow: RawActionRow): ActionRow;
|
4
|
+
static actionRowToRaw(actionRow: ActionRow): RawActionRow;
|
5
|
+
static buttonFromRaw(button: RawButton): Button;
|
6
|
+
static buttonToRaw(button: Button): RawButton;
|
7
|
+
static containerFromRaw(container: RawContainer): Container;
|
8
|
+
static containerToRaw(container: Container): RawContainer;
|
9
|
+
static fileFromRaw(file: RawFile): File;
|
10
|
+
static fileToRaw(file: File): RawFile;
|
11
|
+
static mediaGalleryFromRaw(mediaGallery: RawMediaGallery): MediaGallery;
|
12
|
+
static mediaGalleryToRaw(mediaGallery: MediaGallery): RawMediaGallery;
|
13
|
+
static sectionFromRaw(section: RawSection): Section;
|
14
|
+
static sectionToRaw(section: Section): RawSection;
|
15
|
+
static selectMenuFromRaw(selectMenu: RawSelectMenu): SelectMenu;
|
16
|
+
static selectMenuToRaw(selectMenu: SelectMenu): RawSelectMenu;
|
17
|
+
static separatorFromRaw(separator: RawSeparator): Separator;
|
18
|
+
static separatorToRaw(separator: Separator): RawSeparator;
|
19
|
+
static textDisplayFromRaw(textDisplay: RawTextDisplay): TextDisplay;
|
20
|
+
static textDisplayToRaw(textDisplay: TextDisplay): RawTextDisplay;
|
21
|
+
static textInputFromRaw(textInput: RawTextInput): TextInput;
|
22
|
+
static textInputToRaw(textInput: TextInput): RawTextInput;
|
23
|
+
static thumbnailFromRaw(thumbnail: RawThumbnail): Thumbnail;
|
24
|
+
static thumbnailToRaw(thumbnail: Thumbnail): RawThumbnail;
|
25
|
+
static unfurledMediaItemFromRaw(unfurledMediaItem: RawUnfurledMediaItem): UnfurledMediaItem;
|
26
|
+
static unfurledMediaItemToRaw(unfurledMediaItem: UnfurledMediaItem): RawUnfurledMediaItem;
|
27
|
+
}
|
@@ -0,0 +1,395 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Components = void 0;
|
4
|
+
const constants_js_1 = require("../constants.js");
|
5
|
+
class Components {
|
6
|
+
static actionRowFromRaw(actionRow) {
|
7
|
+
return {
|
8
|
+
type: actionRow.type,
|
9
|
+
components: actionRow.components.map((c) => {
|
10
|
+
switch (c.type) {
|
11
|
+
case constants_js_1.ComponentTypes.Button: {
|
12
|
+
return Components.buttonFromRaw(c);
|
13
|
+
}
|
14
|
+
case constants_js_1.ComponentTypes.TextInput: {
|
15
|
+
return Components.textInputFromRaw(c);
|
16
|
+
}
|
17
|
+
case constants_js_1.ComponentTypes.ChannelSelect:
|
18
|
+
case constants_js_1.ComponentTypes.MentionableSelect:
|
19
|
+
case constants_js_1.ComponentTypes.RoleSelect:
|
20
|
+
case constants_js_1.ComponentTypes.UserSelect:
|
21
|
+
case constants_js_1.ComponentTypes.StringSelect: {
|
22
|
+
return Components.selectMenuFromRaw(c);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}),
|
26
|
+
id: actionRow.id,
|
27
|
+
};
|
28
|
+
}
|
29
|
+
static actionRowToRaw(actionRow) {
|
30
|
+
return {
|
31
|
+
type: actionRow.type,
|
32
|
+
components: actionRow.components.map((c) => {
|
33
|
+
switch (c.type) {
|
34
|
+
case constants_js_1.ComponentTypes.Button: {
|
35
|
+
return Components.buttonToRaw(c);
|
36
|
+
}
|
37
|
+
case constants_js_1.ComponentTypes.TextInput: {
|
38
|
+
return Components.textInputToRaw(c);
|
39
|
+
}
|
40
|
+
case constants_js_1.ComponentTypes.ChannelSelect:
|
41
|
+
case constants_js_1.ComponentTypes.MentionableSelect:
|
42
|
+
case constants_js_1.ComponentTypes.RoleSelect:
|
43
|
+
case constants_js_1.ComponentTypes.UserSelect:
|
44
|
+
case constants_js_1.ComponentTypes.StringSelect: {
|
45
|
+
return Components.selectMenuToRaw(c);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}),
|
49
|
+
id: actionRow.id,
|
50
|
+
};
|
51
|
+
}
|
52
|
+
static buttonFromRaw(button) {
|
53
|
+
return {
|
54
|
+
type: button.type,
|
55
|
+
style: button.style,
|
56
|
+
label: button.label,
|
57
|
+
emoji: button.emoji,
|
58
|
+
customID: button.custom_id,
|
59
|
+
skuID: button.sku_id,
|
60
|
+
url: button.url,
|
61
|
+
disabled: button.disabled,
|
62
|
+
id: button.id,
|
63
|
+
};
|
64
|
+
}
|
65
|
+
static buttonToRaw(button) {
|
66
|
+
return {
|
67
|
+
type: button.type,
|
68
|
+
style: button.style,
|
69
|
+
label: button.label,
|
70
|
+
emoji: button.emoji,
|
71
|
+
custom_id: button.customID,
|
72
|
+
sku_id: button.skuID,
|
73
|
+
url: button.url,
|
74
|
+
disabled: button.disabled,
|
75
|
+
id: button.id,
|
76
|
+
};
|
77
|
+
}
|
78
|
+
static containerFromRaw(container) {
|
79
|
+
return {
|
80
|
+
type: container.type,
|
81
|
+
id: container.id,
|
82
|
+
components: container.components.map((c) => {
|
83
|
+
switch (c.type) {
|
84
|
+
case constants_js_1.ComponentTypes.ActionRow: {
|
85
|
+
return Components.actionRowFromRaw(c);
|
86
|
+
}
|
87
|
+
case constants_js_1.ComponentTypes.TextDisplay: {
|
88
|
+
return Components.textDisplayFromRaw(c);
|
89
|
+
}
|
90
|
+
case constants_js_1.ComponentTypes.Section: {
|
91
|
+
return Components.sectionFromRaw(c);
|
92
|
+
}
|
93
|
+
case constants_js_1.ComponentTypes.MediaGallery: {
|
94
|
+
return Components.mediaGalleryFromRaw(c);
|
95
|
+
}
|
96
|
+
case constants_js_1.ComponentTypes.File: {
|
97
|
+
return Components.fileFromRaw(c);
|
98
|
+
}
|
99
|
+
case constants_js_1.ComponentTypes.Separator: {
|
100
|
+
return Components.separatorFromRaw(c);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}),
|
104
|
+
accentColor: container.accent_color,
|
105
|
+
spoiler: container.spoiler,
|
106
|
+
};
|
107
|
+
}
|
108
|
+
static containerToRaw(container) {
|
109
|
+
return {
|
110
|
+
type: container.type,
|
111
|
+
id: container.id,
|
112
|
+
components: container.components.map((c) => {
|
113
|
+
switch (c.type) {
|
114
|
+
case constants_js_1.ComponentTypes.ActionRow: {
|
115
|
+
return Components.actionRowToRaw(c);
|
116
|
+
}
|
117
|
+
case constants_js_1.ComponentTypes.TextDisplay: {
|
118
|
+
return Components.textDisplayToRaw(c);
|
119
|
+
}
|
120
|
+
case constants_js_1.ComponentTypes.Section: {
|
121
|
+
return Components.sectionToRaw(c);
|
122
|
+
}
|
123
|
+
case constants_js_1.ComponentTypes.MediaGallery: {
|
124
|
+
return Components.mediaGalleryToRaw(c);
|
125
|
+
}
|
126
|
+
case constants_js_1.ComponentTypes.File: {
|
127
|
+
return Components.fileToRaw(c);
|
128
|
+
}
|
129
|
+
case constants_js_1.ComponentTypes.Separator: {
|
130
|
+
return Components.separatorToRaw(c);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}),
|
134
|
+
accent_color: container.accentColor,
|
135
|
+
spoiler: container.spoiler,
|
136
|
+
};
|
137
|
+
}
|
138
|
+
static fileFromRaw(file) {
|
139
|
+
return {
|
140
|
+
type: file.type,
|
141
|
+
id: file.id,
|
142
|
+
file: Components.unfurledMediaItemFromRaw(file.file),
|
143
|
+
spoiler: file.spoiler,
|
144
|
+
};
|
145
|
+
}
|
146
|
+
static fileToRaw(file) {
|
147
|
+
return {
|
148
|
+
type: file.type,
|
149
|
+
id: file.id,
|
150
|
+
file: Components.unfurledMediaItemToRaw(file.file),
|
151
|
+
spoiler: file.spoiler,
|
152
|
+
};
|
153
|
+
}
|
154
|
+
static mediaGalleryFromRaw(mediaGallery) {
|
155
|
+
return {
|
156
|
+
type: mediaGallery.type,
|
157
|
+
id: mediaGallery.id,
|
158
|
+
items: mediaGallery.items.map((item) => ({
|
159
|
+
media: Components.unfurledMediaItemFromRaw(item.media),
|
160
|
+
description: item.description,
|
161
|
+
spoiler: item.spoiler,
|
162
|
+
})),
|
163
|
+
};
|
164
|
+
}
|
165
|
+
static mediaGalleryToRaw(mediaGallery) {
|
166
|
+
return {
|
167
|
+
type: mediaGallery.type,
|
168
|
+
id: mediaGallery.id,
|
169
|
+
items: mediaGallery.items.map((item) => ({
|
170
|
+
media: Components.unfurledMediaItemToRaw(item.media),
|
171
|
+
description: item.description,
|
172
|
+
spoiler: item.spoiler,
|
173
|
+
})),
|
174
|
+
};
|
175
|
+
}
|
176
|
+
static sectionFromRaw(section) {
|
177
|
+
return {
|
178
|
+
type: section.type,
|
179
|
+
id: section.id,
|
180
|
+
components: [],
|
181
|
+
accessory: section.accessory.type === constants_js_1.ComponentTypes.Button
|
182
|
+
? Components.buttonFromRaw(section.accessory)
|
183
|
+
: Components.thumbnailFromRaw(section.accessory),
|
184
|
+
};
|
185
|
+
}
|
186
|
+
static sectionToRaw(section) {
|
187
|
+
return {
|
188
|
+
type: section.type,
|
189
|
+
id: section.id,
|
190
|
+
components: [],
|
191
|
+
accessory: section.accessory.type === constants_js_1.ComponentTypes.Button
|
192
|
+
? Components.buttonToRaw(section.accessory)
|
193
|
+
: Components.thumbnailToRaw(section.accessory),
|
194
|
+
};
|
195
|
+
}
|
196
|
+
static selectMenuFromRaw(selectMenu) {
|
197
|
+
switch (selectMenu.type) {
|
198
|
+
case constants_js_1.ComponentTypes.ChannelSelect: {
|
199
|
+
return {
|
200
|
+
type: selectMenu.type,
|
201
|
+
customID: selectMenu.custom_id,
|
202
|
+
channelTypes: selectMenu.channel_types,
|
203
|
+
placeholder: selectMenu.placeholder,
|
204
|
+
defaultValues: selectMenu.default_values,
|
205
|
+
minValues: selectMenu.min_values,
|
206
|
+
maxValues: selectMenu.max_values,
|
207
|
+
disabled: selectMenu.disabled,
|
208
|
+
};
|
209
|
+
}
|
210
|
+
case constants_js_1.ComponentTypes.StringSelect: {
|
211
|
+
return {
|
212
|
+
type: selectMenu.type,
|
213
|
+
customID: selectMenu.custom_id,
|
214
|
+
placeholder: selectMenu.placeholder,
|
215
|
+
options: selectMenu.options?.map((option) => ({
|
216
|
+
label: option.label,
|
217
|
+
value: option.value,
|
218
|
+
description: option.description,
|
219
|
+
emoji: option.emoji !== undefined
|
220
|
+
? {
|
221
|
+
name: option.emoji.name,
|
222
|
+
id: option.emoji.id,
|
223
|
+
animated: option.emoji.animated,
|
224
|
+
}
|
225
|
+
: undefined,
|
226
|
+
default: option.default,
|
227
|
+
})),
|
228
|
+
minValues: selectMenu.min_values,
|
229
|
+
maxValues: selectMenu.max_values,
|
230
|
+
disabled: selectMenu.disabled,
|
231
|
+
};
|
232
|
+
}
|
233
|
+
case constants_js_1.ComponentTypes.MentionableSelect:
|
234
|
+
case constants_js_1.ComponentTypes.RoleSelect:
|
235
|
+
case constants_js_1.ComponentTypes.UserSelect: {
|
236
|
+
return {
|
237
|
+
type: selectMenu.type,
|
238
|
+
customID: selectMenu.custom_id,
|
239
|
+
placeholder: selectMenu.placeholder,
|
240
|
+
defaultValues: selectMenu.default_values,
|
241
|
+
minValues: selectMenu.min_values,
|
242
|
+
maxValues: selectMenu.max_values,
|
243
|
+
disabled: selectMenu.disabled,
|
244
|
+
};
|
245
|
+
}
|
246
|
+
}
|
247
|
+
}
|
248
|
+
static selectMenuToRaw(selectMenu) {
|
249
|
+
switch (selectMenu.type) {
|
250
|
+
case constants_js_1.ComponentTypes.ChannelSelect: {
|
251
|
+
return {
|
252
|
+
type: selectMenu.type,
|
253
|
+
custom_id: selectMenu.customID,
|
254
|
+
channel_types: selectMenu.channelTypes,
|
255
|
+
placeholder: selectMenu.placeholder,
|
256
|
+
default_values: selectMenu.defaultValues,
|
257
|
+
min_values: selectMenu.minValues,
|
258
|
+
max_values: selectMenu.maxValues,
|
259
|
+
disabled: selectMenu.disabled,
|
260
|
+
};
|
261
|
+
}
|
262
|
+
case constants_js_1.ComponentTypes.StringSelect: {
|
263
|
+
return {
|
264
|
+
type: selectMenu.type,
|
265
|
+
custom_id: selectMenu.customID,
|
266
|
+
placeholder: selectMenu.placeholder,
|
267
|
+
options: selectMenu.options?.map((option) => ({
|
268
|
+
label: option.label,
|
269
|
+
value: option.value,
|
270
|
+
description: option.description,
|
271
|
+
emoji: option.emoji !== undefined
|
272
|
+
? {
|
273
|
+
name: option.emoji.name,
|
274
|
+
id: option.emoji.id,
|
275
|
+
animated: option.emoji.animated,
|
276
|
+
}
|
277
|
+
: undefined,
|
278
|
+
default: option.default,
|
279
|
+
})),
|
280
|
+
min_values: selectMenu.minValues,
|
281
|
+
max_values: selectMenu.maxValues,
|
282
|
+
disabled: selectMenu.disabled,
|
283
|
+
};
|
284
|
+
}
|
285
|
+
case constants_js_1.ComponentTypes.MentionableSelect:
|
286
|
+
case constants_js_1.ComponentTypes.RoleSelect:
|
287
|
+
case constants_js_1.ComponentTypes.UserSelect: {
|
288
|
+
return {
|
289
|
+
type: selectMenu.type,
|
290
|
+
custom_id: selectMenu.customID,
|
291
|
+
placeholder: selectMenu.placeholder,
|
292
|
+
default_values: selectMenu.defaultValues,
|
293
|
+
min_values: selectMenu.minValues,
|
294
|
+
max_values: selectMenu.maxValues,
|
295
|
+
disabled: selectMenu.disabled,
|
296
|
+
};
|
297
|
+
}
|
298
|
+
}
|
299
|
+
}
|
300
|
+
static separatorFromRaw(separator) {
|
301
|
+
return {
|
302
|
+
type: separator.type,
|
303
|
+
id: separator.id,
|
304
|
+
divider: separator.divider,
|
305
|
+
spacing: separator.spacing,
|
306
|
+
};
|
307
|
+
}
|
308
|
+
static separatorToRaw(separator) {
|
309
|
+
return {
|
310
|
+
type: separator.type,
|
311
|
+
id: separator.id,
|
312
|
+
divider: separator.divider,
|
313
|
+
spacing: separator.spacing,
|
314
|
+
};
|
315
|
+
}
|
316
|
+
static textDisplayFromRaw(textDisplay) {
|
317
|
+
return {
|
318
|
+
type: textDisplay.type,
|
319
|
+
id: textDisplay.id,
|
320
|
+
content: textDisplay.content,
|
321
|
+
};
|
322
|
+
}
|
323
|
+
static textDisplayToRaw(textDisplay) {
|
324
|
+
return {
|
325
|
+
type: textDisplay.type,
|
326
|
+
id: textDisplay.id,
|
327
|
+
content: textDisplay.content,
|
328
|
+
};
|
329
|
+
}
|
330
|
+
static textInputFromRaw(textInput) {
|
331
|
+
return {
|
332
|
+
type: textInput.type,
|
333
|
+
customID: textInput.custom_id,
|
334
|
+
style: textInput.style,
|
335
|
+
label: textInput.label,
|
336
|
+
minLength: textInput.min_length,
|
337
|
+
maxLength: textInput.max_length,
|
338
|
+
required: textInput.required,
|
339
|
+
value: textInput.value,
|
340
|
+
placeholder: textInput.placeholder,
|
341
|
+
id: textInput.id,
|
342
|
+
};
|
343
|
+
}
|
344
|
+
static textInputToRaw(textInput) {
|
345
|
+
return {
|
346
|
+
type: textInput.type,
|
347
|
+
custom_id: textInput.customID,
|
348
|
+
style: textInput.style,
|
349
|
+
label: textInput.label,
|
350
|
+
min_length: textInput.minLength,
|
351
|
+
max_length: textInput.maxLength,
|
352
|
+
required: textInput.required,
|
353
|
+
value: textInput.value,
|
354
|
+
placeholder: textInput.placeholder,
|
355
|
+
id: textInput.id,
|
356
|
+
};
|
357
|
+
}
|
358
|
+
static thumbnailFromRaw(thumbnail) {
|
359
|
+
return {
|
360
|
+
type: thumbnail.type,
|
361
|
+
id: thumbnail.id,
|
362
|
+
media: Components.unfurledMediaItemFromRaw(thumbnail.media),
|
363
|
+
description: thumbnail.description,
|
364
|
+
spoiler: thumbnail.spoiler,
|
365
|
+
};
|
366
|
+
}
|
367
|
+
static thumbnailToRaw(thumbnail) {
|
368
|
+
return {
|
369
|
+
type: thumbnail.type,
|
370
|
+
id: thumbnail.id,
|
371
|
+
media: Components.unfurledMediaItemToRaw(thumbnail.media),
|
372
|
+
description: thumbnail.description,
|
373
|
+
spoiler: thumbnail.spoiler,
|
374
|
+
};
|
375
|
+
}
|
376
|
+
static unfurledMediaItemFromRaw(unfurledMediaItem) {
|
377
|
+
return {
|
378
|
+
url: unfurledMediaItem.url,
|
379
|
+
proxyURL: unfurledMediaItem.proxy_url,
|
380
|
+
height: unfurledMediaItem.height,
|
381
|
+
width: unfurledMediaItem.width,
|
382
|
+
contentType: unfurledMediaItem.content_type,
|
383
|
+
};
|
384
|
+
}
|
385
|
+
static unfurledMediaItemToRaw(unfurledMediaItem) {
|
386
|
+
return {
|
387
|
+
url: unfurledMediaItem.url,
|
388
|
+
proxy_url: unfurledMediaItem.proxyURL,
|
389
|
+
height: unfurledMediaItem.height,
|
390
|
+
width: unfurledMediaItem.width,
|
391
|
+
content_type: unfurledMediaItem.contentType,
|
392
|
+
};
|
393
|
+
}
|
394
|
+
}
|
395
|
+
exports.Components = Components;
|
@@ -1,10 +1,9 @@
|
|
1
|
-
import { RawAttachment, Attachment, RawEmbed, Embed, RawMessage, Message } from "../types/message";
|
2
|
-
import type { RawActionRow, ActionRow } from "../types/message-components";
|
1
|
+
import { RawAttachment, Attachment, RawEmbed, Embed, RawMessage, Message, MessageTopLevelComponent, RawMessageTopLevelComponent } from "../types/message";
|
3
2
|
export declare class Messages {
|
4
3
|
static attachmentFromRaw(attachment: RawAttachment): Attachment;
|
5
4
|
static attachmentToRaw(attachment: Attachment): RawAttachment;
|
6
|
-
static componentsFromRaw(components: Array<
|
7
|
-
static componentsToRaw(components: Array<
|
5
|
+
static componentsFromRaw(components: Array<RawMessageTopLevelComponent>): Array<MessageTopLevelComponent>;
|
6
|
+
static componentsToRaw(components: Array<MessageTopLevelComponent>): Array<RawMessageTopLevelComponent>;
|
8
7
|
static embedFromRaw(embed: RawEmbed): Embed;
|
9
8
|
static embedToRaw(embed: Embed): RawEmbed;
|
10
9
|
static messageFromRaw(message: RawMessage): Message;
|
@@ -4,6 +4,7 @@ exports.Messages = void 0;
|
|
4
4
|
const constants_1 = require("../constants");
|
5
5
|
const Applications_1 = require("./Applications");
|
6
6
|
const Channels_1 = require("./Channels");
|
7
|
+
const Components_js_1 = require("./Components.js");
|
7
8
|
const Emojis_1 = require("./Emojis");
|
8
9
|
const Guilds_1 = require("./Guilds");
|
9
10
|
const Interactions_1 = require("./Interactions");
|
@@ -48,180 +49,58 @@ class Messages {
|
|
48
49
|
};
|
49
50
|
}
|
50
51
|
static componentsFromRaw(components) {
|
51
|
-
return components.map((component) =>
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
case constants_1.ComponentTypes.Button: {
|
56
|
-
return {
|
57
|
-
type: c.type,
|
58
|
-
style: c.style,
|
59
|
-
label: c.label,
|
60
|
-
emoji: c.emoji !== undefined
|
61
|
-
? {
|
62
|
-
name: c.emoji.name,
|
63
|
-
id: c.emoji.id,
|
64
|
-
animated: c.emoji.animated,
|
65
|
-
}
|
66
|
-
: undefined,
|
67
|
-
customID: c.custom_id,
|
68
|
-
skuID: c.sku_id,
|
69
|
-
url: c.url,
|
70
|
-
disabled: c.disabled,
|
71
|
-
};
|
72
|
-
}
|
73
|
-
case constants_1.ComponentTypes.TextInput: {
|
74
|
-
return {
|
75
|
-
type: c.type,
|
76
|
-
customID: c.custom_id,
|
77
|
-
style: c.style,
|
78
|
-
label: c.label,
|
79
|
-
minLength: c.min_length,
|
80
|
-
maxLength: c.max_length,
|
81
|
-
required: c.required,
|
82
|
-
value: c.value,
|
83
|
-
placeholder: c.placeholder,
|
84
|
-
};
|
85
|
-
}
|
86
|
-
case constants_1.ComponentTypes.ChannelSelect: {
|
87
|
-
return {
|
88
|
-
type: c.type,
|
89
|
-
customID: c.custom_id,
|
90
|
-
channelTypes: c.channel_types,
|
91
|
-
placeholder: c.placeholder,
|
92
|
-
defaultValues: c.default_values,
|
93
|
-
minValues: c.min_values,
|
94
|
-
maxValues: c.max_values,
|
95
|
-
disabled: c.disabled,
|
96
|
-
};
|
97
|
-
}
|
98
|
-
case constants_1.ComponentTypes.StringSelect: {
|
99
|
-
return {
|
100
|
-
type: c.type,
|
101
|
-
customID: c.custom_id,
|
102
|
-
placeholder: c.placeholder,
|
103
|
-
options: c.options?.map((option) => ({
|
104
|
-
label: option.label,
|
105
|
-
value: option.value,
|
106
|
-
description: option.description,
|
107
|
-
emoji: option.emoji !== undefined
|
108
|
-
? {
|
109
|
-
name: option.emoji.name,
|
110
|
-
id: option.emoji.id,
|
111
|
-
animated: option.emoji.animated,
|
112
|
-
}
|
113
|
-
: undefined,
|
114
|
-
default: option.default,
|
115
|
-
})),
|
116
|
-
minValues: c.min_values,
|
117
|
-
maxValues: c.max_values,
|
118
|
-
disabled: c.disabled,
|
119
|
-
};
|
120
|
-
}
|
121
|
-
case constants_1.ComponentTypes.MentionableSelect:
|
122
|
-
case constants_1.ComponentTypes.RoleSelect:
|
123
|
-
case constants_1.ComponentTypes.UserSelect: {
|
124
|
-
return {
|
125
|
-
type: c.type,
|
126
|
-
customID: c.custom_id,
|
127
|
-
placeholder: c.placeholder,
|
128
|
-
defaultValues: c.default_values,
|
129
|
-
minValues: c.min_values,
|
130
|
-
maxValues: c.max_values,
|
131
|
-
disabled: c.disabled,
|
132
|
-
};
|
133
|
-
}
|
52
|
+
return components.map((component) => {
|
53
|
+
switch (component.type) {
|
54
|
+
case constants_1.ComponentTypes.ActionRow: {
|
55
|
+
return Components_js_1.Components.actionRowFromRaw(component);
|
134
56
|
}
|
135
|
-
|
136
|
-
|
57
|
+
case constants_1.ComponentTypes.TextDisplay: {
|
58
|
+
return Components_js_1.Components.textDisplayFromRaw(component);
|
59
|
+
}
|
60
|
+
case constants_1.ComponentTypes.Container: {
|
61
|
+
return Components_js_1.Components.containerFromRaw(component);
|
62
|
+
}
|
63
|
+
case constants_1.ComponentTypes.File: {
|
64
|
+
return Components_js_1.Components.fileFromRaw(component);
|
65
|
+
}
|
66
|
+
case constants_1.ComponentTypes.Section: {
|
67
|
+
return Components_js_1.Components.sectionFromRaw(component);
|
68
|
+
}
|
69
|
+
case constants_1.ComponentTypes.Separator: {
|
70
|
+
return Components_js_1.Components.separatorFromRaw(component);
|
71
|
+
}
|
72
|
+
case constants_1.ComponentTypes.MediaGallery: {
|
73
|
+
return Components_js_1.Components.mediaGalleryFromRaw(component);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
});
|
137
77
|
}
|
138
78
|
static componentsToRaw(components) {
|
139
|
-
return components.map((component) =>
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
case constants_1.ComponentTypes.TextInput: {
|
162
|
-
return {
|
163
|
-
type: c.type,
|
164
|
-
custom_id: c.customID,
|
165
|
-
style: c.style,
|
166
|
-
label: c.label,
|
167
|
-
min_length: c.minLength,
|
168
|
-
max_length: c.maxLength,
|
169
|
-
required: c.required,
|
170
|
-
value: c.value,
|
171
|
-
placeholder: c.placeholder,
|
172
|
-
};
|
173
|
-
}
|
174
|
-
case constants_1.ComponentTypes.ChannelSelect: {
|
175
|
-
return {
|
176
|
-
type: c.type,
|
177
|
-
custom_id: c.customID,
|
178
|
-
channel_types: c.channelTypes,
|
179
|
-
placeholder: c.placeholder,
|
180
|
-
default_values: c.defaultValues,
|
181
|
-
min_values: c.minValues,
|
182
|
-
max_values: c.maxValues,
|
183
|
-
disabled: c.disabled,
|
184
|
-
};
|
185
|
-
}
|
186
|
-
case constants_1.ComponentTypes.StringSelect: {
|
187
|
-
return {
|
188
|
-
type: c.type,
|
189
|
-
custom_id: c.customID,
|
190
|
-
placeholder: c.placeholder,
|
191
|
-
options: c.options?.map((option) => ({
|
192
|
-
label: option.label,
|
193
|
-
value: option.value,
|
194
|
-
description: option.description,
|
195
|
-
emoji: option.emoji !== undefined
|
196
|
-
? {
|
197
|
-
name: option.emoji.name,
|
198
|
-
id: option.emoji.id,
|
199
|
-
animated: option.emoji.animated,
|
200
|
-
}
|
201
|
-
: undefined,
|
202
|
-
default: option.default,
|
203
|
-
})),
|
204
|
-
min_values: c.minValues,
|
205
|
-
max_values: c.maxValues,
|
206
|
-
disabled: c.disabled,
|
207
|
-
};
|
208
|
-
}
|
209
|
-
case constants_1.ComponentTypes.MentionableSelect:
|
210
|
-
case constants_1.ComponentTypes.RoleSelect:
|
211
|
-
case constants_1.ComponentTypes.UserSelect: {
|
212
|
-
return {
|
213
|
-
type: c.type,
|
214
|
-
custom_id: c.customID,
|
215
|
-
placeholder: c.placeholder,
|
216
|
-
default_values: c.defaultValues,
|
217
|
-
min_values: c.minValues,
|
218
|
-
max_values: c.maxValues,
|
219
|
-
disabled: c.disabled,
|
220
|
-
};
|
221
|
-
}
|
79
|
+
return components.map((component) => {
|
80
|
+
switch (component.type) {
|
81
|
+
case constants_1.ComponentTypes.ActionRow: {
|
82
|
+
return Components_js_1.Components.actionRowToRaw(component);
|
83
|
+
}
|
84
|
+
case constants_1.ComponentTypes.TextDisplay: {
|
85
|
+
return Components_js_1.Components.textDisplayToRaw(component);
|
86
|
+
}
|
87
|
+
case constants_1.ComponentTypes.Container: {
|
88
|
+
return Components_js_1.Components.containerToRaw(component);
|
89
|
+
}
|
90
|
+
case constants_1.ComponentTypes.File: {
|
91
|
+
return Components_js_1.Components.fileToRaw(component);
|
92
|
+
}
|
93
|
+
case constants_1.ComponentTypes.Section: {
|
94
|
+
return Components_js_1.Components.sectionToRaw(component);
|
95
|
+
}
|
96
|
+
case constants_1.ComponentTypes.Separator: {
|
97
|
+
return Components_js_1.Components.separatorToRaw(component);
|
98
|
+
}
|
99
|
+
case constants_1.ComponentTypes.MediaGallery: {
|
100
|
+
return Components_js_1.Components.mediaGalleryToRaw(component);
|
222
101
|
}
|
223
|
-
}
|
224
|
-
})
|
102
|
+
}
|
103
|
+
});
|
225
104
|
}
|
226
105
|
static embedFromRaw(embed) {
|
227
106
|
return {
|
@@ -20,6 +20,7 @@ __exportStar(require("./Applications"), exports);
|
|
20
20
|
__exportStar(require("./AuditLogs"), exports);
|
21
21
|
__exportStar(require("./AutoModeration"), exports);
|
22
22
|
__exportStar(require("./Channels"), exports);
|
23
|
+
__exportStar(require("./Components.js"), exports);
|
23
24
|
__exportStar(require("./Emojis"), exports);
|
24
25
|
__exportStar(require("./Entitlements"), exports);
|
25
26
|
__exportStar(require("./Guilds"), exports);
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import type { ApplicationCommandOptionType, ApplicationCommandTypes, ApplicationIntegrationTypes, ComponentTypes, InteractionCallbackType, InteractionContextTypes, InteractionType, Locales, MessageFlags } from "../constants";
|
2
|
-
import type {
|
2
|
+
import type { FileData } from "../rest";
|
3
3
|
import type { RawApplicationCommandOptionChoice, ApplicationCommandOptionChoice } from "./application-command";
|
4
4
|
import type { RawChannel, Channel } from "./channel";
|
5
5
|
import type { snowflake } from "./common";
|
6
6
|
import type { RawEntitlement, Entitlement } from "./entitlements";
|
7
7
|
import type { RawGuildMember, GuildMember, Guild, RawGuild } from "./guild";
|
8
|
-
import type { RawMessage, RawAttachment, RawEmbed, RawAllowedMentions, Message, Attachment, Embed, AllowedMentions } from "./message";
|
9
|
-
import type { RawTextInput,
|
8
|
+
import type { RawMessage, RawAttachment, RawEmbed, RawAllowedMentions, Message, Attachment, Embed, AllowedMentions, MessageTopLevelComponent, RawMessageTopLevelComponent } from "./message";
|
9
|
+
import type { RawTextInput, TextInput } from "./message-components";
|
10
10
|
import type { RawPollCreateParams, PollCreateParams } from "./poll";
|
11
11
|
import type { RawRole, Role } from "./role";
|
12
12
|
import type { RawUser, User } from "./user";
|
@@ -96,10 +96,10 @@ export interface RawInteractionCallbackData {
|
|
96
96
|
embeds?: Array<RawEmbed>;
|
97
97
|
allowed_mentions?: RawAllowedMentions;
|
98
98
|
flags?: MessageFlags;
|
99
|
-
components?: Array<
|
99
|
+
components?: Array<RawMessageTopLevelComponent>;
|
100
100
|
attachments?: Array<Pick<RawAttachment, "filename" | "description">>;
|
101
101
|
poll?: RawPollCreateParams;
|
102
|
-
files?: Array<
|
102
|
+
files?: Array<FileData>;
|
103
103
|
choices?: Array<RawApplicationCommandOptionChoice>;
|
104
104
|
custom_id?: string;
|
105
105
|
title?: string;
|
@@ -205,10 +205,10 @@ export interface InteractionCallbackData {
|
|
205
205
|
embeds?: Array<Embed>;
|
206
206
|
allowedMentions?: AllowedMentions;
|
207
207
|
flags?: MessageFlags;
|
208
|
-
components?: Array<
|
208
|
+
components?: Array<MessageTopLevelComponent>;
|
209
209
|
attachments?: Array<Pick<Attachment, "filename" | "description">>;
|
210
210
|
poll?: PollCreateParams;
|
211
|
-
files?: Array<
|
211
|
+
files?: Array<FileData>;
|
212
212
|
choices?: Array<ApplicationCommandOptionChoice>;
|
213
213
|
customID?: string;
|
214
214
|
title?: string;
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import type { ButtonStyles, ChannelTypes, ComponentTypes, TextInputStyles } from "../constants";
|
1
|
+
import type { ButtonStyles, ChannelTypes, ComponentTypes, SeparatorSpacing, TextInputStyles } from "../constants";
|
2
2
|
import type { snowflake } from "./common";
|
3
3
|
import type { RawEmoji, Emoji } from "./emoji";
|
4
|
-
/** https://discord.com/developers/docs/
|
4
|
+
/** https://discord.com/developers/docs/components/reference#button-button-structure */
|
5
5
|
export interface RawButton {
|
6
6
|
type: ComponentTypes.Button;
|
7
7
|
style: ButtonStyles;
|
@@ -11,6 +11,41 @@ export interface RawButton {
|
|
11
11
|
sku_id?: snowflake;
|
12
12
|
url?: string;
|
13
13
|
disabled?: boolean;
|
14
|
+
id?: number;
|
15
|
+
}
|
16
|
+
/** https://discord.com/developers/docs/components/reference#container-container-structure */
|
17
|
+
export interface RawContainer {
|
18
|
+
type: ComponentTypes.Container;
|
19
|
+
id?: number;
|
20
|
+
components: Array<RawActionRow | RawTextDisplay | RawSection | RawMediaGallery | RawSeparator | RawFile>;
|
21
|
+
accent_color?: number | null;
|
22
|
+
spoiler?: boolean;
|
23
|
+
}
|
24
|
+
/** https://discord.com/developers/docs/components/reference#file-file-structure */
|
25
|
+
export interface RawFile {
|
26
|
+
type: ComponentTypes.File;
|
27
|
+
id?: number;
|
28
|
+
file: RawUnfurledMediaItem;
|
29
|
+
spoiler?: boolean;
|
30
|
+
}
|
31
|
+
/** https://discord.com/developers/docs/components/reference#media-gallery-media-gallery-structure */
|
32
|
+
export interface RawMediaGallery {
|
33
|
+
type: ComponentTypes.MediaGallery;
|
34
|
+
id?: number;
|
35
|
+
items: Array<RawMediaGalleryItem>;
|
36
|
+
}
|
37
|
+
/** https://discord.com/developers/docs/components/reference#media-gallery-media-gallery-item-structure */
|
38
|
+
export interface RawMediaGalleryItem {
|
39
|
+
media: RawUnfurledMediaItem;
|
40
|
+
description?: string;
|
41
|
+
spoiler?: boolean;
|
42
|
+
}
|
43
|
+
/** https://discord.com/developers/docs/components/reference#section-section-structure */
|
44
|
+
export interface RawSection {
|
45
|
+
type: ComponentTypes.Section;
|
46
|
+
id?: number;
|
47
|
+
components: Array<RawTextDisplay>;
|
48
|
+
accessory: RawThumbnail | RawButton;
|
14
49
|
}
|
15
50
|
/** https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure */
|
16
51
|
export interface RawSelectMenu {
|
@@ -23,8 +58,9 @@ export interface RawSelectMenu {
|
|
23
58
|
min_values?: number;
|
24
59
|
max_values?: number;
|
25
60
|
disabled?: boolean;
|
61
|
+
id?: number;
|
26
62
|
}
|
27
|
-
/** https://discord.com/developers/docs/
|
63
|
+
/** https://discord.com/developers/docs/components/reference#string-select-select-option-structure */
|
28
64
|
export interface RawSelectOption {
|
29
65
|
label: string;
|
30
66
|
value: string;
|
@@ -32,12 +68,33 @@ export interface RawSelectOption {
|
|
32
68
|
emoji?: Pick<RawEmoji, "name" | "id" | "animated">;
|
33
69
|
default?: boolean;
|
34
70
|
}
|
35
|
-
/** https://discord.com/developers/docs/
|
71
|
+
/** https://discord.com/developers/docs/components/reference#separator-separator-structure */
|
72
|
+
export interface RawSeparator {
|
73
|
+
type: ComponentTypes.Separator;
|
74
|
+
id?: number;
|
75
|
+
divider?: boolean;
|
76
|
+
spacing?: SeparatorSpacing;
|
77
|
+
}
|
78
|
+
/** https://discord.com/developers/docs/components/reference#text-display-text-display-structure */
|
79
|
+
export interface RawTextDisplay {
|
80
|
+
type: ComponentTypes.TextDisplay;
|
81
|
+
id?: number;
|
82
|
+
content: string;
|
83
|
+
}
|
84
|
+
/** https://discord.com/developers/docs/components/reference#thumbnail-thumbnail-structure */
|
85
|
+
export interface RawThumbnail {
|
86
|
+
type: ComponentTypes.Thumbnail;
|
87
|
+
id?: number;
|
88
|
+
media: RawUnfurledMediaItem;
|
89
|
+
description?: string;
|
90
|
+
spoiler?: boolean;
|
91
|
+
}
|
92
|
+
/** https://discord.com/developers/docs/components/reference#user-select-select-default-value-structure */
|
36
93
|
export interface RawDefaultValue {
|
37
94
|
id: snowflake;
|
38
95
|
type: string;
|
39
96
|
}
|
40
|
-
/** https://discord.com/developers/docs/
|
97
|
+
/** https://discord.com/developers/docs/components/reference#text-input-text-input-structure */
|
41
98
|
export interface RawTextInput {
|
42
99
|
type: ComponentTypes.TextInput;
|
43
100
|
custom_id: string;
|
@@ -48,11 +105,21 @@ export interface RawTextInput {
|
|
48
105
|
required?: boolean;
|
49
106
|
value?: string;
|
50
107
|
placeholder?: string;
|
108
|
+
id?: number;
|
51
109
|
}
|
52
|
-
/** https://discord.com/developers/docs/
|
110
|
+
/** https://discord.com/developers/docs/components/reference#action-row-action-row-structure */
|
53
111
|
export interface RawActionRow {
|
54
112
|
type: ComponentTypes.ActionRow;
|
55
113
|
components: Array<RawButton | RawSelectMenu | RawTextInput>;
|
114
|
+
id?: number;
|
115
|
+
}
|
116
|
+
/** https://discord.com/developers/docs/components/reference#unfurled-media-item-structure */
|
117
|
+
export interface RawUnfurledMediaItem {
|
118
|
+
url: string;
|
119
|
+
proxy_url?: string;
|
120
|
+
height?: number | null;
|
121
|
+
width?: number | null;
|
122
|
+
content_type?: string;
|
56
123
|
}
|
57
124
|
export interface Button {
|
58
125
|
type: ComponentTypes.Button;
|
@@ -63,6 +130,36 @@ export interface Button {
|
|
63
130
|
skuID?: snowflake;
|
64
131
|
url?: string;
|
65
132
|
disabled?: boolean;
|
133
|
+
id?: number;
|
134
|
+
}
|
135
|
+
export interface Container {
|
136
|
+
type: ComponentTypes.Container;
|
137
|
+
id?: number;
|
138
|
+
components: Array<ActionRow | TextDisplay | Section | MediaGallery | Separator | File>;
|
139
|
+
accentColor?: number | null;
|
140
|
+
spoiler?: boolean;
|
141
|
+
}
|
142
|
+
export interface File {
|
143
|
+
type: ComponentTypes.File;
|
144
|
+
id?: number;
|
145
|
+
file: UnfurledMediaItem;
|
146
|
+
spoiler?: boolean;
|
147
|
+
}
|
148
|
+
export interface MediaGallery {
|
149
|
+
type: ComponentTypes.MediaGallery;
|
150
|
+
id?: number;
|
151
|
+
items: Array<MediaGalleryItem>;
|
152
|
+
}
|
153
|
+
export interface MediaGalleryItem {
|
154
|
+
media: UnfurledMediaItem;
|
155
|
+
description?: string;
|
156
|
+
spoiler?: boolean;
|
157
|
+
}
|
158
|
+
export interface Section {
|
159
|
+
type: ComponentTypes.Section;
|
160
|
+
id?: number;
|
161
|
+
components: Array<TextDisplay>;
|
162
|
+
accessory: Thumbnail | Button;
|
66
163
|
}
|
67
164
|
export interface SelectMenu {
|
68
165
|
type: ComponentTypes.ChannelSelect | ComponentTypes.MentionableSelect | ComponentTypes.RoleSelect | ComponentTypes.StringSelect | ComponentTypes.UserSelect;
|
@@ -74,6 +171,7 @@ export interface SelectMenu {
|
|
74
171
|
minValues?: number;
|
75
172
|
maxValues?: number;
|
76
173
|
disabled?: boolean;
|
174
|
+
id?: number;
|
77
175
|
}
|
78
176
|
export interface SelectOption {
|
79
177
|
label: string;
|
@@ -82,6 +180,24 @@ export interface SelectOption {
|
|
82
180
|
emoji?: Pick<Emoji, "name" | "id" | "animated">;
|
83
181
|
default?: boolean;
|
84
182
|
}
|
183
|
+
export interface Separator {
|
184
|
+
type: ComponentTypes.Separator;
|
185
|
+
id?: number;
|
186
|
+
divider?: boolean;
|
187
|
+
spacing?: SeparatorSpacing;
|
188
|
+
}
|
189
|
+
export interface TextDisplay {
|
190
|
+
type: ComponentTypes.TextDisplay;
|
191
|
+
id?: number;
|
192
|
+
content: string;
|
193
|
+
}
|
194
|
+
export interface Thumbnail {
|
195
|
+
type: ComponentTypes.Thumbnail;
|
196
|
+
id?: number;
|
197
|
+
media: UnfurledMediaItem;
|
198
|
+
description?: string;
|
199
|
+
spoiler?: boolean;
|
200
|
+
}
|
85
201
|
export interface DefaultValue {
|
86
202
|
id: snowflake;
|
87
203
|
type: string;
|
@@ -96,8 +212,17 @@ export interface TextInput {
|
|
96
212
|
required?: boolean;
|
97
213
|
value?: string;
|
98
214
|
placeholder?: string;
|
215
|
+
id?: number;
|
99
216
|
}
|
100
217
|
export interface ActionRow {
|
101
218
|
type: ComponentTypes.ActionRow;
|
102
219
|
components: Array<Button | SelectMenu | TextInput>;
|
220
|
+
id?: number;
|
221
|
+
}
|
222
|
+
export interface UnfurledMediaItem {
|
223
|
+
url: string;
|
224
|
+
proxyURL?: string;
|
225
|
+
height?: number | null;
|
226
|
+
width?: number | null;
|
227
|
+
contentType?: string;
|
103
228
|
}
|
@@ -4,7 +4,7 @@ import type { Channel, RawChannel, RawRoleSubscriptionData, RoleSubscriptionData
|
|
4
4
|
import type { snowflake, timestamp } from "./common";
|
5
5
|
import type { Emoji, RawEmoji } from "./emoji";
|
6
6
|
import type { MessageInteraction, RawMessageInteraction, RawResolvedData, ResolvedData } from "./interaction";
|
7
|
-
import type { ActionRow, RawActionRow } from "./message-components";
|
7
|
+
import type { ActionRow, Container, File, MediaGallery, RawActionRow, RawContainer, RawFile, RawMediaGallery, RawSection, RawSeparator, RawTextDisplay, Section, Separator, TextDisplay } from "./message-components";
|
8
8
|
import type { Poll, RawPoll } from "./poll";
|
9
9
|
import type { RawStickerItem, RawSticker, Sticker, StickerItem } from "./sticker";
|
10
10
|
import type { RawUser, User } from "./user";
|
@@ -38,7 +38,7 @@ export interface RawMessage {
|
|
38
38
|
interaction_metadata?: RawMessageInteractionMetadata;
|
39
39
|
interaction?: RawMessageInteraction;
|
40
40
|
thread?: RawChannel;
|
41
|
-
components?: Array<
|
41
|
+
components?: Array<RawMessageTopLevelComponent>;
|
42
42
|
sticker_items?: Array<RawStickerItem>;
|
43
43
|
stickers?: Array<RawSticker>;
|
44
44
|
position?: number;
|
@@ -47,6 +47,7 @@ export interface RawMessage {
|
|
47
47
|
poll?: RawPoll;
|
48
48
|
call?: RawMessageCall;
|
49
49
|
}
|
50
|
+
export type RawMessageTopLevelComponent = RawActionRow | RawTextDisplay | RawContainer | RawFile | RawSection | RawSeparator | RawMediaGallery;
|
50
51
|
/** https://discord.com/developers/docs/resources/message#message-object-message-activity-structure */
|
51
52
|
export interface RawMessageActivity {
|
52
53
|
type: MessageActivityTypes;
|
@@ -225,7 +226,7 @@ export interface Message {
|
|
225
226
|
interactionMetadata?: MessageInteractionMetadata;
|
226
227
|
interaction?: MessageInteraction;
|
227
228
|
thread?: Channel;
|
228
|
-
components?: Array<
|
229
|
+
components?: Array<MessageTopLevelComponent>;
|
229
230
|
stickerItems?: Array<StickerItem>;
|
230
231
|
stickers?: Array<Sticker>;
|
231
232
|
position?: number;
|
@@ -234,6 +235,7 @@ export interface Message {
|
|
234
235
|
poll?: Poll;
|
235
236
|
call?: MessageCall;
|
236
237
|
}
|
238
|
+
export type MessageTopLevelComponent = ActionRow | TextDisplay | Container | File | Section | Separator | MediaGallery;
|
237
239
|
export interface MessageActivity {
|
238
240
|
type: MessageActivityTypes;
|
239
241
|
partyID?: string;
|
package/dist/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "disgroove",
|
3
|
-
"version": "2.2.
|
3
|
+
"version": "2.2.6-dev.4de2c29",
|
4
4
|
"description": "A module to interface with Discord",
|
5
5
|
"main": "./dist/lib/index.js",
|
6
6
|
"types": "./dist/lib/index.d.ts",
|
@@ -27,7 +27,8 @@
|
|
27
27
|
"devDependencies": {
|
28
28
|
"@types/node": "^22.13.11",
|
29
29
|
"@types/ws": "^8.18.0",
|
30
|
-
"typescript": "^5.8.2"
|
30
|
+
"typescript": "^5.8.2",
|
31
|
+
"undici-types": "^7.9.0"
|
31
32
|
},
|
32
33
|
"dependencies": {
|
33
34
|
"ws": "^8.18.1"
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "disgroove",
|
3
|
-
"version": "2.2.
|
3
|
+
"version": "2.2.6-dev.4de2c29",
|
4
4
|
"description": "A module to interface with Discord",
|
5
5
|
"main": "./dist/lib/index.js",
|
6
6
|
"types": "./dist/lib/index.d.ts",
|
@@ -27,7 +27,8 @@
|
|
27
27
|
"devDependencies": {
|
28
28
|
"@types/node": "^22.13.11",
|
29
29
|
"@types/ws": "^8.18.0",
|
30
|
-
"typescript": "^5.8.2"
|
30
|
+
"typescript": "^5.8.2",
|
31
|
+
"undici-types": "^7.9.0"
|
31
32
|
},
|
32
33
|
"dependencies": {
|
33
34
|
"ws": "^8.18.1"
|