disgroove 0.0.1

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.
Files changed (151) hide show
  1. package/dist/class/Client.d.ts +306 -0
  2. package/dist/class/Client.js +771 -0
  3. package/dist/class/Client.js.map +1 -0
  4. package/dist/class/index.d.ts +1 -0
  5. package/dist/class/index.js +18 -0
  6. package/dist/class/index.js.map +1 -0
  7. package/dist/index.d.ts +5 -0
  8. package/dist/index.js +22 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/rest/Endpoints.d.ts +97 -0
  11. package/dist/rest/Endpoints.js +205 -0
  12. package/dist/rest/Endpoints.js.map +1 -0
  13. package/dist/rest/REST.d.ts +16 -0
  14. package/dist/rest/REST.js +55 -0
  15. package/dist/rest/REST.js.map +1 -0
  16. package/dist/rest/index.d.ts +2 -0
  17. package/dist/rest/index.js +32 -0
  18. package/dist/rest/index.js.map +1 -0
  19. package/dist/structures/Application.d.ts +250 -0
  20. package/dist/structures/Application.js +258 -0
  21. package/dist/structures/Application.js.map +1 -0
  22. package/dist/structures/ApplicationCommand.d.ts +68 -0
  23. package/dist/structures/ApplicationCommand.js +133 -0
  24. package/dist/structures/ApplicationCommand.js.map +1 -0
  25. package/dist/structures/AuditLogEntry.d.ts +16 -0
  26. package/dist/structures/AuditLogEntry.js +54 -0
  27. package/dist/structures/AuditLogEntry.js.map +1 -0
  28. package/dist/structures/AutoModerationRule.d.ts +29 -0
  29. package/dist/structures/AutoModerationRule.js +85 -0
  30. package/dist/structures/AutoModerationRule.js.map +1 -0
  31. package/dist/structures/Channel.d.ts +296 -0
  32. package/dist/structures/Channel.js +579 -0
  33. package/dist/structures/Channel.js.map +1 -0
  34. package/dist/structures/Guild.d.ts +452 -0
  35. package/dist/structures/Guild.js +1161 -0
  36. package/dist/structures/Guild.js.map +1 -0
  37. package/dist/structures/GuildMember.d.ts +46 -0
  38. package/dist/structures/GuildMember.js +126 -0
  39. package/dist/structures/GuildMember.js.map +1 -0
  40. package/dist/structures/GuildScheduledEvent.d.ts +45 -0
  41. package/dist/structures/GuildScheduledEvent.js +115 -0
  42. package/dist/structures/GuildScheduledEvent.js.map +1 -0
  43. package/dist/structures/GuildTemplate.d.ts +25 -0
  44. package/dist/structures/GuildTemplate.js +80 -0
  45. package/dist/structures/GuildTemplate.js.map +1 -0
  46. package/dist/structures/Integration.d.ts +28 -0
  47. package/dist/structures/Integration.js +96 -0
  48. package/dist/structures/Integration.js.map +1 -0
  49. package/dist/structures/Interaction.d.ts +204 -0
  50. package/dist/structures/Interaction.js +368 -0
  51. package/dist/structures/Interaction.js.map +1 -0
  52. package/dist/structures/Invite.d.ts +22 -0
  53. package/dist/structures/Invite.js +108 -0
  54. package/dist/structures/Invite.js.map +1 -0
  55. package/dist/structures/Message.d.ts +97 -0
  56. package/dist/structures/Message.js +327 -0
  57. package/dist/structures/Message.js.map +1 -0
  58. package/dist/structures/Role.d.ts +35 -0
  59. package/dist/structures/Role.js +81 -0
  60. package/dist/structures/Role.js.map +1 -0
  61. package/dist/structures/StageInstance.d.ts +20 -0
  62. package/dist/structures/StageInstance.js +53 -0
  63. package/dist/structures/StageInstance.js.map +1 -0
  64. package/dist/structures/User.d.ts +53 -0
  65. package/dist/structures/User.js +168 -0
  66. package/dist/structures/User.js.map +1 -0
  67. package/dist/structures/Webhook.d.ts +133 -0
  68. package/dist/structures/Webhook.js +189 -0
  69. package/dist/structures/Webhook.js.map +1 -0
  70. package/dist/structures/index.d.ts +17 -0
  71. package/dist/structures/index.js +34 -0
  72. package/dist/structures/index.js.map +1 -0
  73. package/dist/types/application-command.d.ts +97 -0
  74. package/dist/types/application-command.js +3 -0
  75. package/dist/types/application-command.js.map +1 -0
  76. package/dist/types/application-role-connection-metadata.d.ts +17 -0
  77. package/dist/types/application-role-connection-metadata.js +3 -0
  78. package/dist/types/application-role-connection-metadata.js.map +1 -0
  79. package/dist/types/application.d.ts +55 -0
  80. package/dist/types/application.js +3 -0
  81. package/dist/types/application.js.map +1 -0
  82. package/dist/types/audit-log.d.ts +77 -0
  83. package/dist/types/audit-log.js +3 -0
  84. package/dist/types/audit-log.js.map +1 -0
  85. package/dist/types/auto-moderation.d.ts +61 -0
  86. package/dist/types/auto-moderation.js +3 -0
  87. package/dist/types/auto-moderation.js.map +1 -0
  88. package/dist/types/channel.d.ts +411 -0
  89. package/dist/types/channel.js +3 -0
  90. package/dist/types/channel.js.map +1 -0
  91. package/dist/types/emoji.d.ts +22 -0
  92. package/dist/types/emoji.js +3 -0
  93. package/dist/types/emoji.js.map +1 -0
  94. package/dist/types/gateway-events.d.ts +53 -0
  95. package/dist/types/gateway-events.js +3 -0
  96. package/dist/types/gateway-events.js.map +1 -0
  97. package/dist/types/guild-scheduled-event.d.ts +55 -0
  98. package/dist/types/guild-scheduled-event.js +3 -0
  99. package/dist/types/guild-scheduled-event.js.map +1 -0
  100. package/dist/types/guild-template.d.ts +28 -0
  101. package/dist/types/guild-template.js +3 -0
  102. package/dist/types/guild-template.js.map +1 -0
  103. package/dist/types/guild.d.ts +305 -0
  104. package/dist/types/guild.js +3 -0
  105. package/dist/types/guild.js.map +1 -0
  106. package/dist/types/index.d.ts +22 -0
  107. package/dist/types/index.js +39 -0
  108. package/dist/types/index.js.map +1 -0
  109. package/dist/types/interaction.d.ts +141 -0
  110. package/dist/types/interaction.js +3 -0
  111. package/dist/types/interaction.js.map +1 -0
  112. package/dist/types/invite.d.ts +56 -0
  113. package/dist/types/invite.js +3 -0
  114. package/dist/types/invite.js.map +1 -0
  115. package/dist/types/message-components.d.ts +76 -0
  116. package/dist/types/message-components.js +3 -0
  117. package/dist/types/message-components.js.map +1 -0
  118. package/dist/types/oauth2.d.ts +14 -0
  119. package/dist/types/oauth2.js +3 -0
  120. package/dist/types/oauth2.js.map +1 -0
  121. package/dist/types/role.d.ts +42 -0
  122. package/dist/types/role.js +3 -0
  123. package/dist/types/role.js.map +1 -0
  124. package/dist/types/stage-instance.d.ts +18 -0
  125. package/dist/types/stage-instance.js +3 -0
  126. package/dist/types/stage-instance.js.map +1 -0
  127. package/dist/types/sticker.d.ts +59 -0
  128. package/dist/types/sticker.js +3 -0
  129. package/dist/types/sticker.js.map +1 -0
  130. package/dist/types/team.d.ts +28 -0
  131. package/dist/types/team.js +3 -0
  132. package/dist/types/team.js.map +1 -0
  133. package/dist/types/user.d.ts +73 -0
  134. package/dist/types/user.js +3 -0
  135. package/dist/types/user.js.map +1 -0
  136. package/dist/types/voice.d.ts +46 -0
  137. package/dist/types/voice.js +3 -0
  138. package/dist/types/voice.js.map +1 -0
  139. package/dist/types/webhook.d.ts +31 -0
  140. package/dist/types/webhook.js +3 -0
  141. package/dist/types/webhook.js.map +1 -0
  142. package/dist/utils/constants.d.ts +963 -0
  143. package/dist/utils/constants.js +1147 -0
  144. package/dist/utils/constants.js.map +1 -0
  145. package/dist/utils/index.d.ts +2 -0
  146. package/dist/utils/index.js +19 -0
  147. package/dist/utils/index.js.map +1 -0
  148. package/dist/utils/rawers.d.ts +467 -0
  149. package/dist/utils/rawers.js +295 -0
  150. package/dist/utils/rawers.js.map +1 -0
  151. package/package.json +27 -0
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Integration = void 0;
4
+ const _1 = require(".");
5
+ const rest_1 = require("../rest");
6
+ class Integration {
7
+ client;
8
+ id;
9
+ guildId;
10
+ name;
11
+ type;
12
+ enabled;
13
+ syncing;
14
+ roleId;
15
+ enableEmoticons;
16
+ expireBehavior;
17
+ expireGracePeriod;
18
+ user;
19
+ account;
20
+ syncedAt;
21
+ subscriberCount;
22
+ revoked;
23
+ application;
24
+ scopes;
25
+ constructor(data, client) {
26
+ this.client = client;
27
+ this.id = data.id;
28
+ this.guildId = data.guild_id;
29
+ this.name = data.name;
30
+ this.type = data.type;
31
+ this.enabled = data.enabled;
32
+ this.account = data.account;
33
+ this.update(data);
34
+ }
35
+ update(data) {
36
+ if (data.syncing !== undefined)
37
+ this.syncing = data.syncing;
38
+ if (data.role_id !== undefined)
39
+ this.roleId = data.role_id;
40
+ if (data.enable_emoticons !== undefined)
41
+ this.enableEmoticons = data.enable_emoticons;
42
+ if (data.expire_behavior !== undefined)
43
+ this.expireBehavior = data.expire_behavior;
44
+ if (data.expire_grace_period !== undefined)
45
+ this.expireGracePeriod = data.expire_grace_period;
46
+ if (data.user !== undefined)
47
+ this.user = new _1.User(data.user, this.client);
48
+ if (data.synced_at !== undefined)
49
+ this.syncedAt = data.synced_at;
50
+ if (data.subscriber_count !== undefined)
51
+ this.subscriberCount = data.subscriber_count;
52
+ if (data.revoked !== undefined)
53
+ this.revoked = data.revoked;
54
+ if (data.application !== undefined)
55
+ this.application = {
56
+ id: data.application.id,
57
+ name: data.application.name,
58
+ icon: data.application.icon,
59
+ description: data.application.description,
60
+ bot: data.application.bot !== undefined
61
+ ? new _1.User(data.application.bot, this.client)
62
+ : undefined,
63
+ };
64
+ if (data.scopes !== undefined)
65
+ this.scopes = data.scopes;
66
+ }
67
+ /* https://discord.com/developers/docs/resources/guild#delete-guild-integration */
68
+ async delete(reason) {
69
+ this.client.rest.request("DELETE", rest_1.Endpoints.guildIntegration(this.guildId, this.id), {
70
+ reason,
71
+ });
72
+ }
73
+ toJSON() {
74
+ return {
75
+ guildId: this.guildId,
76
+ id: this.id,
77
+ name: this.name,
78
+ type: this.type,
79
+ enabled: this.enabled,
80
+ syncing: this.syncing,
81
+ roleId: this.roleId,
82
+ enableEmoticons: this.enableEmoticons,
83
+ expireBehavior: this.expireBehavior,
84
+ expireGracePeriod: this.expireGracePeriod,
85
+ user: this.user,
86
+ account: this.account,
87
+ syncedAt: this.syncedAt,
88
+ subscriberCount: this.subscriberCount,
89
+ revoked: this.revoked,
90
+ application: this.application,
91
+ scopes: this.scopes,
92
+ };
93
+ }
94
+ }
95
+ exports.Integration = Integration;
96
+ //# sourceMappingURL=Integration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Integration.js","sourceRoot":"","sources":["../../src/structures/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;QACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CACtB,QAAQ,EACR,gBAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,EACjD;YACE,MAAM;SACP,CACF,CAAC;IACJ,CAAC;IAEM,MAAM;QACX,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;CACF;AA5FD,kCA4FC"}
@@ -0,0 +1,204 @@
1
+ import { GuildMember, Message, User } from ".";
2
+ import type { Client } from "../class";
3
+ import { File } from "../rest";
4
+ import type { JSONAllowedMentions, JSONApplicationCommandData, JSONApplicationCommandOptionChoice, JSONAttachment, JSONEmbed, JSONEmoji, JSONInteraction, JSONMessageComponentData, JSONModalSubmitData, JSONSelectOption, RawInteraction } from "../types";
5
+ import { ChannelTypes, ComponentTypes, InteractionCallbackType, InteractionType, MessageFlags } from "../utils";
6
+ interface ActionRow {
7
+ type: ComponentTypes.ActionRow;
8
+ components: Array<Button | SelectMenu | TextInput>;
9
+ }
10
+ interface Button {
11
+ type: ComponentTypes.Button;
12
+ style: number;
13
+ label?: string;
14
+ emoji?: JSONEmoji;
15
+ customId?: string;
16
+ url?: string;
17
+ disabled?: boolean;
18
+ }
19
+ interface SelectMenu {
20
+ type: ComponentTypes.SelectMenu | ComponentTypes.ChannelSelect | ComponentTypes.MentionableSelect | ComponentTypes.RoleSelect | ComponentTypes.UserSelect;
21
+ customId: string;
22
+ options?: Array<JSONSelectOption>;
23
+ channelTypes?: Array<ChannelTypes>;
24
+ placeholder?: string;
25
+ minValues?: number;
26
+ maxValues?: number;
27
+ disabled?: boolean;
28
+ }
29
+ interface TextInput {
30
+ type: ComponentTypes.TextInput;
31
+ customId: string;
32
+ style: number;
33
+ label: string;
34
+ minLength?: number;
35
+ maxLength?: number;
36
+ required?: boolean;
37
+ value?: string;
38
+ placeholder?: string;
39
+ }
40
+ export declare class Interaction {
41
+ private client;
42
+ id: string;
43
+ applicationId: string;
44
+ type: InteractionType;
45
+ data?: JSONApplicationCommandData & JSONMessageComponentData & JSONModalSubmitData;
46
+ guildId?: string;
47
+ channelId?: string;
48
+ member?: GuildMember;
49
+ user?: User;
50
+ token: string;
51
+ version: number;
52
+ message?: Message;
53
+ appPermissions?: string;
54
+ locale?: string;
55
+ guildLocale?: string;
56
+ constructor(data: RawInteraction, client: Client);
57
+ protected update(data: RawInteraction): void;
58
+ createResponse(options: {
59
+ type: InteractionCallbackType;
60
+ data: {
61
+ tts?: boolean;
62
+ content?: string;
63
+ embeds?: Array<JSONEmbed>;
64
+ allowedMentions?: JSONAllowedMentions;
65
+ flags?: MessageFlags;
66
+ components?: Array<ActionRow>;
67
+ attachments?: Array<JSONAttachment>;
68
+ choices?: Array<JSONApplicationCommandOptionChoice>;
69
+ customId?: string;
70
+ title?: string;
71
+ };
72
+ }): Promise<void>;
73
+ getOriginalResponse(options?: {
74
+ threadId?: string;
75
+ }): Promise<Message>;
76
+ editOriginalResponse(options: {
77
+ threadId?: string;
78
+ content?: string | null;
79
+ embeds?: Array<JSONEmbed> | null;
80
+ flags?: MessageFlags | null;
81
+ allowedMentions?: JSONAllowedMentions | null;
82
+ components?: Array<{
83
+ type: ComponentTypes.ActionRow;
84
+ components: Array<{
85
+ type: ComponentTypes.Button;
86
+ style: number;
87
+ label?: string;
88
+ emoji?: JSONEmoji;
89
+ customId?: string;
90
+ url?: string;
91
+ disabled?: boolean;
92
+ } | {
93
+ type: ComponentTypes.SelectMenu | ComponentTypes.ChannelSelect | ComponentTypes.MentionableSelect | ComponentTypes.RoleSelect | ComponentTypes.UserSelect;
94
+ customId: string;
95
+ options?: Array<JSONSelectOption>;
96
+ channelTypes?: Array<ChannelTypes>;
97
+ placeholder?: string;
98
+ minValues?: number;
99
+ maxValues?: number;
100
+ disabled?: boolean;
101
+ } | {
102
+ type: ComponentTypes.TextInput;
103
+ customId: string;
104
+ style: number;
105
+ label: string;
106
+ minLength?: number;
107
+ maxLength?: number;
108
+ required?: boolean;
109
+ value?: string;
110
+ placeholder?: string;
111
+ }>;
112
+ }> | null;
113
+ files?: Array<File> | null;
114
+ attachments?: Array<JSONAttachment> | null;
115
+ }): Promise<Message>;
116
+ deleteOriginalResponse(): Promise<void>;
117
+ createFollowupMessage(options: {
118
+ content?: string | null;
119
+ tts?: boolean;
120
+ embeds?: Array<JSONEmbed> | null;
121
+ allowedMentions?: JSONAllowedMentions | null;
122
+ components?: Array<{
123
+ type: ComponentTypes.ActionRow;
124
+ components: Array<{
125
+ type: ComponentTypes.Button;
126
+ style: number;
127
+ label?: string;
128
+ emoji?: JSONEmoji;
129
+ customId?: string;
130
+ url?: string;
131
+ disabled?: boolean;
132
+ } | {
133
+ type: ComponentTypes.SelectMenu | ComponentTypes.ChannelSelect | ComponentTypes.MentionableSelect | ComponentTypes.RoleSelect | ComponentTypes.UserSelect;
134
+ customId: string;
135
+ options?: Array<JSONSelectOption>;
136
+ channelTypes?: Array<ChannelTypes>;
137
+ placeholder?: string;
138
+ minValues?: number;
139
+ maxValues?: number;
140
+ disabled?: boolean;
141
+ } | {
142
+ type: ComponentTypes.TextInput;
143
+ customId: string;
144
+ style: number;
145
+ label: string;
146
+ minLength?: number;
147
+ maxLength?: number;
148
+ required?: boolean;
149
+ value?: string;
150
+ placeholder?: string;
151
+ }>;
152
+ }> | null;
153
+ files?: Array<File> | null;
154
+ attachments?: Array<JSONAttachment> | null;
155
+ flags?: MessageFlags | null;
156
+ threadName?: string;
157
+ }): Promise<void>;
158
+ getFollowupMessage(messageId: string, options?: {
159
+ threadId?: string;
160
+ }): Promise<Message>;
161
+ editFollowupMessage(messageId: string, options: {
162
+ threadId?: string;
163
+ content?: string | null;
164
+ embeds?: Array<JSONEmbed> | null;
165
+ flags?: MessageFlags | null;
166
+ allowedMentions?: JSONAllowedMentions | null;
167
+ components?: Array<{
168
+ type: ComponentTypes.ActionRow;
169
+ components: Array<{
170
+ type: ComponentTypes.Button;
171
+ style: number;
172
+ label?: string;
173
+ emoji?: JSONEmoji;
174
+ customId?: string;
175
+ url?: string;
176
+ disabled?: boolean;
177
+ } | {
178
+ type: ComponentTypes.SelectMenu | ComponentTypes.ChannelSelect | ComponentTypes.MentionableSelect | ComponentTypes.RoleSelect | ComponentTypes.UserSelect;
179
+ customId: string;
180
+ options?: Array<JSONSelectOption>;
181
+ channelTypes?: Array<ChannelTypes>;
182
+ placeholder?: string;
183
+ minValues?: number;
184
+ maxValues?: number;
185
+ disabled?: boolean;
186
+ } | {
187
+ type: ComponentTypes.TextInput;
188
+ customId: string;
189
+ style: number;
190
+ label: string;
191
+ minLength?: number;
192
+ maxLength?: number;
193
+ required?: boolean;
194
+ value?: string;
195
+ placeholder?: string;
196
+ }>;
197
+ }> | null;
198
+ files?: Array<File> | null;
199
+ attachments?: Array<JSONAttachment> | null;
200
+ }): Promise<Message>;
201
+ deleteFollowupMessage(messageId: string): Promise<void>;
202
+ toJSON(): JSONInteraction;
203
+ }
204
+ export {};
@@ -0,0 +1,368 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Interaction = void 0;
4
+ const _1 = require(".");
5
+ const rest_1 = require("../rest");
6
+ const utils_1 = require("../utils");
7
+ class Interaction {
8
+ client;
9
+ id;
10
+ applicationId;
11
+ type;
12
+ data;
13
+ guildId;
14
+ channelId;
15
+ member;
16
+ user;
17
+ token;
18
+ version;
19
+ message;
20
+ appPermissions;
21
+ locale;
22
+ guildLocale;
23
+ constructor(data, client) {
24
+ this.client = client;
25
+ this.id = data.id;
26
+ this.applicationId = data.application_id;
27
+ this.type = data.type;
28
+ this.token = data.token;
29
+ this.version = data.version;
30
+ this.update(data);
31
+ }
32
+ update(data) {
33
+ if (data.data !== undefined)
34
+ this.data = {
35
+ id: data.data.id,
36
+ name: data.data.name,
37
+ type: data.data.type,
38
+ resolved: {
39
+ users: data.data.resolved?.users?.map((user) => new _1.User(user, this.client)),
40
+ members: data.data.resolved?.members?.map((member) => new _1.GuildMember(member, this.client)),
41
+ roles: data.data.resolved?.roles?.map((roles) => new _1.Role(roles, this.client)),
42
+ channels: data.data.resolved?.channels?.map((channel) => new _1.Channel(channel, this.client)),
43
+ messages: data.data.resolved?.messages?.map((message) => new _1.Message(message, this.client)),
44
+ attachments: data.data.resolved?.attachments?.map((attachment) => ({
45
+ id: attachment.id,
46
+ filename: attachment.filename,
47
+ description: attachment.description,
48
+ contentType: attachment.content_type,
49
+ size: attachment.size,
50
+ url: attachment.url,
51
+ proxyUrl: attachment.proxy_url,
52
+ height: attachment.height,
53
+ width: attachment.width,
54
+ ephemeral: attachment.ephemeral,
55
+ })),
56
+ },
57
+ options: data.data.options?.map((option) => ({
58
+ name: option.name,
59
+ type: option.type,
60
+ value: option.value,
61
+ options: option.options?.map((o) => ({
62
+ name: o.name,
63
+ type: o.type,
64
+ value: o.value,
65
+ focused: o.focused,
66
+ })),
67
+ focused: option.focused,
68
+ })),
69
+ guildId: data.data.guild_id,
70
+ targetId: data.data.target_id,
71
+ customId: data.data.custom_id,
72
+ componentType: data.data.component_type,
73
+ values: data.data.values?.map((value) => ({
74
+ label: value.label,
75
+ value: value.value,
76
+ description: value.description,
77
+ emoji: value.emoji !== undefined
78
+ ? {
79
+ id: value.emoji.id,
80
+ name: value.emoji.name,
81
+ roles: value.emoji.roles,
82
+ user: value.emoji.user !== undefined
83
+ ? new _1.User(value.emoji.user, this.client)
84
+ : undefined,
85
+ requireColons: value.emoji.require_colons,
86
+ managed: value.emoji.managed,
87
+ animated: value.emoji.animated,
88
+ available: value.emoji.available,
89
+ }
90
+ : undefined,
91
+ default: value.default,
92
+ })),
93
+ components: data.data.components?.map((component) => ({
94
+ type: component.type,
95
+ components: component.components.map((c) => ({
96
+ type: c.type,
97
+ customId: c.custom_id,
98
+ style: c.style,
99
+ label: c.label,
100
+ minLength: c.min_length,
101
+ maxLength: c.max_length,
102
+ required: c.required,
103
+ value: c.value,
104
+ placeholder: c.placeholder,
105
+ })),
106
+ })),
107
+ };
108
+ if (data.guild_id !== undefined)
109
+ this.guildId = data.guild_id;
110
+ if (data.channel_id !== undefined)
111
+ this.channelId = data.channel_id;
112
+ if (data.member !== undefined)
113
+ this.member = new _1.GuildMember(data.member, this.client);
114
+ if (data.user !== undefined)
115
+ this.user = new _1.User(data.user, this.client);
116
+ if (data.message !== undefined)
117
+ this.message = new _1.Message(data.message, this.client);
118
+ if (data.app_permissions !== undefined)
119
+ this.appPermissions = data.app_permissions;
120
+ if (data.locale !== undefined)
121
+ this.locale = data.locale;
122
+ if (data.guild_locale !== undefined)
123
+ this.guildLocale = data.guild_locale;
124
+ }
125
+ /* https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */
126
+ async createResponse(options) {
127
+ switch (options.type) {
128
+ case utils_1.InteractionCallbackType.Pong:
129
+ break;
130
+ case utils_1.InteractionCallbackType.ChannelMessageWithSource:
131
+ case utils_1.InteractionCallbackType.UpdateMessage:
132
+ {
133
+ await this.client.rest.request("POST", rest_1.Endpoints.interactionCallback(this.id, this.token), {
134
+ json: {
135
+ type: options.type,
136
+ data: {
137
+ content: options.data.content,
138
+ embeds: options.data.embeds?.map((embed) => ({
139
+ title: embed.title,
140
+ type: embed.type,
141
+ description: embed.description,
142
+ url: embed.url,
143
+ timestamp: embed.timestamp,
144
+ color: embed.color,
145
+ footer: embed.footer,
146
+ image: {
147
+ url: embed.image?.url,
148
+ proxy_url: embed.image?.proxyUrl,
149
+ height: embed.image?.height,
150
+ width: embed.image?.width,
151
+ },
152
+ thumbnail: {
153
+ url: embed.thumbnail?.url,
154
+ proxy_url: embed.thumbnail?.proxyUrl,
155
+ height: embed.thumbnail?.height,
156
+ width: embed.thumbnail?.width,
157
+ },
158
+ video: {
159
+ url: embed.video?.url,
160
+ proxy_url: embed.video?.proxyUrl,
161
+ height: embed.video?.height,
162
+ width: embed.video?.width,
163
+ },
164
+ provider: {
165
+ name: embed.provider?.name,
166
+ url: embed.provider?.url,
167
+ },
168
+ author: {
169
+ name: embed.author?.name,
170
+ url: embed.author?.url,
171
+ icon_url: embed.author?.iconUrl,
172
+ proxy_icon_url: embed.author?.proxyIconUrl,
173
+ },
174
+ fields: embed.fields?.map((field) => ({
175
+ name: field.name,
176
+ value: field.value,
177
+ inline: field.inline,
178
+ })),
179
+ })),
180
+ allowed_mentions: {
181
+ parse: options.data.allowedMentions?.parse,
182
+ roles: options.data.allowedMentions?.roles,
183
+ users: options.data.allowedMentions?.users,
184
+ replied_user: options.data.allowedMentions?.repliedUser,
185
+ },
186
+ flags: options.data.flags,
187
+ components: options.data.components !== undefined
188
+ ? (0, utils_1.rawMessageComponent)(options.data.components)
189
+ : undefined,
190
+ attachments: options.data.attachments,
191
+ },
192
+ },
193
+ });
194
+ }
195
+ break;
196
+ case utils_1.InteractionCallbackType.ApplicationCommandAutocompleteResult:
197
+ {
198
+ await this.client.rest.request("POST", rest_1.Endpoints.interactionCallback(this.id, this.token), {
199
+ json: {
200
+ type: options.type,
201
+ data: {
202
+ choices: options.data.choices?.map((choice) => ({
203
+ name: choice.name,
204
+ name_localizations: choice.nameLocalizations,
205
+ value: choice.value,
206
+ })),
207
+ },
208
+ },
209
+ });
210
+ }
211
+ break;
212
+ case utils_1.InteractionCallbackType.Modal:
213
+ {
214
+ await this.client.rest.request("POST", rest_1.Endpoints.interactionCallback(this.id, this.token), {
215
+ json: {
216
+ type: options.type,
217
+ data: {
218
+ custom_id: options.data.customId,
219
+ components: options.data.components !== undefined
220
+ ? options.data.components.map((component) => ({
221
+ type: component.type,
222
+ components: component.components.map((c) => {
223
+ if (c.type === utils_1.ComponentTypes.TextInput) {
224
+ return {
225
+ type: c.type,
226
+ custom_id: c.customId,
227
+ style: c.style,
228
+ label: c.label,
229
+ min_length: c.minLength,
230
+ max_length: c.maxLength,
231
+ required: c.required,
232
+ value: c.value,
233
+ placeholder: c.placeholder,
234
+ };
235
+ }
236
+ }),
237
+ }))
238
+ : undefined,
239
+ title: options.data.title,
240
+ },
241
+ },
242
+ });
243
+ }
244
+ break;
245
+ }
246
+ }
247
+ /* https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response */
248
+ async getOriginalResponse(options) {
249
+ return new _1.Message(await this.client.rest.request("GET", rest_1.Endpoints.interactionOriginalMessage(this.id, this.token), {
250
+ query: {
251
+ thread_id: options?.threadId,
252
+ },
253
+ }), this.client);
254
+ }
255
+ /* https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */
256
+ async editOriginalResponse(options) {
257
+ return new _1.Message(await this.client.rest.request("PATCH", rest_1.Endpoints.interactionOriginalMessage(this.id, this.token), {
258
+ query: {
259
+ thread_id: options?.threadId,
260
+ },
261
+ json: {
262
+ content: options?.content,
263
+ embeds: options?.embeds,
264
+ allowed_mentions: {
265
+ parse: options?.allowedMentions?.parse,
266
+ roles: options?.allowedMentions?.roles,
267
+ users: options?.allowedMentions?.users,
268
+ replied_user: options?.allowedMentions?.repliedUser,
269
+ },
270
+ components: options?.components !== undefined
271
+ ? options.components !== null
272
+ ? (0, utils_1.rawMessageComponent)(options.components)
273
+ : null
274
+ : undefined,
275
+ attachments: options?.attachments,
276
+ flags: options?.flags,
277
+ },
278
+ files: options?.files,
279
+ }), this.client);
280
+ }
281
+ /* https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response */
282
+ async deleteOriginalResponse() {
283
+ this.client.rest.request("DELETE", rest_1.Endpoints.interactionOriginalMessage(this.id, this.token));
284
+ }
285
+ /* https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */
286
+ async createFollowupMessage(options) {
287
+ await this.client.rest.request("POST", rest_1.Endpoints.webhook(this.applicationId, this.token), {
288
+ json: {
289
+ content: options?.content,
290
+ tts: options?.tts,
291
+ embeds: options?.embeds,
292
+ allowed_mentions: {
293
+ parse: options?.allowedMentions?.parse,
294
+ roles: options?.allowedMentions?.roles,
295
+ users: options?.allowedMentions?.users,
296
+ replied_user: options?.allowedMentions?.repliedUser,
297
+ },
298
+ components: options?.components !== undefined
299
+ ? options.components !== null
300
+ ? (0, utils_1.rawMessageComponent)(options.components)
301
+ : null
302
+ : undefined,
303
+ attachments: options?.attachments,
304
+ flags: options?.flags,
305
+ thread_name: options?.threadName,
306
+ },
307
+ files: options?.files,
308
+ });
309
+ }
310
+ /* https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message */
311
+ async getFollowupMessage(messageId, options) {
312
+ return new _1.Message(await this.client.rest.request("GET", rest_1.Endpoints.webhookMessage(this.applicationId, this.token, messageId), {
313
+ query: {
314
+ thread_id: options?.threadId,
315
+ },
316
+ }), this.client);
317
+ }
318
+ /* https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */
319
+ async editFollowupMessage(messageId, options) {
320
+ return new _1.Message(await this.client.rest.request("POST", rest_1.Endpoints.webhookMessage(this.applicationId, this.token, messageId), {
321
+ query: {
322
+ thread_id: options?.threadId,
323
+ },
324
+ json: {
325
+ content: options?.content,
326
+ embeds: options?.embeds,
327
+ allowed_mentions: {
328
+ parse: options?.allowedMentions?.parse,
329
+ roles: options?.allowedMentions?.roles,
330
+ users: options?.allowedMentions?.users,
331
+ replied_user: options?.allowedMentions?.repliedUser,
332
+ },
333
+ components: options?.components !== undefined
334
+ ? options.components !== null
335
+ ? (0, utils_1.rawMessageComponent)(options.components)
336
+ : null
337
+ : undefined,
338
+ attachments: options?.attachments,
339
+ flags: options?.flags,
340
+ },
341
+ files: options?.files,
342
+ }), this.client);
343
+ }
344
+ /* https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message */
345
+ async deleteFollowupMessage(messageId) {
346
+ this.client.rest.request("DELETE", rest_1.Endpoints.webhookMessage(this.applicationId, this.token, messageId));
347
+ }
348
+ toJSON() {
349
+ return {
350
+ id: this.id,
351
+ applicationId: this.applicationId,
352
+ type: this.type,
353
+ data: this.data,
354
+ guildId: this.guildId,
355
+ channelId: this.channelId,
356
+ member: this.member,
357
+ user: this.user,
358
+ token: this.token,
359
+ version: this.version,
360
+ message: this.message,
361
+ appPermissions: this.appPermissions,
362
+ locale: this.locale,
363
+ guildLocale: this.guildLocale,
364
+ };
365
+ }
366
+ }
367
+ exports.Interaction = Interaction;
368
+ //# sourceMappingURL=Interaction.js.map