@buape/carbon 0.0.0-beta-20241008010229

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 (245) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -0
  3. package/dist/package.json +34 -0
  4. package/dist/src/abstracts/AnySelectMenu.d.ts +31 -0
  5. package/dist/src/abstracts/AnySelectMenu.d.ts.map +1 -0
  6. package/dist/src/abstracts/AnySelectMenu.js +19 -0
  7. package/dist/src/abstracts/AnySelectMenu.js.map +1 -0
  8. package/dist/src/abstracts/AnySelectMenuInteraction.d.ts +13 -0
  9. package/dist/src/abstracts/AnySelectMenuInteraction.d.ts.map +1 -0
  10. package/dist/src/abstracts/AnySelectMenuInteraction.js +21 -0
  11. package/dist/src/abstracts/AnySelectMenuInteraction.js.map +1 -0
  12. package/dist/src/abstracts/Base.d.ts +10 -0
  13. package/dist/src/abstracts/Base.d.ts.map +1 -0
  14. package/dist/src/abstracts/Base.js +11 -0
  15. package/dist/src/abstracts/Base.js.map +1 -0
  16. package/dist/src/abstracts/BaseChannel.d.ts +45 -0
  17. package/dist/src/abstracts/BaseChannel.d.ts.map +1 -0
  18. package/dist/src/abstracts/BaseChannel.js +68 -0
  19. package/dist/src/abstracts/BaseChannel.js.map +1 -0
  20. package/dist/src/abstracts/BaseCommand.d.ts +58 -0
  21. package/dist/src/abstracts/BaseCommand.d.ts.map +1 -0
  22. package/dist/src/abstracts/BaseCommand.js +72 -0
  23. package/dist/src/abstracts/BaseCommand.js.map +1 -0
  24. package/dist/src/abstracts/BaseComponent.d.ts +34 -0
  25. package/dist/src/abstracts/BaseComponent.d.ts.map +1 -0
  26. package/dist/src/abstracts/BaseComponent.js +30 -0
  27. package/dist/src/abstracts/BaseComponent.js.map +1 -0
  28. package/dist/src/abstracts/BaseComponentInteraction.d.ts +19 -0
  29. package/dist/src/abstracts/BaseComponentInteraction.d.ts.map +1 -0
  30. package/dist/src/abstracts/BaseComponentInteraction.js +42 -0
  31. package/dist/src/abstracts/BaseComponentInteraction.js.map +1 -0
  32. package/dist/src/abstracts/BaseGuildChannel.d.ts +70 -0
  33. package/dist/src/abstracts/BaseGuildChannel.d.ts.map +1 -0
  34. package/dist/src/abstracts/BaseGuildChannel.js +143 -0
  35. package/dist/src/abstracts/BaseGuildChannel.js.map +1 -0
  36. package/dist/src/abstracts/BaseGuildTextChannel.d.ts +46 -0
  37. package/dist/src/abstracts/BaseGuildTextChannel.d.ts.map +1 -0
  38. package/dist/src/abstracts/BaseGuildTextChannel.js +77 -0
  39. package/dist/src/abstracts/BaseGuildTextChannel.js.map +1 -0
  40. package/dist/src/abstracts/BaseInteraction.d.ts +92 -0
  41. package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -0
  42. package/dist/src/abstracts/BaseInteraction.js +152 -0
  43. package/dist/src/abstracts/BaseInteraction.js.map +1 -0
  44. package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts +43 -0
  45. package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts.map +1 -0
  46. package/dist/src/abstracts/GuildThreadOnlyChannel.js +69 -0
  47. package/dist/src/abstracts/GuildThreadOnlyChannel.js.map +1 -0
  48. package/dist/src/classes/Button.d.ts +49 -0
  49. package/dist/src/classes/Button.d.ts.map +1 -0
  50. package/dist/src/classes/Button.js +61 -0
  51. package/dist/src/classes/Button.js.map +1 -0
  52. package/dist/src/classes/ChannelSelectMenu.d.ts +15 -0
  53. package/dist/src/classes/ChannelSelectMenu.d.ts.map +1 -0
  54. package/dist/src/classes/ChannelSelectMenu.js +15 -0
  55. package/dist/src/classes/ChannelSelectMenu.js.map +1 -0
  56. package/dist/src/classes/Client.d.ts +180 -0
  57. package/dist/src/classes/Client.d.ts.map +1 -0
  58. package/dist/src/classes/Client.js +263 -0
  59. package/dist/src/classes/Client.js.map +1 -0
  60. package/dist/src/classes/Command.d.ts +33 -0
  61. package/dist/src/classes/Command.d.ts.map +1 -0
  62. package/dist/src/classes/Command.js +31 -0
  63. package/dist/src/classes/Command.js.map +1 -0
  64. package/dist/src/classes/CommandWithSubcommandGroups.d.ts +22 -0
  65. package/dist/src/classes/CommandWithSubcommandGroups.d.ts.map +1 -0
  66. package/dist/src/classes/CommandWithSubcommandGroups.js +31 -0
  67. package/dist/src/classes/CommandWithSubcommandGroups.js.map +1 -0
  68. package/dist/src/classes/CommandWithSubcommands.d.ts +19 -0
  69. package/dist/src/classes/CommandWithSubcommands.d.ts.map +1 -0
  70. package/dist/src/classes/CommandWithSubcommands.js +21 -0
  71. package/dist/src/classes/CommandWithSubcommands.js.map +1 -0
  72. package/dist/src/classes/Embed.d.ts +61 -0
  73. package/dist/src/classes/Embed.d.ts.map +1 -0
  74. package/dist/src/classes/Embed.js +75 -0
  75. package/dist/src/classes/Embed.js.map +1 -0
  76. package/dist/src/classes/MentionableSelectMenu.d.ts +13 -0
  77. package/dist/src/classes/MentionableSelectMenu.d.ts.map +1 -0
  78. package/dist/src/classes/MentionableSelectMenu.js +13 -0
  79. package/dist/src/classes/MentionableSelectMenu.js.map +1 -0
  80. package/dist/src/classes/Modal.d.ts +21 -0
  81. package/dist/src/classes/Modal.d.ts.map +1 -0
  82. package/dist/src/classes/Modal.js +14 -0
  83. package/dist/src/classes/Modal.js.map +1 -0
  84. package/dist/src/classes/RoleSelectMenu.d.ts +13 -0
  85. package/dist/src/classes/RoleSelectMenu.d.ts.map +1 -0
  86. package/dist/src/classes/RoleSelectMenu.js +13 -0
  87. package/dist/src/classes/RoleSelectMenu.js.map +1 -0
  88. package/dist/src/classes/Row.d.ts +25 -0
  89. package/dist/src/classes/Row.d.ts.map +1 -0
  90. package/dist/src/classes/Row.js +40 -0
  91. package/dist/src/classes/Row.js.map +1 -0
  92. package/dist/src/classes/StringSelectMenu.d.ts +13 -0
  93. package/dist/src/classes/StringSelectMenu.d.ts.map +1 -0
  94. package/dist/src/classes/StringSelectMenu.js +12 -0
  95. package/dist/src/classes/StringSelectMenu.js.map +1 -0
  96. package/dist/src/classes/TextInput.d.ts +40 -0
  97. package/dist/src/classes/TextInput.d.ts.map +1 -0
  98. package/dist/src/classes/TextInput.js +44 -0
  99. package/dist/src/classes/TextInput.js.map +1 -0
  100. package/dist/src/classes/UserSelectMenu.d.ts +13 -0
  101. package/dist/src/classes/UserSelectMenu.d.ts.map +1 -0
  102. package/dist/src/classes/UserSelectMenu.js +13 -0
  103. package/dist/src/classes/UserSelectMenu.js.map +1 -0
  104. package/dist/src/factories/channelFactory.d.ts +13 -0
  105. package/dist/src/factories/channelFactory.d.ts.map +1 -0
  106. package/dist/src/factories/channelFactory.js +39 -0
  107. package/dist/src/factories/channelFactory.js.map +1 -0
  108. package/dist/src/index.d.ts +55 -0
  109. package/dist/src/index.d.ts.map +1 -0
  110. package/dist/src/index.js +61 -0
  111. package/dist/src/index.js.map +1 -0
  112. package/dist/src/internals/AutocompleteInteraction.d.ts +33 -0
  113. package/dist/src/internals/AutocompleteInteraction.d.ts.map +1 -0
  114. package/dist/src/internals/AutocompleteInteraction.js +61 -0
  115. package/dist/src/internals/AutocompleteInteraction.js.map +1 -0
  116. package/dist/src/internals/ButtonInteraction.d.ts +9 -0
  117. package/dist/src/internals/ButtonInteraction.d.ts.map +1 -0
  118. package/dist/src/internals/ButtonInteraction.js +18 -0
  119. package/dist/src/internals/ButtonInteraction.js.map +1 -0
  120. package/dist/src/internals/ChannelSelectMenuInteraction.d.ts +8 -0
  121. package/dist/src/internals/ChannelSelectMenuInteraction.d.ts.map +1 -0
  122. package/dist/src/internals/ChannelSelectMenuInteraction.js +11 -0
  123. package/dist/src/internals/ChannelSelectMenuInteraction.js.map +1 -0
  124. package/dist/src/internals/CommandHandler.d.ts +12 -0
  125. package/dist/src/internals/CommandHandler.d.ts.map +1 -0
  126. package/dist/src/internals/CommandHandler.js +89 -0
  127. package/dist/src/internals/CommandHandler.js.map +1 -0
  128. package/dist/src/internals/CommandInteraction.d.ts +16 -0
  129. package/dist/src/internals/CommandInteraction.d.ts.map +1 -0
  130. package/dist/src/internals/CommandInteraction.js +23 -0
  131. package/dist/src/internals/CommandInteraction.js.map +1 -0
  132. package/dist/src/internals/ComponentHandler.d.ts +17 -0
  133. package/dist/src/internals/ComponentHandler.d.ts.map +1 -0
  134. package/dist/src/internals/ComponentHandler.js +75 -0
  135. package/dist/src/internals/ComponentHandler.js.map +1 -0
  136. package/dist/src/internals/FieldsHandler.d.ts +27 -0
  137. package/dist/src/internals/FieldsHandler.d.ts.map +1 -0
  138. package/dist/src/internals/FieldsHandler.js +37 -0
  139. package/dist/src/internals/FieldsHandler.js.map +1 -0
  140. package/dist/src/internals/MentionableSelectMenuInteraction.d.ts +9 -0
  141. package/dist/src/internals/MentionableSelectMenuInteraction.d.ts.map +1 -0
  142. package/dist/src/internals/MentionableSelectMenuInteraction.js +15 -0
  143. package/dist/src/internals/MentionableSelectMenuInteraction.js.map +1 -0
  144. package/dist/src/internals/ModalHandler.d.ts +17 -0
  145. package/dist/src/internals/ModalHandler.d.ts.map +1 -0
  146. package/dist/src/internals/ModalHandler.js +25 -0
  147. package/dist/src/internals/ModalHandler.js.map +1 -0
  148. package/dist/src/internals/ModalInteraction.d.ts +22 -0
  149. package/dist/src/internals/ModalInteraction.d.ts.map +1 -0
  150. package/dist/src/internals/ModalInteraction.js +42 -0
  151. package/dist/src/internals/ModalInteraction.js.map +1 -0
  152. package/dist/src/internals/OptionsHandler.d.ts +82 -0
  153. package/dist/src/internals/OptionsHandler.d.ts.map +1 -0
  154. package/dist/src/internals/OptionsHandler.js +127 -0
  155. package/dist/src/internals/OptionsHandler.js.map +1 -0
  156. package/dist/src/internals/RoleSelectMenuInteraction.d.ts +9 -0
  157. package/dist/src/internals/RoleSelectMenuInteraction.d.ts.map +1 -0
  158. package/dist/src/internals/RoleSelectMenuInteraction.js +14 -0
  159. package/dist/src/internals/RoleSelectMenuInteraction.js.map +1 -0
  160. package/dist/src/internals/StringSelectMenuInteraction.d.ts +9 -0
  161. package/dist/src/internals/StringSelectMenuInteraction.d.ts.map +1 -0
  162. package/dist/src/internals/StringSelectMenuInteraction.js +14 -0
  163. package/dist/src/internals/StringSelectMenuInteraction.js.map +1 -0
  164. package/dist/src/internals/UserSelectMenuInteraction.d.ts +9 -0
  165. package/dist/src/internals/UserSelectMenuInteraction.d.ts.map +1 -0
  166. package/dist/src/internals/UserSelectMenuInteraction.js +14 -0
  167. package/dist/src/internals/UserSelectMenuInteraction.js.map +1 -0
  168. package/dist/src/plugins/linked-roles/LinkedRoles.d.ts +49 -0
  169. package/dist/src/plugins/linked-roles/LinkedRoles.d.ts.map +1 -0
  170. package/dist/src/plugins/linked-roles/LinkedRoles.js +164 -0
  171. package/dist/src/plugins/linked-roles/LinkedRoles.js.map +1 -0
  172. package/dist/src/plugins/linked-roles/index.d.ts +3 -0
  173. package/dist/src/plugins/linked-roles/index.d.ts.map +1 -0
  174. package/dist/src/plugins/linked-roles/index.js +3 -0
  175. package/dist/src/plugins/linked-roles/index.js.map +1 -0
  176. package/dist/src/plugins/linked-roles/types.d.ts +88 -0
  177. package/dist/src/plugins/linked-roles/types.d.ts.map +1 -0
  178. package/dist/src/plugins/linked-roles/types.js +39 -0
  179. package/dist/src/plugins/linked-roles/types.js.map +1 -0
  180. package/dist/src/structures/DmChannel.d.ts +19 -0
  181. package/dist/src/structures/DmChannel.d.ts.map +1 -0
  182. package/dist/src/structures/DmChannel.js +25 -0
  183. package/dist/src/structures/DmChannel.js.map +1 -0
  184. package/dist/src/structures/GroupDmChannel.d.ts +65 -0
  185. package/dist/src/structures/GroupDmChannel.d.ts.map +1 -0
  186. package/dist/src/structures/GroupDmChannel.js +116 -0
  187. package/dist/src/structures/GroupDmChannel.js.map +1 -0
  188. package/dist/src/structures/Guild.d.ts +77 -0
  189. package/dist/src/structures/Guild.d.ts.map +1 -0
  190. package/dist/src/structures/Guild.js +156 -0
  191. package/dist/src/structures/Guild.js.map +1 -0
  192. package/dist/src/structures/GuildAnnouncementChannel.d.ts +11 -0
  193. package/dist/src/structures/GuildAnnouncementChannel.d.ts.map +1 -0
  194. package/dist/src/structures/GuildAnnouncementChannel.js +15 -0
  195. package/dist/src/structures/GuildAnnouncementChannel.js.map +1 -0
  196. package/dist/src/structures/GuildCategoryChannel.d.ts +13 -0
  197. package/dist/src/structures/GuildCategoryChannel.d.ts.map +1 -0
  198. package/dist/src/structures/GuildCategoryChannel.js +13 -0
  199. package/dist/src/structures/GuildCategoryChannel.js.map +1 -0
  200. package/dist/src/structures/GuildForumChannel.d.ts +14 -0
  201. package/dist/src/structures/GuildForumChannel.d.ts.map +1 -0
  202. package/dist/src/structures/GuildForumChannel.js +15 -0
  203. package/dist/src/structures/GuildForumChannel.js.map +1 -0
  204. package/dist/src/structures/GuildMediaChannel.d.ts +9 -0
  205. package/dist/src/structures/GuildMediaChannel.d.ts.map +1 -0
  206. package/dist/src/structures/GuildMediaChannel.js +7 -0
  207. package/dist/src/structures/GuildMediaChannel.js.map +1 -0
  208. package/dist/src/structures/GuildMember.d.ts +111 -0
  209. package/dist/src/structures/GuildMember.d.ts.map +1 -0
  210. package/dist/src/structures/GuildMember.js +224 -0
  211. package/dist/src/structures/GuildMember.js.map +1 -0
  212. package/dist/src/structures/GuildStageOrVoiceChannel.d.ts +31 -0
  213. package/dist/src/structures/GuildStageOrVoiceChannel.d.ts.map +1 -0
  214. package/dist/src/structures/GuildStageOrVoiceChannel.js +43 -0
  215. package/dist/src/structures/GuildStageOrVoiceChannel.js.map +1 -0
  216. package/dist/src/structures/GuildTextChannel.d.ts +15 -0
  217. package/dist/src/structures/GuildTextChannel.d.ts.map +1 -0
  218. package/dist/src/structures/GuildTextChannel.js +20 -0
  219. package/dist/src/structures/GuildTextChannel.js.map +1 -0
  220. package/dist/src/structures/GuildThreadChannel.d.ts +90 -0
  221. package/dist/src/structures/GuildThreadChannel.d.ts.map +1 -0
  222. package/dist/src/structures/GuildThreadChannel.js +165 -0
  223. package/dist/src/structures/GuildThreadChannel.js.map +1 -0
  224. package/dist/src/structures/Message.d.ts +153 -0
  225. package/dist/src/structures/Message.d.ts.map +1 -0
  226. package/dist/src/structures/Message.js +296 -0
  227. package/dist/src/structures/Message.js.map +1 -0
  228. package/dist/src/structures/Role.d.ts +108 -0
  229. package/dist/src/structures/Role.d.ts.map +1 -0
  230. package/dist/src/structures/Role.js +220 -0
  231. package/dist/src/structures/Role.js.map +1 -0
  232. package/dist/src/structures/User.d.ts +82 -0
  233. package/dist/src/structures/User.d.ts.map +1 -0
  234. package/dist/src/structures/User.js +166 -0
  235. package/dist/src/structures/User.js.map +1 -0
  236. package/dist/src/types.d.ts +37 -0
  237. package/dist/src/types.d.ts.map +1 -0
  238. package/dist/src/types.js +2 -0
  239. package/dist/src/types.js.map +1 -0
  240. package/dist/src/utils.d.ts +22 -0
  241. package/dist/src/utils.d.ts.map +1 -0
  242. package/dist/src/utils.js +79 -0
  243. package/dist/src/utils.js.map +1 -0
  244. package/dist/tsconfig.tsbuildinfo +1 -0
  245. package/package.json +34 -0
@@ -0,0 +1,263 @@
1
+ import { RequestClient } from "@buape/carbon-request";
2
+ import { InteractionResponseType, InteractionType, Routes } from "discord-api-types/v10";
3
+ import { AutoRouter, StatusError, json } from "itty-router";
4
+ import { channelFactory } from "../factories/channelFactory.js";
5
+ import { CommandHandler } from "../internals/CommandHandler.js";
6
+ import { ComponentHandler } from "../internals/ComponentHandler.js";
7
+ import { ModalHandler } from "../internals/ModalHandler.js";
8
+ import { Guild } from "../structures/Guild.js";
9
+ import { GuildMember } from "../structures/GuildMember.js";
10
+ import { Role } from "../structures/Role.js";
11
+ import { User } from "../structures/User.js";
12
+ import { concatUint8Arrays, subtleCrypto, valueToUint8Array } from "../utils.js";
13
+ /**
14
+ * The mode that the client is running in.
15
+ * Different platforms have different requirements for how processes are handled.
16
+ */
17
+ export var ClientMode;
18
+ (function (ClientMode) {
19
+ ClientMode["NodeJS"] = "node";
20
+ ClientMode["CloudflareWorkers"] = "cloudflare";
21
+ ClientMode["Bun"] = "bun";
22
+ ClientMode["Vercel"] = "vercel";
23
+ ClientMode["Web"] = "web";
24
+ })(ClientMode || (ClientMode = {}));
25
+ /**
26
+ * The main client used to interact with Discord
27
+ */
28
+ export class Client {
29
+ /**
30
+ * The options used to initialize the client
31
+ */
32
+ options;
33
+ /**
34
+ * The commands that the client has registered
35
+ */
36
+ commands;
37
+ /**
38
+ * The router used to handle requests
39
+ */
40
+ router;
41
+ /**
42
+ * The rest client used to interact with the Discord API
43
+ */
44
+ rest;
45
+ /**
46
+ * The handler for the component interactions sent from Discord
47
+ * @internal
48
+ */
49
+ componentHandler;
50
+ /**
51
+ * The handler for the modal interactions sent from Discord
52
+ * @internal
53
+ */
54
+ commandHandler;
55
+ /**
56
+ * The handler for the modal interactions sent from Discord
57
+ * @internal
58
+ */
59
+ modalHandler;
60
+ /**
61
+ * Creates a new client
62
+ * @param options The options used to initialize the client
63
+ * @param commands The commands that the client has registered
64
+ */
65
+ constructor(options, commands) {
66
+ if (!options.clientId)
67
+ throw new Error("Missing client ID");
68
+ if (!options.publicKey)
69
+ throw new Error("Missing public key");
70
+ if (!options.token)
71
+ throw new Error("Missing token");
72
+ this.options = options;
73
+ this.commands = commands;
74
+ this.commandHandler = new CommandHandler(this);
75
+ this.componentHandler = new ComponentHandler(this);
76
+ this.modalHandler = new ModalHandler(this);
77
+ const routerData = this.options.mode === ClientMode.Bun && this.options.port
78
+ ? { port: this.options.port }
79
+ : {};
80
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
81
+ this.router = AutoRouter(routerData);
82
+ this.rest = new RequestClient(options.token, options.requestOptions);
83
+ if (this.options.autoRegister) {
84
+ for (const command of commands) {
85
+ for (const component of command.components)
86
+ this.componentHandler.registerComponent(new component());
87
+ for (const modal of command.modals)
88
+ this.modalHandler.registerModal(new modal());
89
+ }
90
+ }
91
+ if (this.options.autoDeploy)
92
+ this.deployCommands();
93
+ this.setupRoutes();
94
+ }
95
+ /**
96
+ * Deploy the commands registered to Discord.
97
+ * This is automatically called when running in NodeJS mode.
98
+ */
99
+ async deployCommands() {
100
+ try {
101
+ const commands = this.commands
102
+ .filter((x) => x.name !== "*")
103
+ .map((command) => {
104
+ return command.serialize();
105
+ });
106
+ await this.rest.put(Routes.applicationCommands(this.options.clientId), {
107
+ body: commands
108
+ });
109
+ console.log(`Deployed ${commands.length} commands to Discord`);
110
+ }
111
+ catch (err) {
112
+ console.error("Failed to deploy commands");
113
+ console.error(err);
114
+ }
115
+ }
116
+ /**
117
+ * Setup the routes for the client
118
+ */
119
+ setupRoutes() {
120
+ this.router.get("/", () => {
121
+ if (this.options.redirectUrl)
122
+ return Response.redirect(this.options.redirectUrl, 302);
123
+ throw new StatusError(404);
124
+ });
125
+ this.router.post(this.options.interactionRoute || "/interaction", async (req, ctx) => {
126
+ return await this.handle(req, ctx);
127
+ });
128
+ }
129
+ /**
130
+ * If you want use a custom handler for HTTP requests instead of Carbon's router, you can use this method.
131
+ * @param req The request to handle
132
+ * @param ctx Cloudflare Workers only. The execution context of the request, provided in the fetch handler from CF.
133
+ * @returns A response to send back to the client.
134
+ */
135
+ async handle(req, ctx) {
136
+ const isValid = await this.validateInteraction(req);
137
+ if (!isValid) {
138
+ return new Response("Invalid request signature", { status: 401 });
139
+ }
140
+ const rawInteraction = (await req.json());
141
+ if (rawInteraction.type === InteractionType.Ping) {
142
+ return json({
143
+ type: InteractionResponseType.Pong
144
+ });
145
+ }
146
+ if (rawInteraction.type === InteractionType.ApplicationCommand) {
147
+ if (ctx?.waitUntil) {
148
+ ctx.waitUntil((async () => {
149
+ await this.commandHandler.handleCommandInteraction(rawInteraction);
150
+ })());
151
+ }
152
+ else {
153
+ await this.commandHandler.handleCommandInteraction(rawInteraction);
154
+ }
155
+ }
156
+ if (rawInteraction.type === InteractionType.ApplicationCommandAutocomplete) {
157
+ if (ctx?.waitUntil) {
158
+ ctx.waitUntil((async () => {
159
+ await this.commandHandler.handleAutocompleteInteraction(rawInteraction);
160
+ })());
161
+ }
162
+ else {
163
+ await this.commandHandler.handleAutocompleteInteraction(rawInteraction);
164
+ }
165
+ }
166
+ if (rawInteraction.type === InteractionType.MessageComponent) {
167
+ if (ctx?.waitUntil) {
168
+ ctx.waitUntil((async () => {
169
+ await this.componentHandler.handleInteraction(rawInteraction);
170
+ })());
171
+ }
172
+ else {
173
+ await this.componentHandler.handleInteraction(rawInteraction);
174
+ }
175
+ }
176
+ if (rawInteraction.type === InteractionType.ModalSubmit) {
177
+ if (ctx?.waitUntil) {
178
+ ctx.waitUntil((async () => {
179
+ await this.modalHandler.handleInteraction(rawInteraction);
180
+ })());
181
+ }
182
+ else {
183
+ await this.modalHandler.handleInteraction(rawInteraction);
184
+ }
185
+ }
186
+ return new Response(null, { status: 202 });
187
+ }
188
+ /**
189
+ * Validate the interaction request
190
+ * @param req The request to validate
191
+ */
192
+ async validateInteraction(req) {
193
+ const body = await req.clone().text();
194
+ const signature = req.headers.get("X-Signature-Ed25519");
195
+ const timestamp = req.headers.get("X-Signature-Timestamp");
196
+ if (!timestamp || !signature || req.method !== "POST" || !body) {
197
+ throw new StatusError(401);
198
+ }
199
+ try {
200
+ const timestampData = valueToUint8Array(timestamp);
201
+ const bodyData = valueToUint8Array(body);
202
+ const message = concatUint8Arrays(timestampData, bodyData);
203
+ const isValid = await subtleCrypto.verify({
204
+ name: "ed25519"
205
+ }, await subtleCrypto.importKey("raw", valueToUint8Array(this.options.publicKey, "hex"), {
206
+ name: "ed25519",
207
+ namedCurve: "ed25519"
208
+ }, false, ["verify"]), valueToUint8Array(signature, "hex"), message);
209
+ return isValid;
210
+ }
211
+ catch (_) {
212
+ return false;
213
+ }
214
+ }
215
+ // ======================== Begin Fetchers ================================================
216
+ /**
217
+ * Fetch a user from the Discord API
218
+ * @param id The ID of the user to fetch
219
+ * @returns The user data
220
+ */
221
+ async fetchUser(id) {
222
+ const user = (await this.rest.get(Routes.user(id)));
223
+ return new User(this, user);
224
+ }
225
+ /**
226
+ * Fetch a guild from the Discord API
227
+ * @param id The ID of the guild to fetch
228
+ * @returns The guild data
229
+ */
230
+ async fetchGuild(id) {
231
+ const guild = (await this.rest.get(Routes.guild(id)));
232
+ return new Guild(this, guild);
233
+ }
234
+ /**
235
+ * Fetch a channel from the Discord API
236
+ * @param id The ID of the channel to fetch
237
+ * @returns The channel data
238
+ */
239
+ async fetchChannel(id) {
240
+ const channel = (await this.rest.get(Routes.channel(id)));
241
+ return channelFactory(this, channel);
242
+ }
243
+ /**
244
+ * Fetch a role from the Discord API
245
+ * @param id The ID of the role to fetch
246
+ * @returns The role data
247
+ */
248
+ async fetchRole(guildId, id) {
249
+ const role = (await this.rest.get(Routes.guildRole(guildId, id)));
250
+ return new Role(this, role);
251
+ }
252
+ /**
253
+ * Fetch a member from the Discord API
254
+ * @param guildId The ID of the guild the member is in
255
+ * @param id The ID of the member to fetch
256
+ * @returns The member data
257
+ */
258
+ async fetchMember(guildId, id) {
259
+ const member = (await this.rest.get(Routes.guildMember(guildId, id)));
260
+ return new GuildMember(this, member, new Guild(this, guildId));
261
+ }
262
+ }
263
+ //# sourceMappingURL=Client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../src/classes/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA6B,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAON,uBAAuB,EACvB,eAAe,EACf,MAAM,EACN,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAuB,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAA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A;IACrC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,OAAe,EAAE,EAAU;QAC1C,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAY,CAAA;QAC5E,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC5B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,EAAU;QAC5C,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAClC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,CAC/B,CAAmB,CAAA;QACpB,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,KAAK,CAAO,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;IACrE,CAAC;CAGD"}
@@ -0,0 +1,33 @@
1
+ import { type APIApplicationCommandBasicOption, ApplicationCommandType } from "discord-api-types/v10";
2
+ import { type AutocompleteInteraction, BaseCommand, type CommandInteraction } from "../index.js";
3
+ export type CommandOptions = APIApplicationCommandBasicOption[];
4
+ /**
5
+ * Represents a standard command that the user creates
6
+ */
7
+ export declare abstract class Command extends BaseCommand {
8
+ /**
9
+ * The options that the user passes along with the command in Discord
10
+ */
11
+ options?: CommandOptions;
12
+ /**
13
+ * The type of command, either ChatInput, User, or Message. User and Message are context menu commands.
14
+ * @default ChatInput
15
+ */
16
+ type: ApplicationCommandType;
17
+ /**
18
+ * The function that is called when the command is ran
19
+ * @param interaction The interaction that triggered the command
20
+ */
21
+ abstract run(interaction: CommandInteraction): Promise<void>;
22
+ /**
23
+ * The function that is called when the command's autocomplete is triggered.
24
+ * @param interaction The interaction that triggered the autocomplete
25
+ * @remarks You are expected to `override` this function to provide your own autocomplete functionality.
26
+ */
27
+ autocomplete(interaction: AutocompleteInteraction): Promise<void>;
28
+ /**
29
+ * @internal
30
+ */
31
+ serializeOptions(): CommandOptions | undefined;
32
+ }
33
+ //# sourceMappingURL=Command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../../src/classes/Command.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gCAAgC,EACrC,sBAAsB,EACtB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACN,KAAK,uBAAuB,EAC5B,WAAW,EACX,KAAK,kBAAkB,EACvB,MAAM,aAAa,CAAA;AAEpB,MAAM,MAAM,cAAc,GAAG,gCAAgC,EAAE,CAAA;AAE/D;;GAEG;AACH,8BAAsB,OAAQ,SAAQ,WAAW;IAChD;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IAExB;;;OAGG;IACH,IAAI,EAAE,sBAAsB,CAAmC;IAE/D;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAE5D;;;;OAIG;IACU,YAAY,CACxB,WAAW,EAAE,uBAAuB,GAClC,OAAO,CAAC,IAAI,CAAC;IAMhB;;OAEG;IACH,gBAAgB;CAGhB"}
@@ -0,0 +1,31 @@
1
+ import { ApplicationCommandType } from "discord-api-types/v10";
2
+ import { BaseCommand } from "../index.js";
3
+ /**
4
+ * Represents a standard command that the user creates
5
+ */
6
+ export class Command extends BaseCommand {
7
+ /**
8
+ * The options that the user passes along with the command in Discord
9
+ */
10
+ options;
11
+ /**
12
+ * The type of command, either ChatInput, User, or Message. User and Message are context menu commands.
13
+ * @default ChatInput
14
+ */
15
+ type = ApplicationCommandType.ChatInput;
16
+ /**
17
+ * The function that is called when the command's autocomplete is triggered.
18
+ * @param interaction The interaction that triggered the autocomplete
19
+ * @remarks You are expected to `override` this function to provide your own autocomplete functionality.
20
+ */
21
+ async autocomplete(interaction) {
22
+ throw new Error(`The ${interaction.rawData.data.name} command does not support autocomplete`);
23
+ }
24
+ /**
25
+ * @internal
26
+ */
27
+ serializeOptions() {
28
+ return this.options;
29
+ }
30
+ }
31
+ //# sourceMappingURL=Command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Command.js","sourceRoot":"","sources":["../../../src/classes/Command.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,sBAAsB,EACtB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAEN,WAAW,EAEX,MAAM,aAAa,CAAA;AAIpB;;GAEG;AACH,MAAM,OAAgB,OAAQ,SAAQ,WAAW;IAChD;;OAEG;IACH,OAAO,CAAiB;IAExB;;;OAGG;IACH,IAAI,GAA2B,sBAAsB,CAAC,SAAS,CAAA;IAQ/D;;;;OAIG;IACI,KAAK,CAAC,YAAY,CACxB,WAAoC;QAEpC,MAAM,IAAI,KAAK,CACd,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,wCAAwC,CAC5E,CAAA;IACF,CAAC;IAED;;OAEG;IACH,gBAAgB;QACf,OAAO,IAAI,CAAC,OAAO,CAAA;IACpB,CAAC;CACD"}
@@ -0,0 +1,22 @@
1
+ import { type APIApplicationCommandSubcommandGroupOption, type APIApplicationCommandSubcommandOption } from "discord-api-types/v10";
2
+ import type { Command } from "./Command.js";
3
+ import { CommandWithSubcommands } from "./CommandWithSubcommands.js";
4
+ /**
5
+ * Represents a subcommand group command that the user creates.
6
+ * You make this instead of a {@link Command} class when you want to have subcommand groups in your options.
7
+ */
8
+ export declare abstract class CommandWithSubcommandGroups extends CommandWithSubcommands {
9
+ /**
10
+ * The subcommands that the user can use
11
+ */
12
+ subcommands: Command[];
13
+ /**
14
+ * The subcommands that the user can use
15
+ */
16
+ abstract subcommandGroups: CommandWithSubcommands[];
17
+ /**
18
+ * @internal
19
+ */
20
+ serializeOptions(): (APIApplicationCommandSubcommandGroupOption | APIApplicationCommandSubcommandOption)[];
21
+ }
22
+ //# sourceMappingURL=CommandWithSubcommandGroups.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandWithSubcommandGroups.d.ts","sourceRoot":"","sources":["../../../src/classes/CommandWithSubcommandGroups.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,0CAA0C,EAC/C,KAAK,qCAAqC,EAE1C,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEpE;;;GAGG;AACH,8BAAsB,2BAA4B,SAAQ,sBAAsB;IAC/E;;OAEG;IACH,WAAW,EAAE,OAAO,EAAE,CAAK;IAE3B;;OAEG;IACH,QAAQ,CAAC,gBAAgB,EAAE,sBAAsB,EAAE,CAAA;IAEnD;;OAEG;IACH,gBAAgB;CAmBhB"}
@@ -0,0 +1,31 @@
1
+ import { ApplicationCommandOptionType } from "discord-api-types/v10";
2
+ import { CommandWithSubcommands } from "./CommandWithSubcommands.js";
3
+ /**
4
+ * Represents a subcommand group command that the user creates.
5
+ * You make this instead of a {@link Command} class when you want to have subcommand groups in your options.
6
+ */
7
+ export class CommandWithSubcommandGroups extends CommandWithSubcommands {
8
+ /**
9
+ * The subcommands that the user can use
10
+ */
11
+ subcommands = [];
12
+ /**
13
+ * @internal
14
+ */
15
+ serializeOptions() {
16
+ const subcommands = this.subcommands.map((subcommand) => ({
17
+ name: subcommand.name,
18
+ description: subcommand.description,
19
+ type: ApplicationCommandOptionType.Subcommand,
20
+ options: subcommand.serializeOptions()
21
+ }));
22
+ const subcommandGroups = this.subcommandGroups.map((subcommandGroup) => ({
23
+ name: subcommandGroup.name,
24
+ description: subcommandGroup.description,
25
+ type: ApplicationCommandOptionType.SubcommandGroup,
26
+ options: subcommandGroup.serializeOptions()
27
+ }));
28
+ return [...subcommands, ...subcommandGroups];
29
+ }
30
+ }
31
+ //# sourceMappingURL=CommandWithSubcommandGroups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandWithSubcommandGroups.js","sourceRoot":"","sources":["../../../src/classes/CommandWithSubcommandGroups.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,4BAA4B,EAC5B,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEpE;;;GAGG;AACH,MAAM,OAAgB,2BAA4B,SAAQ,sBAAsB;IAC/E;;OAEG;IACH,WAAW,GAAc,EAAE,CAAA;IAO3B;;OAEG;IACH,gBAAgB;QACf,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACzD,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,WAAW,EAAE,UAAU,CAAC,WAAW;YACnC,IAAI,EAAE,4BAA4B,CAAC,UAAU;YAC7C,OAAO,EACN,UAAU,CAAC,gBAAgB,EAAwC;SACpE,CAAC,CAA4C,CAAA;QAE9C,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;YACxE,IAAI,EAAE,eAAe,CAAC,IAAI;YAC1B,WAAW,EAAE,eAAe,CAAC,WAAW;YACxC,IAAI,EAAE,4BAA4B,CAAC,eAAe;YAClD,OAAO,EACN,eAAe,CAAC,gBAAgB,EAA6C;SAC9E,CAAC,CAAiD,CAAA;QAEnD,OAAO,CAAC,GAAG,WAAW,EAAE,GAAG,gBAAgB,CAAC,CAAA;IAC7C,CAAC;CACD"}
@@ -0,0 +1,19 @@
1
+ import { ApplicationCommandType, type RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10";
2
+ import { BaseCommand } from "../abstracts/BaseCommand.js";
3
+ import type { Command } from "./Command.js";
4
+ /**
5
+ * Represents a subcommand command that the user creates.
6
+ * You make this instead of a {@link Command} class when you want to have subcommands in your options.
7
+ */
8
+ export declare abstract class CommandWithSubcommands extends BaseCommand {
9
+ type: ApplicationCommandType;
10
+ /**
11
+ * The subcommands that the user can use
12
+ */
13
+ abstract subcommands: Command[];
14
+ /**
15
+ * @internal
16
+ */
17
+ serializeOptions(): RESTPostAPIApplicationCommandsJSONBody["options"];
18
+ }
19
+ //# sourceMappingURL=CommandWithSubcommands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandWithSubcommands.d.ts","sourceRoot":"","sources":["../../../src/classes/CommandWithSubcommands.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,sBAAsB,EACtB,KAAK,sCAAsC,EAC3C,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C;;;GAGG;AACH,8BAAsB,sBAAuB,SAAQ,WAAW;IAC/D,IAAI,yBAAmC;IAEvC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,OAAO,EAAE,CAAA;IAE/B;;OAEG;IACH,gBAAgB,IAAI,sCAAsC,CAAC,SAAS,CAAC;CASrE"}
@@ -0,0 +1,21 @@
1
+ import { ApplicationCommandOptionType, ApplicationCommandType } from "discord-api-types/v10";
2
+ import { BaseCommand } from "../abstracts/BaseCommand.js";
3
+ /**
4
+ * Represents a subcommand command that the user creates.
5
+ * You make this instead of a {@link Command} class when you want to have subcommands in your options.
6
+ */
7
+ export class CommandWithSubcommands extends BaseCommand {
8
+ type = ApplicationCommandType.ChatInput;
9
+ /**
10
+ * @internal
11
+ */
12
+ serializeOptions() {
13
+ return this.subcommands.map((subcommand) => ({
14
+ name: subcommand.name,
15
+ description: subcommand.description,
16
+ type: ApplicationCommandOptionType.Subcommand,
17
+ options: subcommand.serializeOptions()
18
+ }));
19
+ }
20
+ }
21
+ //# sourceMappingURL=CommandWithSubcommands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandWithSubcommands.js","sourceRoot":"","sources":["../../../src/classes/CommandWithSubcommands.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,4BAA4B,EAC5B,sBAAsB,EAEtB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAGzD;;;GAGG;AACH,MAAM,OAAgB,sBAAuB,SAAQ,WAAW;IAC/D,IAAI,GAAG,sBAAsB,CAAC,SAAS,CAAA;IAOvC;;OAEG;IACH,gBAAgB;QACf,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YAC5C,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,WAAW,EAAE,UAAU,CAAC,WAAW;YACnC,IAAI,EAAE,4BAA4B,CAAC,UAAU;YAC7C,OAAO,EACN,UAAU,CAAC,gBAAgB,EAAwC;SACpE,CAAC,CAA4C,CAAA;IAC/C,CAAC;CACD"}
@@ -0,0 +1,61 @@
1
+ import type { APIEmbed } from "discord-api-types/v10";
2
+ /**
3
+ * Represents an embed in a message.
4
+ */
5
+ export declare class Embed {
6
+ /**
7
+ * The title of the embed
8
+ */
9
+ title?: string;
10
+ /**
11
+ * The description of the embed
12
+ */
13
+ description?: string;
14
+ /**
15
+ * The URL of the embed
16
+ */
17
+ url?: string;
18
+ /**
19
+ * The timestamp of the embed
20
+ */
21
+ timestamp?: string;
22
+ /**
23
+ * The color of the embed
24
+ */
25
+ color?: number;
26
+ /**
27
+ * The footer of the embed
28
+ */
29
+ footer?: {
30
+ text: string;
31
+ icon_url?: string;
32
+ };
33
+ /**
34
+ * The image URL of the embed
35
+ */
36
+ image?: string;
37
+ /**
38
+ * The thumbnail URL of the embed
39
+ */
40
+ thumbnail?: string;
41
+ author?: {
42
+ name: string;
43
+ url?: string;
44
+ icon_url?: string;
45
+ };
46
+ fields?: {
47
+ name: string;
48
+ value: string;
49
+ inline?: boolean;
50
+ }[];
51
+ /**
52
+ * Create an embed from an API embed
53
+ */
54
+ constructor(embed?: APIEmbed);
55
+ /**
56
+ * Serialize the embed to an API embed
57
+ * @internal
58
+ */
59
+ serialize(): APIEmbed;
60
+ }
61
+ //# sourceMappingURL=Embed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Embed.d.ts","sourceRoot":"","sources":["../../../src/classes/Embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD;;GAEG;AACH,qBAAa,KAAK;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,MAAM,CAAC,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;KACjB,CAAA;IAED;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,MAAM,CAAC,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;KACjB,CAAA;IAED,MAAM,CAAC,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,OAAO,CAAA;KAChB,EAAE,CAAA;IAEH;;OAEG;gBACS,KAAK,CAAC,EAAE,QAAQ;IAe5B;;;OAGG;IACH,SAAS,IAAI,QAAQ;CAcrB"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Represents an embed in a message.
3
+ */
4
+ export class Embed {
5
+ /**
6
+ * The title of the embed
7
+ */
8
+ title;
9
+ /**
10
+ * The description of the embed
11
+ */
12
+ description;
13
+ /**
14
+ * The URL of the embed
15
+ */
16
+ url;
17
+ /**
18
+ * The timestamp of the embed
19
+ */
20
+ timestamp;
21
+ /**
22
+ * The color of the embed
23
+ */
24
+ color;
25
+ /**
26
+ * The footer of the embed
27
+ */
28
+ footer;
29
+ /**
30
+ * The image URL of the embed
31
+ */
32
+ image;
33
+ /**
34
+ * The thumbnail URL of the embed
35
+ */
36
+ thumbnail;
37
+ author;
38
+ fields;
39
+ /**
40
+ * Create an embed from an API embed
41
+ */
42
+ constructor(embed) {
43
+ if (embed) {
44
+ this.title = embed.title;
45
+ this.description = embed.description;
46
+ this.url = embed.url;
47
+ this.timestamp = embed.timestamp;
48
+ this.color = embed.color;
49
+ this.footer = embed.footer;
50
+ this.image = embed.image?.url;
51
+ this.thumbnail = embed.thumbnail?.url;
52
+ this.author = embed.author;
53
+ this.fields = embed.fields;
54
+ }
55
+ }
56
+ /**
57
+ * Serialize the embed to an API embed
58
+ * @internal
59
+ */
60
+ serialize() {
61
+ return {
62
+ title: this.title,
63
+ description: this.description,
64
+ url: this.url,
65
+ timestamp: this.timestamp,
66
+ color: this.color,
67
+ footer: this.footer,
68
+ image: this.image ? { url: this.image } : undefined,
69
+ thumbnail: this.thumbnail ? { url: this.thumbnail } : undefined,
70
+ author: this.author,
71
+ fields: this.fields
72
+ };
73
+ }
74
+ }
75
+ //# sourceMappingURL=Embed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Embed.js","sourceRoot":"","sources":["../../../src/classes/Embed.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,KAAK;IACjB;;OAEG;IACH,KAAK,CAAS;IAEd;;OAEG;IACH,WAAW,CAAS;IAEpB;;OAEG;IACH,GAAG,CAAS;IAEZ;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,KAAK,CAAS;IAEd;;OAEG;IACH,MAAM,CAGL;IAED;;OAEG;IACH,KAAK,CAAS;IAEd;;OAEG;IACH,S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B,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CAAA;IACF,CAAC;CACD"}
@@ -0,0 +1,13 @@
1
+ import { type APIMentionableSelectComponent, ComponentType } from "discord-api-types/v10";
2
+ import { AnySelectMenu } from "../abstracts/AnySelectMenu.js";
3
+ import type { MentionableSelectMenuInteraction } from "../internals/MentionableSelectMenuInteraction.js";
4
+ export declare abstract class MentionableSelectMenu extends AnySelectMenu {
5
+ type: ComponentType.MentionableSelect;
6
+ defaultValues?: APIMentionableSelectComponent["default_values"];
7
+ abstract run(interaction: MentionableSelectMenuInteraction): Promise<void>;
8
+ serializeOptions(): {
9
+ type: ComponentType.MentionableSelect;
10
+ default_values: import("discord-api-types/v10").APISelectMenuDefaultValue<import("discord-api-types/v10").SelectMenuDefaultValueType.Role | import("discord-api-types/v10").SelectMenuDefaultValueType.User>[] | undefined;
11
+ };
12
+ }
13
+ //# sourceMappingURL=MentionableSelectMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MentionableSelectMenu.d.ts","sourceRoot":"","sources":["../../../src/classes/MentionableSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,6BAA6B,EAClC,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,kDAAkD,CAAA;AAExG,8BAAsB,qBAAsB,SAAQ,aAAa;IAChE,IAAI,EAAE,aAAa,CAAC,iBAAiB,CAAkC;IACvE,aAAa,CAAC,EAAE,6BAA6B,CAAC,gBAAgB,CAAC,CAAA;IAC/D,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,gCAAgC,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1E,gBAAgB;;;;CAMhB"}
@@ -0,0 +1,13 @@
1
+ import { ComponentType } from "discord-api-types/v10";
2
+ import { AnySelectMenu } from "../abstracts/AnySelectMenu.js";
3
+ export class MentionableSelectMenu extends AnySelectMenu {
4
+ type = ComponentType.MentionableSelect;
5
+ defaultValues;
6
+ serializeOptions() {
7
+ return {
8
+ type: this.type,
9
+ default_values: this.defaultValues
10
+ };
11
+ }
12
+ }
13
+ //# sourceMappingURL=MentionableSelectMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MentionableSelectMenu.js","sourceRoot":"","sources":["../../../src/classes/MentionableSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAG7D,MAAM,OAAgB,qBAAsB,SAAQ,aAAa;IAChE,IAAI,GAAoC,aAAa,CAAC,iBAAiB,CAAA;IACvE,aAAa,CAAkD;IAG/D,gBAAgB;QACf,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,cAAc,EAAE,IAAI,CAAC,aAAa;SAClC,CAAA;IACF,CAAC;CACD"}