├── .DS_Store ├── .gitignore ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── conflict ├── .swcrc ├── Conflict.js ├── README.md ├── bot.js ├── build │ └── index.js ├── cli │ ├── environment.js │ └── index.js ├── commandManager.js ├── commands.js ├── components.js ├── components │ ├── .swcrc │ ├── dist │ │ ├── ActionRow.js │ │ ├── Attachment.js │ │ ├── Button.js │ │ ├── Embed.js │ │ ├── EmbedSlideshow.js │ │ ├── Modal.js │ │ ├── SelectMenu.js │ │ ├── SelectOption.js │ │ ├── ServerlessButton.js │ │ ├── StatelessButton.js │ │ └── TextInput.js │ └── src │ │ ├── ActionRow.js │ │ ├── Attachment.js │ │ ├── Button.js │ │ ├── Embed.js │ │ ├── EmbedSlideshow.js │ │ ├── Modal.js │ │ ├── SelectMenu.js │ │ ├── SelectOption.js │ │ ├── ServerlessButton.js │ │ ├── StatelessButton.js │ │ └── TextInput.js ├── devserver │ └── index.js ├── ep.js ├── events.js ├── exports.js ├── handler │ ├── gateway.js │ ├── handler.js │ └── webhook.js ├── hooks.js ├── loader │ ├── initializer.js │ └── loader.js ├── logger.js ├── package-lock.json ├── package.json ├── plugins │ └── global-ratelimit.js ├── renderer │ ├── setState.js │ ├── templateRenderer.js │ └── view.js ├── replit.js ├── state.js ├── utils.js ├── vercel-kit │ ├── .vc-config.json │ ├── config.json │ ├── dispatch.js │ ├── index.html │ ├── package.json │ └── serve.js ├── vercel.js └── yarn.lock └── create-conflict-app ├── bot ├── commands │ ├── demo.js │ ├── help.js │ ├── slides.js │ └── welcome.js ├── events │ ├── interval.js │ └── message.js └── views │ └── welcome.js ├── conflict.config.js ├── package-lock.json ├── package.json ├── vercel.json └── yarn.lock /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conflictjs/conflict/e794e7f7f6da6690af8e1d62b2762f068492ef59/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .conflict 3 | token -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "workbench.colorCustomizations": { 3 | "activityBar.background": "#17207D", 4 | "titleBar.activeBackground": "#202DAF", 5 | "titleBar.activeForeground": "#F9FAFE" 6 | } 7 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |

3 | Conflict logo, in a rounded font with a blue and red background 4 |

5 | 6 | # Conflict 7 | https://conflict.js.org 8 | The JavaScript UI framework for Discord bots 9 | 10 | [![ 11 | Discord badge 12 | ]( 13 | https://img.shields.io/discord/921962253262155876?color=%235865f2&label=%20&logo=Discord&logoColor=white 14 | )]( 15 | https://discord.gg/jCgArsS7ub 16 | ) 17 | [![ 18 | GitHub badge 19 | ]( 20 | https://img.shields.io/github/last-commit/yodalightsabr/conflict?color=%23222&label=%20%20%20&logo=GitHub&logoColor=white 21 | )]( 22 | https://github.com/yodalightsabr/conflict 23 | ) 24 | -------- 25 | > ### ⚠️ This project is under development and will likely not run as expected. Please do not use in a production environment. 26 | -------- 27 | Get started by running `npx create-conflict-app` 28 | -------- 29 | 30 | 31 | ## What is Conflict? 32 | Conflict aims to be the best JavaScript framework for making Discord bots. Most frameworks are composed of classes and based on events and functions. Conflict is different. Conflict sets up a directory structure to handle every challenging aspect of making a Discord bot, including command registration, command handling, UI structuring, events, storage, state, and even sharding. Under the hood, it's just Discord.js with superpowers. 33 | 34 | ## How can I contribute? 35 | It's great you want to contribute! Since I probably have a lot of progress locally and it is still very much under development, you should join the [Discord server](https://discord.gg/KuAHEnbj5v). 36 | Or, if you find a typo in the READMEs or documentation, please open a PR, because that happens too often. 🤪 37 | Additionally, you can drop a ⭐ **star** on this repo to show your support. If you have any feature suggestions, please open an issue or join the Discord server. 38 | 39 | ## Current development state & details 40 | 41 | `create-conflict-app` is a testing place for the Conflict bot, currently running in the Discord server. Whatever the bot is doing is from the code in here. 42 | 43 | `create-conflict-app/bot` is where the code for the bot is stored. It is in a subdirectory so that all files can be transpiled for JSX, therefore allowing for a more organic file structure. 44 | 45 | `create-conflict-app/.conflict` is similar to `.next` with Next.js. It holds the output and all temporary files for conflict. 46 | 47 | `conflict` is the folder for all of Conflict's exports and utilities. Other than `bot.js` and `ep.js`, most files will be mapped to the `@conflict/beta/` export. 48 | 49 | `conflict/ep.js` is the entry point, which will are mapped to the command `conflict start` and `conflict dev` in the NPM package. 50 | -------------------------------------------------------------------------------- /conflict/.swcrc: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/swcrc", 3 | "jsc": { 4 | "transform": { 5 | "react": { 6 | "pragma": "global.__ConflictViewParser", 7 | "pragmaFrag": "DomFrag", 8 | "throwIfNamespace": true, 9 | "runtime": "classic" 10 | } 11 | }, 12 | "parser": { 13 | "syntax": "ecmascript", 14 | "jsx": true 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /conflict/Conflict.js: -------------------------------------------------------------------------------- 1 | export const useState = (defaultValue) => { 2 | let value = defaultValue; 3 | let message, view; 4 | function setValue (newValue) { 5 | value = newValue; 6 | } 7 | function callback (sentMessage, viewInstance) { 8 | message = sentMessage; 9 | view = viewInstance; 10 | } 11 | return [value, setValue, callback]; 12 | }; 13 | 14 | const Conflict = { 15 | useState 16 | }; 17 | 18 | export default Conflict; -------------------------------------------------------------------------------- /conflict/README.md: -------------------------------------------------------------------------------- 1 | # Conflict 2 | Conflict is currently in beta and is not recommended for production use. If you'd like to help develop, please join the [Discord server](https://discord.gg/Bxtf45CCX7). 3 | 4 | To get started, run `npx create-conflict-app`. 5 | 6 | [conflict.js.org](https://conflict.js.org) 7 | 8 | -------------------------------------------------------------------------------- /conflict/bot.js: -------------------------------------------------------------------------------- 1 | import Discord, { 2 | Client, 3 | Intents, 4 | Message, 5 | MessageEmbed, 6 | TextChannel, 7 | DMChannel, 8 | NewsChannel, 9 | ThreadChannel 10 | } from 'discord.js' 11 | import { dirname } from "esm-dirname" 12 | import path from 'path' 13 | import fs from 'fs' 14 | import stump from './logger.js' 15 | import events, { _setClient, onInteractionCreate, onDebug, onReady, onHotReload, onStartThinking } from './events.js' 16 | import Command, { InteractionResponse } from './commands.js' 17 | import View from './renderer/view.js' 18 | import State, { managers } from './state.js' 19 | import { REST } from '@discordjs/rest' 20 | // const { REST } = djsrest; 21 | import typesv9 from 'discord-api-types/v9' 22 | const { Routes } = typesv9; 23 | import { getFile, cleanLines } from './utils.js' 24 | import CommandManager from './commandManager.js' 25 | 26 | global.__ConflictFilePrefix = process.platform === 'win32' ? 'file://' : ''; 27 | 28 | let thinking = false; 29 | const finishThinking = () => { 30 | return new Promise(resolve => { 31 | let id = setInterval(() => { 32 | if (!thinking) { 33 | clearInterval(id); 34 | resolve(); 35 | } 36 | }, 100); 37 | }) 38 | } 39 | 40 | global.__ConflictViewParser = View.createElement; 41 | 42 | if (!global.__ConflictENV) global.__ConflictENV = {}; 43 | 44 | (async () => { 45 | 46 | TextChannel.prototype.view = function (view) { 47 | view.applyTo(this); 48 | }; 49 | DMChannel.prototype.view = function (view) { 50 | view.applyTo(this); 51 | }; 52 | NewsChannel.prototype.view = function (view) { 53 | view.applyTo(this); 54 | }; 55 | ThreadChannel.prototype.view = function (view) { 56 | view.applyTo(this); 57 | }; 58 | 59 | if (process.env.CONFLICT_VERBOSE) global.__ConflictENV.verbose = true; 60 | 61 | let config; 62 | try { 63 | config = await import(global.__ConflictFilePrefix + process.cwd() + '/conflict.config.js'); 64 | } catch (err) { 65 | return stump.error('Missing conflict.config.js'); 66 | } 67 | let { token, intents, errorHandler, plugins } = config.default; 68 | if (!token) token = process.env.TOKEN ?? process.env.token; 69 | if (!token) { 70 | try { 71 | token = fs.readFileSync(process.cwd() + '/token', 'utf8'); 72 | } catch (err) { 73 | stump.error(new Error('Missing token. No token found in config file, token file, or env variable.')); 74 | process.exit(1); 75 | } 76 | } 77 | 78 | token = token.trim(); 79 | 80 | if (!plugins) plugins = []; 81 | 82 | const rest = new REST({ version: '9' }).setToken(token.trim()); 83 | 84 | const client = new Client({ intents: (intents || ["GUILD_MESSAGES"]).map(intent => Intents.FLAGS[intent] ) }); 85 | 86 | _setClient(client); 87 | if (client.shard) { 88 | setInterval(() => { 89 | client.shard.fetchClientValues('user') 90 | .then(() => {}) 91 | .catch((error) => { 92 | if (error.message == 'Channel closed') { 93 | if (__ConflictENV.verbose) stump.verbose('Disconnected from parent, killing shard'); 94 | process.exit(1); 95 | } 96 | }); 97 | }, 3000); 98 | } 99 | 100 | if (process.env.CONFLICT_VERBOSE === "TRUE") onDebug(message => { 101 | stump.verbose(message); 102 | }); 103 | 104 | onReady(() => { 105 | stump.success('Logged in as ' + client.user.tag); 106 | initCommands(); 107 | }); 108 | 109 | client.login(token.trim()); 110 | 111 | async function initEvents() { 112 | let eventsPath = path.join(process.cwd(), '.conflict', 'build', 'events'); 113 | if (fs.existsSync(eventsPath)) { 114 | let files = fs.readdirSync(eventsPath); 115 | let filePaths = files.map(file => path.join(eventsPath, file)); 116 | for (const file of filePaths) { 117 | if (file.endsWith('.js') || file.endsWith('.cjs') || file.endsWith('.mjs')) await import(global.__ConflictFilePrefix + file); 118 | } 119 | } 120 | } 121 | 122 | let commands = {}; 123 | 124 | async function initCommands (hotReload) { 125 | if (hotReload) commands = {}; 126 | let previousGuilds = []; 127 | if (fs.existsSync(path.join(process.cwd(), '.conflict', '.guilds.commands.cache'))) { 128 | previousGuilds = fs.readFileSync(path.join(process.cwd(), '.conflict', '.guilds.commands.cache'), 'utf8').split('^').filter(guild => guild).map(guild => guild.trim()).filter(guild => guild); 129 | } 130 | 131 | let commandsPath = path.join(process.cwd(), '.conflict', 'build', 'commands'); 132 | if (fs.existsSync(commandsPath)) { 133 | let files = fs.readdirSync(commandsPath); 134 | let filePaths = files.map(file => path.join(commandsPath, file)); 135 | for (const file of filePaths) { 136 | if (file.endsWith('.js') || file.endsWith('.cjs') || file.endsWith('.mjs')) { 137 | let fileData = await import(global.__ConflictFilePrefix +file + '?r=' + Math.random().toString(36).substring(3)); 138 | 139 | if (fileData.default && fileData.default instanceof Command) { 140 | let command = fileData.default; 141 | commands[command.name] = command; 142 | } 143 | } 144 | } 145 | } 146 | 147 | let publicCommands = []; 148 | let guildCommands = {}; 149 | let guilds = []; 150 | 151 | for (const command in commands) { 152 | let commandData = commands[command]; 153 | if (commandData.testing && commandData.testing.guildId) { 154 | if (!guildCommands[commandData.testing.guildId]) guildCommands[commandData.testing.guildId] = []; 155 | guilds.push(commandData.testing.guildId); 156 | guildCommands[commandData.testing.guildId].push({ 157 | name: commandData.name, 158 | description: commandData.description, 159 | options: commandData.options, 160 | name_localizations: commandData.name_localizations, 161 | description_localizations: commandData.description_localizations, 162 | ...commandData.raw 163 | }); 164 | } else { 165 | publicCommands.push({ 166 | name: commandData.name, 167 | description: commandData.description, 168 | options: commandData.options, 169 | name_localizations: commandData.name_localizations, 170 | description_localizations: commandData.description_localizations, 171 | ...commandData.raw 172 | }); 173 | } 174 | } 175 | 176 | previousGuilds = previousGuilds.filter(guild => !guilds.includes(guild)); 177 | if (!hotReload) for (const guild of previousGuilds) { 178 | await rest.put(Routes.applicationGuildCommands(client.user.id, guild), { body: [] }); 179 | } 180 | 181 | fs.writeFileSync(path.join(process.cwd(), '.conflict', '.guilds.commands.cache'), guilds.join('^'), 'utf8'); 182 | 183 | const manager = new CommandManager(client, stump); 184 | await manager.setGlobalCommands(publicCommands); 185 | 186 | // await setGlobalCommands(token, client.user.id, publicCommands); 187 | // if (!hotReload) setTimeout(async () => { 188 | // await rest.put(Routes.applicationCommands(client.user.id), { body: publicCommands }); 189 | // }, 30000); 190 | 191 | if (!hotReload) for (const guild in guildCommands) { 192 | const commandsForGuild = guildCommands[guild]; 193 | await rest.put(Routes.applicationGuildCommands(client.user.id, guild), { body: commandsForGuild }) 194 | } 195 | 196 | managers.components.select('*').statelessLoad(); 197 | 198 | if (!hotReload) onInteractionCreate(async interaction => { 199 | if (thinking) { 200 | interaction.deferReply(); 201 | await finishThinking(); 202 | return interaction.editReply({ embeds: [ 203 | new MessageEmbed() 204 | .setColor('#ff4444') 205 | .setTitle('Build Finished') 206 | .setDescription('Run the command again to see the updated output.') 207 | .setTimestamp() 208 | ] }) 209 | } 210 | if (interaction.isCommand()) { 211 | if (commands[interaction.commandName]) { 212 | let command = commands[interaction.commandName]; 213 | try { 214 | let output = await command.execute(new InteractionResponse(interaction)); 215 | if (output instanceof Promise) output = await output; 216 | } catch (err) { 217 | 218 | stump.error(err); 219 | try { 220 | if (errorHandler) return errorHandler(err, interaction); 221 | const file = getFile(err); 222 | interaction.reply({ embeds: [ 223 | new MessageEmbed() 224 | .setColor('#ff4444') 225 | .setTitle('Command Error') 226 | .setDescription(file + ' ```' + cleanLines(err.stack, 4) + '```') 227 | .setTimestamp() 228 | ] }); 229 | } catch (nestedErr) { 230 | 231 | stump.error('Conflict had a hard time figuring this one out.', nestedErr); 232 | if (errorHandler) return errorHandler(err, interaction); 233 | try { 234 | interaction.channel.send( 235 | new MessageEmbed() 236 | .setColor('#ff4444') 237 | .setTitle('Command Error') 238 | .setDescription('```' + err.stack + '```') 239 | .setTimestamp() 240 | ); 241 | } catch (nestedNestedErr) { 242 | stump.error('Nested error handling failed.'); 243 | } 244 | } 245 | } 246 | } else { 247 | interaction.reply({ embeds: [ 248 | new MessageEmbed() 249 | .setColor('#ff4444') 250 | .setTitle('Command Error') 251 | .setDescription('```' + `Conflict Erorr: CommandNotFound` + '```') 252 | .setTimestamp() 253 | ] }); 254 | } 255 | } else { 256 | let { customId } = interaction; 257 | let code = managers.components.select('*').fetch(customId); 258 | if (code) { 259 | try { 260 | let output = await code(new InteractionResponse(interaction)); 261 | if (output instanceof Promise) output = await output; 262 | } catch (err) { 263 | stump.error(err); 264 | try { 265 | if (errorHandler) return errorHandler(err, interaction); 266 | const file = getFile(err); 267 | interaction.reply({ embeds: [ 268 | new MessageEmbed() 269 | .setColor('#ff4444') 270 | .setTitle('Command Error') 271 | .setDescription(file + ' ```' + cleanLines(err.stack, 4) + '```') 272 | .setTimestamp() 273 | ] }); 274 | } catch (nestedErr) { 275 | 276 | stump.error('Conflict had a hard time figuring this one out.', nestedErr); 277 | if (errorHandler) return errorHandler(err, interaction); 278 | try { 279 | interaction.reply( 280 | new MessageEmbed() 281 | .setColor('#ff4444') 282 | .setTitle('Command Error') 283 | .setDescription('```' + err.stack + '```') 284 | .setTimestamp() 285 | ); 286 | } catch (nestedNestedErr) { 287 | stump.error('Nested error handling failed.'); 288 | } 289 | } 290 | } 291 | } else { 292 | interaction.reply({ embeds: [ 293 | new MessageEmbed() 294 | .setColor('#ff4444') 295 | .setTitle('Button Expired') 296 | .setDescription('This button is expired.') 297 | .setTimestamp() 298 | ] }); 299 | } 300 | } 301 | }); 302 | if (!hotReload) client.ws.on('INTERACTION_CREATE', async (apiInteraction) => { 303 | if (apiInteraction.type !== 5) return; 304 | let interaction = new Discord.CommandInteraction(client, apiInteraction); 305 | interaction.customId = apiInteraction.data.custom_id; 306 | interaction.components = apiInteraction.data.components; 307 | interaction.isModalSubmit = true; 308 | let { customId } = interaction; 309 | let code = managers.components.select('*').fetch(customId); 310 | if (code) { 311 | try { 312 | let output = await code(new InteractionResponse(interaction)); 313 | if (output instanceof Promise) output = await output; 314 | } catch (err) { 315 | stump.error(err); 316 | try { 317 | if (errorHandler) return errorHandler(err, interaction); 318 | const file = getFile(err); 319 | interaction.reply({ embeds: [ 320 | new MessageEmbed() 321 | .setColor('#ff4444') 322 | .setTitle('Command Error') 323 | .setDescription(file + ' ```' + cleanLines(err.stack, 4) + '```') 324 | .setTimestamp() 325 | ] }); 326 | } catch (nestedErr) { 327 | 328 | stump.error('Conflict had a hard time figuring this one out.', nestedErr); 329 | if (errorHandler) return errorHandler(err, interaction); 330 | try { 331 | interaction.reply( 332 | new MessageEmbed() 333 | .setColor('#ff4444') 334 | .setTitle('Command Error') 335 | .setDescription('```' + err.stack + '```') 336 | .setTimestamp() 337 | ); 338 | } catch (nestedNestedErr) { 339 | stump.error('Nested error handling failed.'); 340 | } 341 | } 342 | } 343 | } else { 344 | interaction.reply({ embeds: [ 345 | new MessageEmbed() 346 | .setColor('#ff4444') 347 | .setTitle('Button Expired') 348 | .setDescription('This button is expired.') 349 | .setTimestamp() 350 | ] }); 351 | } 352 | }); 353 | } 354 | 355 | async function init() { 356 | await initEvents(); 357 | for (let plugin of plugins) { 358 | if (typeof plugin === "string") plugin = (await plugin()).default; 359 | if (plugin instanceof Promise) plugin = await plugin; 360 | if (plugin && plugin.default && plugin.default instanceof Function) 361 | plugin = plugin.default; 362 | plugin({ 363 | stump, 364 | logger: stump, 365 | events, 366 | View, 367 | State, 368 | config, 369 | client, 370 | }); 371 | } 372 | } 373 | 374 | init(); 375 | onHotReload(async () => { 376 | stump.info('Reloading...'); 377 | await initCommands(true); 378 | thinking = false; 379 | stump.success('Reloaded. Hot reload does not update command metadata with Discord, only the response code.'); 380 | }); 381 | onStartThinking(() => { 382 | thinking = true; 383 | }); 384 | })(); 385 | -------------------------------------------------------------------------------- /conflict/build/index.js: -------------------------------------------------------------------------------- 1 | import { exec, file } from "../utils.js"; 2 | 3 | export class CoreBuilder { 4 | constructor (sourceDirectory, outputDirectory, configFile) { 5 | this.sourceDirectory = sourceDirectory; 6 | this.outputDirectory = outputDirectory; 7 | this.configFile = configFile; 8 | } 9 | 10 | async build () { 11 | const output = await exec(`swc ${this.sourceDirectory} --out-dir ${this.outputDirectory} --config-file ${this.configFile}`, { cwd: process.cwd() }); 12 | 13 | const info = output.stdout; 14 | const errors = output.stderr; 15 | 16 | return { info, errors }; 17 | } 18 | 19 | async vercel () { 20 | const { finish } = await import("../vercel.js"); 21 | if (finish) await finish(); 22 | } 23 | } 24 | 25 | export async function build ({ vercel } = { vercel: false }) { 26 | const builder = new CoreBuilder("bot", ".conflict/build", file(__dirname, "..", ".swcrc")); 27 | 28 | const { info, errors } = await builder.build(); 29 | 30 | if (vercel) await builder.vercel(); 31 | 32 | return { info, errors }; 33 | } -------------------------------------------------------------------------------- /conflict/cli/environment.js: -------------------------------------------------------------------------------- 1 | import { attempt, detectFlag, file } from "../utils.js"; 2 | import fs from "fs"; 3 | 4 | class Environment { 5 | #argv; 6 | #env; 7 | #cwd; 8 | 9 | constructor (argv, env, cwd) { 10 | this.#argv = argv; 11 | this.#env = env; 12 | this.#cwd = cwd; 13 | } 14 | 15 | get verbose () { 16 | return detectFlag(this.#argv, 'verbose') || detectFlag(this.#argv, 'detailed'); 17 | } 18 | 19 | get cwd () { 20 | return this.#cwd; 21 | } 22 | 23 | get vercel () { 24 | this.#env.VERCEL_ENV || this.#argv.includes('-vercel') || this.#argv.includes('--vercel') || this.#argv.includes('-V') || this.#argv.includes('--V'); 25 | } 26 | 27 | get configFilePath () { 28 | return file(this.#cwd + '/conflict.config.js'); 29 | } 30 | 31 | get tokenFilePath () { 32 | return file(this.#cwd + '/.token'); 33 | } 34 | 35 | async getConfig () { 36 | return await import(this.configFilePath); 37 | } 38 | 39 | async getToken () { 40 | const config = await this.getConfig(); 41 | return config.default.token ?? this.#env.TOKEN ?? this.#env.token ?? attempt(fs.readFileSync, this.tokenFilePath, 'utf8')[0]?.trim?.() ?? null; 42 | } 43 | 44 | error () { 45 | return process.exit(1); 46 | } 47 | } 48 | 49 | export const environment = new Environment(process.argv, process.env); 50 | export default environment; -------------------------------------------------------------------------------- /conflict/cli/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import { ShardingManager } from 'discord.js' 4 | import { dirname } from "esm-dirname" 5 | const __dirname = dirname(import.meta); 6 | 7 | import stump from '../logger.js' 8 | import { file } from '../utils.js' 9 | import { build } from '../build/index.js' 10 | import environment from './environment.js' 11 | 12 | process.argv.shift(); 13 | process.argv.shift(); 14 | 15 | global.__ConflictENV = {}; 16 | global.__ConflictFilePrefix = process.platform === 'win32' ? 'file://' : ''; 17 | 18 | const { vercel } = environment; 19 | 20 | (async () => { 21 | if (process.argv[0] == 'help' || process.argv.includes('-h') || process.argv.includes('--h') || process.argv.includes('-help') || process.argv.includes('--help')) { 22 | stump.info('Please view documentation at https://conflict.js.org/docs'); 23 | 24 | } else if (process.argv[0] == 'dev') { 25 | if (global.__ConflictReplitRunDev) delete global.__ConflictReplitRunDev; 26 | 27 | await import(file(__dirname, 'devserver', 'index.js')); 28 | 29 | } else if (process.argv[0] == 'build') { 30 | stump.info('Starting build...'); 31 | 32 | const { info, errors } = await build({ vercel }); 33 | 34 | info 35 | .trim() 36 | .split("\n") 37 | .filter((line) => line) 38 | .forEach((line) => stump.info(line)); 39 | 40 | stump.success(`Build completed with ${ 41 | errors 42 | .trim() 43 | .split("\n") 44 | .filter((line) => line) 45 | .map((line) => (stump.warn(line), line)) 46 | .length 47 | } errors`); 48 | 49 | if (vercel) stump.info("Deploying to Vercel will disable events and only listen for commands"); 50 | 51 | } else { 52 | if (environment.verbose) stump.verbose('Running verbose'); 53 | let config; 54 | 55 | try { 56 | config = await environment.getConfig(); 57 | } catch (err) { 58 | stump.error('Missing conflict.config.js'); 59 | environment.error(); 60 | } 61 | 62 | const { token } = environment; 63 | if (!token) { 64 | stump.error(new Error('Missing token. No token found in config file, token file, or env variable.')); 65 | environment.error(); 66 | } 67 | 68 | const manager = new ShardingManager(file(__dirname, "..", 'bot.js'), { token }); 69 | 70 | manager.on('shardCreate', shard => stump.success(`Launched shard ${shard.id}`)); 71 | manager.spawn(); 72 | } 73 | })(); -------------------------------------------------------------------------------- /conflict/commandManager.js: -------------------------------------------------------------------------------- 1 | import { REST } from '@discordjs/rest'; 2 | import deepEqual from 'deep-equal'; 3 | import types from 'discord-api-types/v9'; 4 | const { Routes } = types; 5 | 6 | export default class CommandManager { 7 | constructor (client, stump) { 8 | this.client = client; 9 | this.rest = new REST({ version: '9' }).setToken(client.token); 10 | this.userId = client.user.id; 11 | 12 | this.stump = stump; 13 | } 14 | 15 | #commandTransform (command) { 16 | return [command.name, { 17 | name: command.name, 18 | description: command.description, 19 | options: command.options, 20 | nsfw: command.nsfw, 21 | dm_permission: command.dm_permission, 22 | type: command.type 23 | }]; 24 | } 25 | 26 | async setGlobalCommands (commands) { 27 | const apiCommands = await this.rest.get(Routes.applicationCommands(this.userId)); 28 | 29 | const apiCommandNames = apiCommands.map(command => command.name); 30 | const commandNames = commands.map(command => command.name); 31 | 32 | const diffAdd = commands.filter(command => !apiCommandNames.includes(command.name)); 33 | const diffRemove = apiCommands.filter(command => !commandNames.includes(command.name)); 34 | const diffModify = []; 35 | 36 | const existingLocal = Object.fromEntries(commands.filter(command => apiCommandNames.includes(command.name)).map(this.#commandTransform)); 37 | const existingApi = Object.fromEntries(commands.filter(command => commandNames.includes(command.name)).map(this.#commandTransform)); 38 | 39 | for (const command in existingLocal) { 40 | if (!deepEqual(existingLocal[command], existingApi[command])) { 41 | diffModify.push(command); 42 | } 43 | } 44 | 45 | this.stump.verbose(`Adding`, diffAdd.length, `global commands, removing`, diffRemove.length, `global commands, and modifying`, diffModify.length, `global commands`); 46 | 47 | for (const command of diffAdd) { 48 | await this.rest.post(Routes.applicationCommands(this.userId), { body: command }); 49 | this.stump.verbose(`Added global command ${command.name}`); 50 | } 51 | 52 | for (const command of diffRemove) { 53 | await this.rest.delete(Routes.applicationCommand(this.userId, command.id)); 54 | this.stump.verbose(`Removed global command ${command.name}`); 55 | } 56 | 57 | for (const command of diffModify) { 58 | await this.rest.patch(Routes.applicationCommand(this.userId, command.id), { body: command }); 59 | this.stump.verbose(`Modified global command ${command.name}`); 60 | } 61 | 62 | return { 63 | added: diffAdd, 64 | removed: diffRemove, 65 | modified: diffModify 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /conflict/commands.js: -------------------------------------------------------------------------------- 1 | import View, { Component } from './renderer/view.js' 2 | 3 | class ValueLocalizations { 4 | constructor (default_, localizations) { 5 | this.default = default_; 6 | this.localizations = localizations; 7 | } 8 | getDefault () { 9 | return this.default; 10 | } 11 | getLocalizations () { 12 | return this.localizations; 13 | } 14 | } 15 | 16 | export function localize (localizations) { 17 | return new ValueLocalizations(localizations); 18 | } 19 | 20 | export default class Command { 21 | constructor ({ name, description, options, execute, meta, testing, description_localizations = {}, name_localizations = {} }) { 22 | this.name = name; 23 | this.description = description; 24 | this.options = options; 25 | this.name_localizations = name_localizations; 26 | this.description_localizations = description_localizations; 27 | if (name instanceof ValueLocalizations) { 28 | this.name = name.getDefault(); 29 | this.name_localizations = name.getLocalizations(); 30 | } 31 | if (description instanceof ValueLocalizations) { 32 | this.description = description.getDefault(); 33 | this.description_localizations = description.getLocalizations(); 34 | } 35 | this.testing = testing; 36 | this.type = (testing && testing.guildId) ? 'guild' : 'global'; 37 | this.meta = meta; 38 | this.executeFn = execute; 39 | this.raw = {}; 40 | } 41 | execute (command, options, utils) { 42 | return this.executeFn(command, options, utils); 43 | } 44 | localize (languageData) { 45 | for (const language in languageData) { 46 | const text = languageData[language]; 47 | this.name_localizations[language] = text.name; 48 | this.description_localizations[language] = text.description; 49 | } 50 | return this; 51 | } 52 | static localize (data) { 53 | return localize(data); 54 | } 55 | } 56 | 57 | export class InteractionResponse { 58 | constructor (interaction, vercelConfig) { 59 | this.vercelConfig = vercelConfig; 60 | this.interaction = interaction; 61 | if (interaction.options) { 62 | let optionsArray = interaction.options.data; 63 | let options = {}; 64 | let rawOptions = {}; 65 | 66 | for (const option of optionsArray) { 67 | options[option.name] = option.value; 68 | rawOptions[option.name] = option; 69 | } 70 | 71 | this.options = options; 72 | this.rawOptions = rawOptions; 73 | 74 | } 75 | this.user = interaction.user; 76 | this.id = interaction.id; 77 | this.guild = interaction.guild; 78 | this.member = interaction.member; 79 | if (interaction.member) this.author = interaction.member.user; 80 | this.token = interaction.token; 81 | this.type = interaction.type; 82 | 83 | this.commandName = interaction.commandName; 84 | this.channel = interaction.channel; 85 | this.client = interaction.client; 86 | this.createdAt = interaction.createdAt; 87 | this.createdTimestamp = interaction.createdTimestamp; 88 | 89 | this.values = interaction.values; 90 | 91 | if (interaction.isModalSubmit && interaction.components) { 92 | let values = {}; 93 | interaction.components.map(component => component.components[0]).forEach(component => { 94 | values[component.custom_id] = component.value; 95 | }); 96 | this.values = values; 97 | } 98 | } 99 | 100 | deferReply () { 101 | return this.interaction.deferReply(); 102 | } 103 | editReply (...options) { 104 | return this.interaction.editReply(...options); 105 | } 106 | deleteReply () { 107 | return this.interaction.deleteReply(); 108 | } 109 | fetchReply () { 110 | return this.interaction.fetchReply(); 111 | } 112 | followUp (...options) { 113 | return this.interaction.followUp(...options); 114 | } 115 | inGuild () { 116 | return this.interaction.inGuild(); 117 | } 118 | isCommand () { 119 | return this.interaction.isCommand(); 120 | } 121 | isButton () { 122 | return this.interaction.isButton(); 123 | } 124 | isContextMenu () { 125 | return this.interaction.isContextMenu(); 126 | } 127 | isMessageComponent () { 128 | return this.interaction.isMessageComponent(); 129 | } 130 | isSelectMenu () { 131 | return this.interaction.isSelectMenu(); 132 | } 133 | reply (...options) { 134 | let ephemeral = false; 135 | if (options[1] && options[1].ephemeral) ephemeral = true; 136 | if (options[0] instanceof View && ephemeral) return this.privateView(...options); 137 | if (options[0] instanceof Component && ephemeral) return this.privateView(...options); 138 | if (options[0] instanceof View) return this.view(...options); 139 | if (options[0] instanceof Component) return this.view(...options); 140 | if (ephemeral && options[0] instanceof String) options[0] = { content: options[0], ephemeral: true }; 141 | if (ephemeral && options[0] && options[0].toString() == '[object Object]') options[0].ephemeral = true; 142 | return ( 143 | this.interaction.conflictThunked ? 144 | this.interaction.editReply(...options) : 145 | this.interaction.reply(...options) 146 | ); 147 | } 148 | respond (...options) { 149 | return this.reply(...options); 150 | } 151 | respondPrivate (...options) { 152 | return this.privateReply(...options); 153 | } 154 | replyPrivate (...options) { 155 | return this.privateReply(...options); 156 | } 157 | private (...options) { 158 | return this.privateReply(...options); 159 | } 160 | privateReply (...options) { 161 | if (typeof options[0] === 'string') options[0] = { content: options[0], ephemeral: true }; 162 | if (options[0] && options[0].toString() == '[object Object]') options[0].ephemeral = true; 163 | return this.reply(...options); 164 | } 165 | getView () { 166 | return View; 167 | } 168 | modal (view) { 169 | if (!(view instanceof View)) view = new View(view); 170 | if (!view.title) throw new Error('Missing title'); 171 | if (!view.custom_id) throw new Error('Missing callback'); 172 | if (!view.title) throw new Error('Missing title'); 173 | if (!view.components) throw new Error('Missing components'); 174 | return this.interaction.client.api.interactions(this.interaction.id, this.interaction.token).callback.post({ data: { 175 | type: 9, 176 | data: view 177 | }}); 178 | } 179 | async view (view, options) { 180 | if (!(view instanceof View)) view = new View(view); 181 | return await view.applyTo(this.interaction, options, true); 182 | } 183 | privateView (view, options) { 184 | view.ephemeral = true; 185 | this.view(view, options); 186 | } 187 | update (...options) { 188 | if (this.interaction.update) return this.interaction.update(options); 189 | return this.reply(...options); 190 | } 191 | } 192 | 193 | export { Command }; 194 | -------------------------------------------------------------------------------- /conflict/components.js: -------------------------------------------------------------------------------- 1 | import ActionRow from './components/dist/ActionRow.js'; 2 | import Button from './components/dist/Button.js'; 3 | import Embed from './components/dist/Embed.js'; 4 | import Attachment from './components/dist/Attachment.js'; 5 | import SelectMenu from './components/dist/SelectMenu.js'; 6 | import SelectOption from './components/dist/SelectOption.js'; 7 | export { default as TextInput } from './components/dist/TextInput.js'; 8 | export { default as StatelessButton } from './components/dist/StatelessButton.js'; 9 | export { default as Modal } from './components/dist/Modal.js'; 10 | export { default as EmbedSlideshow } from './components/dist/EmbedSlideshow.js'; 11 | 12 | export { ActionRow, Button, Embed, Attachment, SelectMenu, SelectOption } -------------------------------------------------------------------------------- /conflict/components/.swcrc: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/swcrc", 3 | "jsc": { 4 | "transform": { 5 | "react": { 6 | "pragma": "global.__ConflictViewParser", 7 | "pragmaFrag": "DomFrag", 8 | "throwIfNamespace": true, 9 | "runtime": "classic" 10 | } 11 | }, 12 | "parser": { 13 | "syntax": "ecmascript", 14 | "jsx": true 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /conflict/components/dist/ActionRow.js: -------------------------------------------------------------------------------- 1 | export default function ActionRow({ children }) { 2 | return global.__ConflictViewParser( 3 | "components_arr", 4 | null, 5 | global.__ConflictViewParser( 6 | "component", 7 | { 8 | type: 1, 9 | }, 10 | children 11 | ) 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /conflict/components/dist/Attachment.js: -------------------------------------------------------------------------------- 1 | export default function Attachment({ 2 | url, 3 | attachment, 4 | name, 5 | description, 6 | children, 7 | }) { 8 | if (url) { 9 | return global.__ConflictViewParser("files_arr", null, url); 10 | } else 11 | return global.__ConflictViewParser( 12 | "files_arr", 13 | null, 14 | global.__ConflictViewParser( 15 | "file", 16 | { 17 | description, 18 | name, 19 | attachment, 20 | }, 21 | children 22 | ) 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /conflict/components/dist/Button.js: -------------------------------------------------------------------------------- 1 | import { managers } from "../../state.js"; 2 | export default function Button({ 3 | style, 4 | onclick, 5 | customId, 6 | url, 7 | label, 8 | children, 9 | emoji, 10 | variant, 11 | onClick, 12 | }) { 13 | label = 14 | children && children.length 15 | ? global.__ConflictViewParser("label", null, children[0]) 16 | : global.__ConflictViewParser("label", null, label); 17 | if (!style) style = variant ? variant : url ? 5 : 1; 18 | 19 | if (!(style >= 1 && style <= 5)) { 20 | switch ((style + "").toLowerCase()) { 21 | case "primary": 22 | case "cta": 23 | case "purple": 24 | case "blurple": 25 | style = 1; 26 | break; 27 | 28 | case "green": 29 | case "success": 30 | case "good": 31 | style = 3; 32 | break; 33 | 34 | case "grey": 35 | case "gray": 36 | case "secondary": 37 | case "dark": 38 | style = 2; 39 | break; 40 | 41 | case "danger": 42 | case "fail": 43 | case "failed": 44 | case "error": 45 | case "red": 46 | case "bad": 47 | style = 4; 48 | break; 49 | 50 | case "url": 51 | case "link": 52 | case "popup": 53 | style = 5; 54 | break; 55 | 56 | default: 57 | style = 1; 58 | break; 59 | } 60 | } 61 | 62 | if (!customId && !url && !onclick && !onClick) 63 | throw new Error("Button must have either customId, url, or onclick props"); 64 | if (!onclick && onClick) onclick = onClick; 65 | let props = { 66 | style, 67 | type: 2, 68 | emoji, 69 | url: style === 5 ? url : undefined, 70 | custom_id: 71 | style !== 5 72 | ? customId 73 | ? customId 74 | : managers.components.select("*").store(onclick) 75 | : undefined, 76 | }; 77 | return global.__ConflictViewParser( 78 | "components_arr", 79 | null, 80 | global.__ConflictViewParser("component", props, label) 81 | ); 82 | } 83 | -------------------------------------------------------------------------------- /conflict/components/dist/Embed.js: -------------------------------------------------------------------------------- 1 | export default function Embed({ 2 | title, 3 | description, 4 | url, 5 | timestamp, 6 | color, 7 | footer, 8 | image, 9 | thumbnail, 10 | video, 11 | provider, 12 | author, 13 | fields, 14 | children, 15 | }) { 16 | return global.__ConflictViewParser( 17 | "embeds_arr", 18 | null, 19 | global.__ConflictViewParser( 20 | "embed", 21 | { 22 | title, 23 | description, 24 | url, 25 | timestamp, 26 | color, 27 | footer, 28 | image, 29 | thumbnail, 30 | video, 31 | provider, 32 | author, 33 | fields, 34 | }, 35 | children 36 | ) 37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /conflict/components/dist/EmbedSlideshow.js: -------------------------------------------------------------------------------- 1 | import ActionRow from "./ActionRow.js"; 2 | import Button from "./Button.js"; 3 | export default function EmbedSlideshow({ embeds }) { 4 | let activeEmbed = embeds[0]; 5 | return global.__ConflictViewParser( 6 | "message", 7 | null, 8 | activeEmbed, 9 | global.__ConflictViewParser( 10 | ActionRow, 11 | null, 12 | global.__ConflictViewParser( 13 | Button, 14 | { 15 | onclick: (event) => event.respond("OK"), 16 | }, 17 | "<<" 18 | ), 19 | global.__ConflictViewParser( 20 | Button, 21 | { 22 | onclick: (event) => event.respond("OK"), 23 | }, 24 | "←" 25 | ), 26 | global.__ConflictViewParser( 27 | Button, 28 | { 29 | onclick: (event) => event.respond("OK"), 30 | disabled: true, 31 | }, 32 | embeds.indexOf(activeEmbed) + 1 33 | ), 34 | global.__ConflictViewParser( 35 | Button, 36 | { 37 | onclick: (event) => event.respond("OK"), 38 | }, 39 | "→" 40 | ), 41 | global.__ConflictViewParser( 42 | Button, 43 | { 44 | onclick: (event) => event.respond("OK"), 45 | }, 46 | ">>" 47 | ) 48 | ) 49 | ); 50 | } 51 | -------------------------------------------------------------------------------- /conflict/components/dist/Modal.js: -------------------------------------------------------------------------------- 1 | import { managers } from "../../state.js"; 2 | export default function Modal({ children, onsubmit, onSubmit, title }) { 3 | if (!onsubmit && onSubmit) onsubmit = onSubmit; 4 | if (!onsubmit) throw new Error("Modal must have onsubmit prop"); 5 | return global.__ConflictViewParser( 6 | "modal", 7 | { 8 | title: title, 9 | custom_id: managers.components.select("*").store(onsubmit), 10 | }, 11 | children 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /conflict/components/dist/SelectMenu.js: -------------------------------------------------------------------------------- 1 | import { managers } from "../../state.js"; 2 | import SelectOption from "./SelectOption.js"; 3 | export default function SelectMenu({ 4 | onclick, 5 | onClick, 6 | customId, 7 | options, 8 | children, 9 | min, 10 | max, 11 | disabled = false, 12 | }) { 13 | if (!customId && !onclick && !onClick) 14 | throw new Error( 15 | "SelectMenu must have either customId, url, or onclick props" 16 | ); 17 | if (!onclick && onClick) onclick = onClick; 18 | 19 | if (children) { 20 | options = children; 21 | } else { 22 | options = options.map((option) => { 23 | return global.__ConflictViewParser( 24 | SelectOption, 25 | { 26 | value: option.value, 27 | description: option.description, 28 | emoji: option.emoji, 29 | default: option.default, 30 | }, 31 | option.label 32 | ); 33 | }); 34 | } 35 | 36 | let props = { 37 | type: 3, 38 | min_values: min, 39 | max_values: max, 40 | disabled: !!disabled, 41 | custom_id: customId 42 | ? customId 43 | : managers.components.select("*").store(onclick), 44 | }; 45 | return global.__ConflictViewParser( 46 | "components_arr", 47 | null, 48 | global.__ConflictViewParser("component", props, options) 49 | ); 50 | } 51 | -------------------------------------------------------------------------------- /conflict/components/dist/SelectOption.js: -------------------------------------------------------------------------------- 1 | export default function SelectOption({ 2 | label, 3 | value, 4 | description, 5 | emoji, 6 | children, 7 | ...props 8 | }) { 9 | if (children) { 10 | label = global.__ConflictViewParser("label", null, children[0]); 11 | } else { 12 | label = global.__ConflictViewParser("label", null, label); 13 | } 14 | 15 | return global.__ConflictViewParser( 16 | "options_arr", 17 | null, 18 | global.__ConflictViewParser( 19 | "option", 20 | { 21 | value, 22 | description, 23 | emoji, 24 | default: props.default, 25 | }, 26 | label 27 | ) 28 | ); 29 | } 30 | -------------------------------------------------------------------------------- /conflict/components/dist/ServerlessButton.js: -------------------------------------------------------------------------------- 1 | function _extends() { 2 | _extends = Object.assign || function(target) { 3 | for(var i = 1; i < arguments.length; i++){ 4 | var source = arguments[i]; 5 | for(var key in source){ 6 | if (Object.prototype.hasOwnProperty.call(source, key)) { 7 | target[key] = source[key]; 8 | } 9 | } 10 | } 11 | return target; 12 | }; 13 | return _extends.apply(this, arguments); 14 | } 15 | import { managers } from "../../state.js"; 16 | export default function ServerlessButton(param) { 17 | var style = param.style, onclick = param.onclick, label = param.label, children = param.children, emoji = param.emoji, variant = param.variant, name = param.name, params = param.params; 18 | label = children && children.length ? /*#__PURE__*/ global.__ConflictViewParser("label", null, children[0]) : /*#__PURE__*/ global.__ConflictViewParser("label", null, label); 19 | if (!style) style = variant ? variant : 1; 20 | if (!(style >= 1 && style <= 4)) { 21 | switch((style + "").toLowerCase()){ 22 | case "primary": 23 | case "cta": 24 | case "purple": 25 | case "blurple": 26 | style = 1; 27 | break; 28 | case "green": 29 | case "success": 30 | case "good": 31 | style = 3; 32 | break; 33 | case "grey": 34 | case "gray": 35 | case "secondary": 36 | case "dark": 37 | style = 2; 38 | break; 39 | case "danger": 40 | case "fail": 41 | case "failed": 42 | case "error": 43 | case "red": 44 | case "bad": 45 | style = 4; 46 | break; 47 | default: 48 | style = 1; 49 | break; 50 | } 51 | } 52 | if (!onclick && !onClick) throw new Error("Button must have onclick prop"); 53 | if (!onclick && onClick) onclick = onClick; 54 | var props = { 55 | style: style, 56 | emoji: emoji, 57 | type: 2, 58 | custom_id: "!" + JSON.stringify([ 59 | name, 60 | params 61 | ]) 62 | }; 63 | return /*#__PURE__*/ global.__ConflictViewParser("components_arr", null, /*#__PURE__*/ global.__ConflictViewParser("component", _extends({}, props), label)); 64 | } 65 | -------------------------------------------------------------------------------- /conflict/components/dist/StatelessButton.js: -------------------------------------------------------------------------------- 1 | import { managers } from "../../state.js"; 2 | export default function Button({ 3 | style, 4 | onclick, 5 | label, 6 | children, 7 | emoji, 8 | variant, 9 | onClick, 10 | }) { 11 | label = 12 | children && children.length 13 | ? global.__ConflictViewParser("label", null, children[0]) 14 | : global.__ConflictViewParser("label", null, label); 15 | if (!style) style = variant ? variant : 1; 16 | 17 | if (!(style >= 1 && style <= 4)) { 18 | switch ((style + "").toLowerCase()) { 19 | case "primary": 20 | case "cta": 21 | case "purple": 22 | case "blurple": 23 | style = 1; 24 | break; 25 | 26 | case "green": 27 | case "success": 28 | case "good": 29 | style = 3; 30 | break; 31 | 32 | case "grey": 33 | case "gray": 34 | case "secondary": 35 | case "dark": 36 | style = 2; 37 | break; 38 | 39 | case "danger": 40 | case "fail": 41 | case "failed": 42 | case "error": 43 | case "red": 44 | case "bad": 45 | style = 4; 46 | break; 47 | 48 | default: 49 | style = 1; 50 | break; 51 | } 52 | } 53 | 54 | if (!onclick && !onClick) throw new Error("Button must have onclick prop"); 55 | if (!onclick && onClick) onclick = onClick; 56 | let props = { 57 | style, 58 | emoji, 59 | type: 2, 60 | custom_id: managers.components.select("*").statelessStore(onclick), 61 | }; 62 | return global.__ConflictViewParser( 63 | "components_arr", 64 | null, 65 | global.__ConflictViewParser("component", props, label) 66 | ); 67 | } 68 | -------------------------------------------------------------------------------- /conflict/components/dist/TextInput.js: -------------------------------------------------------------------------------- 1 | import { managers } from "../../state.js"; 2 | export default function TextInput({ 3 | name, 4 | value, 5 | label, 6 | style, 7 | required = false, 8 | placeholder, 9 | children, 10 | min, 11 | max, 12 | variant, 13 | }) { 14 | if (!name) throw new Error("TextInput must have a name"); 15 | 16 | if (!value && children && children[0]) { 17 | value = children[0]; 18 | } 19 | 20 | if (!style) style = variant; 21 | 22 | if (!(style >= 1 && style <= 2)) { 23 | switch ((style + "").toLowerCase()) { 24 | case "short": 25 | case "single-line": 26 | case "line": 27 | case "input": 28 | style = 1; 29 | break; 30 | 31 | case "paragraph": 32 | case "multi-line": 33 | case "textarea": 34 | style = 2; 35 | break; 36 | 37 | default: 38 | style = 1; 39 | break; 40 | } 41 | } 42 | 43 | let props = { 44 | type: 4, 45 | min_length: min, 46 | max_length: max, 47 | placeholder, 48 | value, 49 | required, 50 | style, 51 | custom_id: name, 52 | }; 53 | return global.__ConflictViewParser( 54 | "components_arr", 55 | null, 56 | global.__ConflictViewParser( 57 | "component", 58 | props, 59 | global.__ConflictViewParser("label", null, label) 60 | ) 61 | ); 62 | } 63 | -------------------------------------------------------------------------------- /conflict/components/src/ActionRow.js: -------------------------------------------------------------------------------- 1 | export default function ActionRow ({ children }) { 2 | return ( 3 | {/** output an array of Discord message components */} 4 | 5 | {children} 6 | 7 | 8 | ) 9 | } -------------------------------------------------------------------------------- /conflict/components/src/Attachment.js: -------------------------------------------------------------------------------- 1 | export default function Attachment ({ url, attachment, name, description, children }) { 2 | if (url) { 3 | return ( 4 | {url} 5 | ); 6 | } else return ( 7 | 8 | 13 | {children} 14 | 15 | 16 | ); 17 | } -------------------------------------------------------------------------------- /conflict/components/src/Button.js: -------------------------------------------------------------------------------- 1 | import { managers } from '../../state.js'; 2 | 3 | export default function Button ({ style, onclick, customId, url, label, children, emoji, variant, onClick }) { 4 | label = (children && children.length) ? ( 5 | 6 | ) : ( 7 | 8 | ); 9 | if (!style) style = variant ? variant : (url ? 5 : 1); 10 | 11 | if (!(style >= 1 && style <= 5)) { 12 | switch ((style + '').toLowerCase()) { 13 | case 'primary': 14 | case 'cta': 15 | case 'purple': 16 | case 'blurple': 17 | style = 1; 18 | break; 19 | 20 | case 'green': 21 | case 'success': 22 | case 'good': 23 | style = 3; 24 | break; 25 | 26 | case 'grey': 27 | case 'gray': 28 | case 'secondary': 29 | case 'dark': 30 | style = 2; 31 | break; 32 | 33 | case 'danger': 34 | case 'fail': 35 | case 'failed': 36 | case 'error': 37 | case 'red': 38 | case 'bad': 39 | style = 4; 40 | break; 41 | 42 | case 'url': 43 | case 'link': 44 | case 'popup': 45 | style = 5; 46 | break; 47 | 48 | default: 49 | style = 1; 50 | break; 51 | } 52 | } 53 | 54 | if (!customId && !url && !onclick && !onClick) throw new Error('Button must have either customId, url, or onclick props'); 55 | if (!onclick && onClick) onclick = onClick; 56 | let props = { 57 | style, 58 | type: 2, 59 | emoji, 60 | url: style === 5 ? url : undefined, 61 | custom_id: style !== 5 ? ( 62 | customId ? customId : managers.components.select('*').store(onclick) 63 | ) : undefined 64 | }; 65 | return ( 66 | 67 | 68 | {label} 69 | 70 | 71 | ) 72 | } -------------------------------------------------------------------------------- /conflict/components/src/Embed.js: -------------------------------------------------------------------------------- 1 | export default function Embed ({ title, description, url, timestamp, color, footer, image, thumbnail, video, provider, author, fields, children }) { 2 | return ( 3 | 4 | 7 | {children} 8 | 9 | 10 | ) 11 | } -------------------------------------------------------------------------------- /conflict/components/src/EmbedSlideshow.js: -------------------------------------------------------------------------------- 1 | import ActionRow from './ActionRow.js'; 2 | import Button from './Button.js'; 3 | 4 | /** 5 | * Unfinished 6 | */ 7 | export default function EmbedSlideshow ({ embeds }) { 8 | let activeEmbed = embeds[0]; 9 | return ( 10 | 11 | {activeEmbed} 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ) 21 | } 22 | -------------------------------------------------------------------------------- /conflict/components/src/Modal.js: -------------------------------------------------------------------------------- 1 | import { managers } from '../../state.js'; 2 | 3 | export default function Modal ({ children, onsubmit, onSubmit, title }) { 4 | if (!onsubmit && onSubmit) onsubmit = onSubmit; 5 | if (!onsubmit) throw new Error('Modal must have onsubmit prop'); 6 | return ( 7 | 8 | {children} 9 | 10 | ) 11 | } -------------------------------------------------------------------------------- /conflict/components/src/SelectMenu.js: -------------------------------------------------------------------------------- 1 | import { managers } from '../../state.js'; 2 | import SelectOption from './SelectOption.js'; 3 | 4 | export default function SelectMenu ({ onclick, onClick, customId, options, children, min, max, disabled = false }) { 5 | if (!customId && !onclick && !onClick) throw new Error('SelectMenu must have either customId, url, or onclick props'); 6 | if (!onclick && onClick) onclick = onClick; 7 | if (children) { 8 | options = children; 9 | } else { 10 | options = options.map(option => { 11 | return ( 12 | {option.label} 13 | ) 14 | }); 15 | } 16 | let props = { 17 | type: 3, 18 | min_values: min, 19 | max_values: max, 20 | disabled: !!disabled, 21 | custom_id: ( 22 | customId ? customId : managers.components.select('*').store(onclick) 23 | ) 24 | }; 25 | return ( 26 | 27 | 28 | {options} 29 | 30 | 31 | ) 32 | } -------------------------------------------------------------------------------- /conflict/components/src/SelectOption.js: -------------------------------------------------------------------------------- 1 | export default function SelectOption ({ label, value, description, emoji, children, ...props }) { 2 | if (children) { 3 | label = ( 4 | 5 | ); 6 | } else { 7 | label = ( 8 | 9 | ); 10 | } 11 | return ( 12 | 13 | 21 | 22 | ) 23 | } -------------------------------------------------------------------------------- /conflict/components/src/ServerlessButton.js: -------------------------------------------------------------------------------- 1 | import { managers } from '../../state.js'; 2 | 3 | export default function ServerlessButton ({ style, onclick, label, children, emoji, variant, name, params }) { 4 | label = (children && children.length) ? ( 5 | 6 | ) : ( 7 | 8 | ); 9 | if (!style) style = variant ? variant : 1; 10 | 11 | if (!(style >= 1 && style <= 4)) { 12 | switch ((style + '').toLowerCase()) { 13 | case 'primary': 14 | case 'cta': 15 | case 'purple': 16 | case 'blurple': 17 | style = 1; 18 | break; 19 | 20 | case 'green': 21 | case 'success': 22 | case 'good': 23 | style = 3; 24 | break; 25 | 26 | case 'grey': 27 | case 'gray': 28 | case 'secondary': 29 | case 'dark': 30 | style = 2; 31 | break; 32 | 33 | case 'danger': 34 | case 'fail': 35 | case 'failed': 36 | case 'error': 37 | case 'red': 38 | case 'bad': 39 | style = 4; 40 | break; 41 | 42 | default: 43 | style = 1; 44 | break; 45 | } 46 | } 47 | 48 | if (!onclick && !onClick) throw new Error('Button must have onclick prop'); 49 | if (!onclick && onClick) onclick = onClick; 50 | let props = { 51 | style, 52 | emoji, 53 | type: 2, 54 | custom_id: '!' + JSON.stringify([name, params]) 55 | }; 56 | return ( 57 | 58 | 59 | {label} 60 | 61 | 62 | ) 63 | } -------------------------------------------------------------------------------- /conflict/components/src/StatelessButton.js: -------------------------------------------------------------------------------- 1 | import { managers } from '../../state.js'; 2 | 3 | export default function StatelessButton ({ style, onclick, label, children, emoji, variant, onClick }) { 4 | label = (children && children.length) ? ( 5 | 6 | ) : ( 7 | 8 | ); 9 | if (!style) style = variant ? variant : 1; 10 | 11 | if (!(style >= 1 && style <= 4)) { 12 | switch ((style + '').toLowerCase()) { 13 | case 'primary': 14 | case 'cta': 15 | case 'purple': 16 | case 'blurple': 17 | style = 1; 18 | break; 19 | 20 | case 'green': 21 | case 'success': 22 | case 'good': 23 | style = 3; 24 | break; 25 | 26 | case 'grey': 27 | case 'gray': 28 | case 'secondary': 29 | case 'dark': 30 | style = 2; 31 | break; 32 | 33 | case 'danger': 34 | case 'fail': 35 | case 'failed': 36 | case 'error': 37 | case 'red': 38 | case 'bad': 39 | style = 4; 40 | break; 41 | 42 | default: 43 | style = 1; 44 | break; 45 | } 46 | } 47 | 48 | if (!onclick && !onClick) throw new Error('Button must have onclick prop'); 49 | if (!onclick && onClick) onclick = onClick; 50 | let props = { 51 | style, 52 | emoji, 53 | type: 2, 54 | custom_id: managers.components.select('*').statelessStore(onclick) 55 | }; 56 | return ( 57 | 58 | 59 | {label} 60 | 61 | 62 | ) 63 | } -------------------------------------------------------------------------------- /conflict/components/src/TextInput.js: -------------------------------------------------------------------------------- 1 | import { managers } from '../../state.js'; 2 | 3 | export default function TextInput ({ name, value, label, style, required = false, placeholder, children, min, max, variant }) { 4 | if (!name) throw new Error('TextInput must have a name'); 5 | if (!value && children && children[0]) { 6 | value = children[0]; 7 | } 8 | if (!style) style = variant; 9 | if (!(style >= 1 && style <= 2)) { 10 | switch ((style + '').toLowerCase()) { 11 | case 'short': 12 | case 'single-line': 13 | case 'line': 14 | case 'input': 15 | style = 1; 16 | break; 17 | 18 | case 'paragraph': 19 | case 'multi-line': 20 | case 'textarea': 21 | style = 2; 22 | break; 23 | 24 | default: 25 | style = 1; 26 | break; 27 | } 28 | } 29 | let props = { 30 | type: 4, 31 | min_length: min, 32 | max_length: max, 33 | placeholder, 34 | value, 35 | required, 36 | style, 37 | custom_id: name 38 | }; 39 | return ( 40 | 41 | 42 | 43 | 44 | 45 | ) 46 | } -------------------------------------------------------------------------------- /conflict/devserver/index.js: -------------------------------------------------------------------------------- 1 | import { ShardingManager } from 'discord.js'; 2 | import { exec } from 'child_process'; 3 | import stump from '../logger.js'; 4 | import path from 'path'; 5 | import fs from 'fs'; 6 | import chokidar from 'chokidar'; 7 | import { dirname } from "esm-dirname"; 8 | import { detectFlag } from '../utils.js'; 9 | const __dirname = dirname(import.meta); 10 | const build = () => { 11 | return new Promise((resolve, reject) => { 12 | exec( 13 | "swc bot --out-dir .conflict/build --config-file " + 14 | path.join(__dirname, "..", ".swcrc"), 15 | { cwd: process.cwd() }, 16 | (error, stdout, stderr) => { 17 | if (error) return reject(error); 18 | resolve({ stdout, stderr }); 19 | } 20 | ); 21 | }); 22 | }; 23 | 24 | let running = false; 25 | let next; 26 | 27 | build().then(async ({ stdout, stderr }) => { 28 | stump.info('Starting development environment...'); 29 | 30 | global.__ConflictENV = {}; 31 | 32 | global.__ConflictENV.verbose = detectFlag(process.argv, 'verbose') || detectFlag(process.argv, 'detailed'); 33 | if (global.__ConflictENV.verbose) stump.verbose('Running verbose'); 34 | if (global.__ConflictENV.verbose) process.env.CONFLICT_VERBOSE = "TRUE"; 35 | let config; 36 | try { 37 | config = await import(process.cwd() + '/conflict.config.js'); 38 | } catch (err) { 39 | stump.error('Missing conflict.config.js'); 40 | } 41 | 42 | let { token } = config.default; 43 | if (!token) token = process.env.TOKEN ?? process.env.token; 44 | if (!token) { 45 | try { 46 | token = fs.readFileSync(process.cwd() + '/token', 'utf8'); 47 | } catch (err) { 48 | stump.error(new Error('Missing token. No token found in config file, token file, or env variable.')); 49 | process.exit(1); 50 | } 51 | } 52 | 53 | const manager = new ShardingManager(path.join(__dirname, '..', 'bot.js'), { token: token }); 54 | 55 | manager.on('shardCreate', shard => stump.success(`Launched shard ${shard.id}`)); 56 | manager.spawn().then(_ => { 57 | stump.success('All shards launched, waiting for file events...'); 58 | chokidar.watch('./bot', { 59 | persistent: true, 60 | ignoreInitial: true, 61 | awaitWriteFinish: true 62 | }).on('all', (event, path) => { 63 | onFileChange(); 64 | }); 65 | }); 66 | 67 | function refresh () { 68 | manager.broadcastEval(c => { 69 | c.emit('conflict.hotReload'); 70 | }); 71 | } 72 | 73 | async function buildAndRefresh () { 74 | manager.broadcastEval(c => { 75 | c.emit('conflict.startThinking'); 76 | }); 77 | stump.info('Change detected, rebuilding...'); 78 | if (global.__ConflictENV.verbose) stump.verbose('Starting rebuild...'); 79 | await build(); 80 | if (global.__ConflictENV.verbose) stump.verbose('Finished building, starting refresh...'); 81 | refresh(); 82 | if (global.__ConflictENV.verbose) stump.verbose('Refresh finished'); 83 | } 84 | 85 | async function onFileChange () { 86 | if (running) next = true; 87 | else { 88 | running = true; 89 | await buildAndRefresh(); 90 | running = false; 91 | while (next) { 92 | next = false; 93 | buildAndRefresh(); 94 | } 95 | } 96 | } 97 | 98 | }); -------------------------------------------------------------------------------- /conflict/ep.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import { ShardingManager } from 'discord.js' 4 | import { dirname } from "esm-dirname" 5 | import path from 'path' 6 | import fs from 'fs' 7 | import { exec } from 'child_process' 8 | const __dirname = dirname(import.meta); 9 | import stump from './logger.js' 10 | import { detectFlag } from './utils.js' 11 | 12 | process.argv.shift(); 13 | process.argv.shift(); 14 | 15 | global.__ConflictENV = {}; 16 | global.__ConflictFilePrefix = process.platform === 'win32' ? 'file://' : ''; 17 | 18 | const vercel = process.env.VERCEL_ENV || process.argv.includes('-vercel') || process.argv.includes('--vercel') || process.argv.includes('-V') || process.argv.includes('--V'); 19 | 20 | (async () => { 21 | if (process.argv[0] == 'help' || process.argv.includes('-h') || process.argv.includes('--h') || process.argv.includes('-help') || process.argv.includes('--help')) { 22 | stump.info('Please view documentation at https://conflict.js.org/docs'); 23 | return; 24 | } 25 | 26 | if (process.argv[0] == 'dev') { 27 | if (global.__ConflictReplitRunDev) delete global.__ConflictReplitRunDev; 28 | await import(global.__ConflictFilePrefix + __dirname + '/devserver/index.js'); 29 | } else if (process.argv[0] == 'build') { 30 | stump.info('Starting build...'); 31 | 32 | exec( 33 | "swc bot --out-dir .conflict/build --config-file " + 34 | path.join(__dirname, ".swcrc"), 35 | { cwd: process.cwd() }, 36 | async (error, stdout, stderr) => { 37 | if (error) return stump.error(error); 38 | stdout 39 | .trim() 40 | .split("\n") 41 | .filter((line) => line) 42 | .forEach((line) => stump.info(line)); 43 | stderr = stderr 44 | .trim() 45 | .split("\n") 46 | .filter((line) => line); 47 | stderr.forEach((line) => stump.warn(line)); 48 | stump.success(`Build completed with ${stderr.length} errors`); 49 | 50 | if (vercel) { 51 | stump.info( 52 | "Deploying to Vercel will disable events and only listen for commands" 53 | ); 54 | const { finish } = await import("./vercel.js"); 55 | if (finish) await finish(); 56 | } 57 | } 58 | ); 59 | } else { 60 | 61 | global.__ConflictENV.verbose = detectFlag(process.argv, 'verbose') || detectFlag(process.argv, 'detailed'); 62 | if (global.__ConflictENV.verbose) stump.verbose('Running verbose'); 63 | if (global.__ConflictENV.verbose) process.env.CONFLICT_VERBOSE = "TRUE"; 64 | let config; 65 | try { 66 | config = await import(global.__ConflictFilePrefix + process.cwd() + '/conflict.config.js'); 67 | } catch (err) { 68 | return stump.error('Missing conflict.config.js'); 69 | } 70 | let { token } = config.default; 71 | if (!token) token = process.env.TOKEN ?? process.env.token; 72 | if (!token) { 73 | try { 74 | token = fs.readFileSync(process.cwd() + '/token', 'utf8'); 75 | } catch (err) { 76 | stump.error(new Error('Missing token. No token found in config file, token file, or env variable.')); 77 | process.exit(1); 78 | } 79 | } 80 | 81 | const manager = new ShardingManager(path.join(__dirname, 'bot.js'), { token: token.trim() }); 82 | 83 | manager.on('shardCreate', shard => stump.success(`Launched shard ${shard.id}`)); 84 | manager.spawn(); 85 | } 86 | 87 | })(); -------------------------------------------------------------------------------- /conflict/events.js: -------------------------------------------------------------------------------- 1 | let client; 2 | let events = {}; 3 | 4 | // Discord events 5 | 6 | export function onApiRequest (fn) { 7 | client.on('apiRequest', fn); 8 | } 9 | events.onApiRequest = onApiRequest; 10 | 11 | export function onApiResponse (fn) { 12 | client.on('apiResponse', fn); 13 | } 14 | events.onApiResponse = onApiResponse; 15 | 16 | export function onChannelCreate (fn) { 17 | client.on('channelCreate', fn); 18 | } 19 | events.onChannelCreate = onChannelCreate; 20 | 21 | export function onChannelDelete (fn) { 22 | client.on('channelDelete', fn); 23 | } 24 | events.onChannelDelete = onChannelDelete; 25 | 26 | export function onChannelPinsUpdate (fn) { 27 | client.on('channelPinsUpdate', fn); 28 | } 29 | events.onChannelPinsUpdate = onChannelPinsUpdate; 30 | 31 | export function onChannelUpdate (fn) { 32 | client.on('channelUpdate', fn); 33 | } 34 | events.onChannelUpdate = onChannelUpdate; 35 | 36 | export function onDebug (fn) { 37 | client.on('debug', fn); 38 | } 39 | events.onDebug = onDebug; 40 | 41 | export function onEmojiCreate (fn) { 42 | client.on('emojiCreate', fn); 43 | } 44 | events.onEmojiCreate = onEmojiCreate; 45 | 46 | export function onEmojiDelete (fn) { 47 | client.on('emojiDelete', fn); 48 | } 49 | events.onEmojiDelete = onEmojiDelete; 50 | 51 | export function onEmojiUpdate (fn) { 52 | client.on('emojiUpdate', fn); 53 | } 54 | events.onEmojiUpdate = onEmojiUpdate; 55 | 56 | export function onError (fn) { 57 | client.on('error', fn); 58 | } 59 | events.onError = onError; 60 | 61 | export function onGuildBanAdd (fn) { 62 | client.on('guildBanAdd', fn); 63 | } 64 | events.onGuildBanAdd = onGuildBanAdd; 65 | 66 | export function onGuildBanRemove (fn) { 67 | client.on('guildBanRemove', fn); 68 | } 69 | events.onGuildBanRemove = onGuildBanRemove; 70 | 71 | export function onGuildCreate (fn) { 72 | client.on('guildCreate', fn); 73 | } 74 | events.onGuildCreate = onGuildCreate; 75 | 76 | export function onGuildDelete (fn) { 77 | client.on('guildDelete', fn); 78 | } 79 | events.onGuildDelete = onGuildDelete; 80 | 81 | export function onGuildIntegrationsUpdate (fn) { 82 | client.on('guildIntegrationsUpdate', fn); 83 | } 84 | events.onGuildIntegrationsUpdate = onGuildIntegrationsUpdate; 85 | 86 | export function onGuildMemberAdd (fn) { 87 | client.on('guildMemberAdd', fn); 88 | } 89 | events.onGuildMemberAdd = onGuildMemberAdd; 90 | 91 | export function onGuildMemberAvailable (fn) { 92 | client.on('guildMemberAvailable', fn); 93 | } 94 | events.onGuildMemberAvailable = onGuildMemberAvailable; 95 | 96 | export function onGuildMemberRemove (fn) { 97 | client.on('guildMemberRemove', fn); 98 | } 99 | events.onGuildMemberRemove = onGuildMemberRemove; 100 | 101 | export function onGuildMembersChunk (fn) { 102 | client.on('guildMembersChunk', fn); 103 | } 104 | events.onGuildMembersChunk = onGuildMembersChunk; 105 | 106 | export function onGuildMemberUpdate (fn) { 107 | client.on('guildMemberUpdate', fn); 108 | } 109 | events.onGuildMemberUpdate = onGuildMemberUpdate; 110 | 111 | export function onGuildScheduledEventCreate (fn) { 112 | client.on('guildScheduledEventCreate', fn); 113 | } 114 | events.onGuildScheduledEventCreate = onGuildScheduledEventCreate; 115 | 116 | export function onGuildScheduledEventDelete (fn) { 117 | client.on('guildScheduledEventDelete', fn); 118 | } 119 | events.onGuildScheduledEventDelete = onGuildScheduledEventDelete; 120 | 121 | export function onGuildScheduledEventUpdate (fn) { 122 | client.on('guildScheduledEventUpdate', fn); 123 | } 124 | events.onGuildScheduledEventUpdate = onGuildScheduledEventUpdate; 125 | 126 | export function onGuildScheduledEventUserAdd (fn) { 127 | client.on('guildScheduledEventUserAdd', fn); 128 | } 129 | events.onGuildScheduledEventUserAdd = onGuildScheduledEventUserAdd; 130 | 131 | export function onGuildScheduledEventUserRemove (fn) { 132 | client.on('guildScheduledEventUserRemove', fn); 133 | } 134 | events.onGuildScheduledEventUserRemove = onGuildScheduledEventUserRemove; 135 | 136 | export function onGuildUnavailable (fn) { 137 | client.on('guildUnavailable', fn); 138 | } 139 | events.onGuildUnavailable = onGuildUnavailable; 140 | 141 | export function onGuildUpdate (fn) { 142 | client.on('guildUpdate', fn); 143 | } 144 | events.onGuildUpdate = onGuildUpdate; 145 | 146 | export function onInteractionCreate (fn) { 147 | client.on('interactionCreate', fn); 148 | } 149 | events.onInteractionCreate = onInteractionCreate; 150 | 151 | export function onInvalidated (fn) { 152 | client.on('invalidated', fn); 153 | } 154 | events.onInvalidated = onInvalidated; 155 | 156 | export function onInvalidRequestWarning (fn) { 157 | client.on('invalidRequestWarning', fn); 158 | } 159 | events.onInvalidRequestWarning = onInvalidRequestWarning; 160 | 161 | export function onInviteCreate (fn) { 162 | client.on('inviteCreate', fn); 163 | } 164 | events.onInviteCreate = onInviteCreate; 165 | 166 | export function onInviteDelete (fn) { 167 | client.on('inviteDelete', fn); 168 | } 169 | events.onInviteDelete = onInviteDelete; 170 | 171 | export function onMessageCreate (fn) { 172 | client.on('messageCreate', fn); 173 | } 174 | events.onMessageCreate = onMessageCreate; 175 | 176 | export function onMessageDelete (fn) { 177 | client.on('messageDelete', fn); 178 | } 179 | events.onMessageDelete = onMessageDelete; 180 | 181 | export function onMessageDeleteBulk (fn) { 182 | client.on('messageDeleteBulk', fn); 183 | } 184 | events.onMessageDeleteBulk = onMessageDeleteBulk; 185 | 186 | export function onMessageReactionAdd (fn) { 187 | client.on('messageReactionAdd', fn); 188 | } 189 | events.onMessageReactionAdd = onMessageReactionAdd; 190 | 191 | export function onMessageReactionRemove (fn) { 192 | client.on('messageReactionRemove', fn); 193 | } 194 | events.onMessageReactionRemove = onMessageReactionRemove; 195 | 196 | export function onMessageReactionRemoveAll (fn) { 197 | client.on('messageReactionRemoveAll', fn); 198 | } 199 | events.onMessageReactionRemoveAll = onMessageReactionRemoveAll; 200 | 201 | export function onMessageReactionRemoveEmoji (fn) { 202 | client.on('messageReactionRemoveEmoji', fn); 203 | } 204 | events.onMessageReactionRemoveEmoji = onMessageReactionRemoveEmoji; 205 | 206 | export function onMessageUpdate (fn) { 207 | client.on('messageUpdate', fn); 208 | } 209 | events.onMessageUpdate = onMessageUpdate; 210 | 211 | export function onPresenceUpdate (fn) { 212 | client.on('presenceUpdate', fn); 213 | } 214 | events.onPresenceUpdate = onPresenceUpdate; 215 | 216 | export function onRateLimit (fn) { 217 | client.on('rateLimit', fn); 218 | } 219 | events.onRateLimit = onRateLimit; 220 | 221 | export function onReady (fn) { 222 | client.on('ready', fn); 223 | } 224 | events.onReady = onReady; 225 | 226 | export function onRoleCreate (fn) { 227 | client.on('roleCreate', fn); 228 | } 229 | events.onRoleCreate = onRoleCreate; 230 | 231 | export function onRoleDelete (fn) { 232 | client.on('roleDelete', fn); 233 | } 234 | events.onRoleDelete = onRoleDelete; 235 | 236 | export function onRoleUpdate (fn) { 237 | client.on('roleUpdate', fn); 238 | } 239 | events.onRoleUpdate = onRoleUpdate; 240 | 241 | export function onShardDisconnect (fn) { 242 | client.on('shardDisconnect', fn); 243 | } 244 | events.onShardDisconnect = onShardDisconnect; 245 | 246 | export function onShardError (fn) { 247 | client.on('shardError', fn); 248 | } 249 | events.onShardError = onShardError; 250 | 251 | export function onShardReady (fn) { 252 | client.on('shardReady', fn); 253 | } 254 | events.onShardReady = onShardReady; 255 | 256 | export function onShardReconnecting (fn) { 257 | client.on('shardReconnecting', fn); 258 | } 259 | events.onShardReconnecting = onShardReconnecting; 260 | 261 | export function onShardResume (fn) { 262 | client.on('shardResume', fn); 263 | } 264 | events.onShardResume = onShardResume; 265 | 266 | export function onStageInstanceCreate (fn) { 267 | client.on('stageInstanceCreate', fn); 268 | } 269 | events.onStageInstanceCreate = onStageInstanceCreate; 270 | 271 | export function onStageInstanceDelete (fn) { 272 | client.on('stageInstanceDelete', fn); 273 | } 274 | events.onStageInstanceDelete = onStageInstanceDelete; 275 | 276 | export function onStageInstanceUpdate (fn) { 277 | client.on('stageInstanceUpdate', fn); 278 | } 279 | events.onStageInstanceUpdate = onStageInstanceUpdate; 280 | 281 | export function onStickerCreate (fn) { 282 | client.on('stickerCreate', fn); 283 | } 284 | events.onStickerCreate = onStickerCreate; 285 | 286 | export function onStickerDelete (fn) { 287 | client.on('stickerDelete', fn); 288 | } 289 | events.onStickerDelete = onStickerDelete; 290 | 291 | export function onStickerUpdate (fn) { 292 | client.on('stickerUpdate', fn); 293 | } 294 | events.onStickerUpdate = onStickerUpdate; 295 | 296 | export function onThreadCreate (fn) { 297 | client.on('threadCreate', fn); 298 | } 299 | events.onThreadCreate = onThreadCreate; 300 | 301 | export function onThreadDelete (fn) { 302 | client.on('threadDelete', fn); 303 | } 304 | events.onThreadDelete = onThreadDelete; 305 | 306 | export function onThreadListSync (fn) { 307 | client.on('threadListSync', fn); 308 | } 309 | events.onThreadListSync = onThreadListSync; 310 | 311 | export function onThreadMembersUpdate (fn) { 312 | client.on('threadMembersUpdate', fn); 313 | } 314 | events.onThreadMembersUpdate = onThreadMembersUpdate; 315 | 316 | export function onThreadMemberUpdate (fn) { 317 | client.on('threadMemberUpdate', fn); 318 | } 319 | events.onThreadMemberUpdate = onThreadMemberUpdate; 320 | 321 | export function onThreadUpdate (fn) { 322 | client.on('threadUpdate', fn); 323 | } 324 | events.onThreadUpdate = onThreadUpdate; 325 | 326 | export function onTypingStart (fn) { 327 | client.on('typingStart', fn); 328 | } 329 | events.onTypingStart = onTypingStart; 330 | 331 | export function onUserUpdate (fn) { 332 | client.on('userUpdate', fn); 333 | } 334 | events.onUserUpdate = onUserUpdate; 335 | 336 | export function onVoiceStateUpdate (fn) { 337 | client.on('voiceStateUpdate', fn); 338 | } 339 | events.onVoiceStateUpdate = onVoiceStateUpdate; 340 | 341 | export function onWarn (fn) { 342 | client.on('warn', fn); 343 | } 344 | events.onWarn = onWarn; 345 | 346 | export function onWebhookUpdate (fn) { 347 | client.on('webhookUpdate', fn); 348 | } 349 | events.onWebhookUpdate = onWebhookUpdate; 350 | 351 | export function on (event, fn) { 352 | client.on(event, fn); 353 | } 354 | events.on = on; 355 | 356 | export function emit (event, ...args) { 357 | client.emit(event, ...args); 358 | } 359 | events.on = emit; 360 | 361 | // Conflict events 362 | 363 | export function onHotReload (fn) { 364 | client.on('conflict.hotReload', (...args) => { 365 | fn(...args); 366 | }); 367 | } 368 | events.onHotReload = onHotReload; 369 | 370 | export function onStartThinking (fn) { 371 | client.on('conflict.startThinking', () => { 372 | fn(); 373 | }); 374 | } 375 | events.onStartThinking = onStartThinking; 376 | 377 | // Time-based events 378 | 379 | export function onInterval (interval, code, startRightAway) { 380 | let counter = startRightAway ? 1 : 0; 381 | if (startRightAway) code(0); 382 | let id = setInterval(_ => { 383 | code(counter); 384 | counter++; 385 | }, interval); 386 | return id; 387 | } 388 | events.onInterval = onInterval; 389 | 390 | export function onLoop (delay, code) { 391 | let counter = 0; 392 | let ended = false; 393 | (function loop () { 394 | setTimeout(async _ => { 395 | let output = code(counter); 396 | if (output instanceof Promise) await output; 397 | counter++; 398 | if (!ended) loop(); 399 | }, delay) 400 | })(); 401 | return _ => { 402 | ended = true; 403 | } 404 | } 405 | events.onLoop = onLoop; 406 | 407 | // Configuration 408 | 409 | export function _setClient (newClient) { 410 | client = newClient; 411 | } 412 | events._setClient = _setClient; 413 | 414 | export default events; -------------------------------------------------------------------------------- /conflict/exports.js: -------------------------------------------------------------------------------- 1 | import View from './renderer/view.js'; 2 | import logger from './logger.js'; 3 | import Command from './commands.js'; 4 | 5 | export { View, logger, Command }; -------------------------------------------------------------------------------- /conflict/handler/gateway.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conflictjs/conflict/e794e7f7f6da6690af8e1d62b2762f068492ef59/conflict/handler/gateway.js -------------------------------------------------------------------------------- /conflict/handler/handler.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conflictjs/conflict/e794e7f7f6da6690af8e1d62b2762f068492ef59/conflict/handler/handler.js -------------------------------------------------------------------------------- /conflict/handler/webhook.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conflictjs/conflict/e794e7f7f6da6690af8e1d62b2762f068492ef59/conflict/handler/webhook.js -------------------------------------------------------------------------------- /conflict/hooks.js: -------------------------------------------------------------------------------- 1 | export function useState (defaultValue) { 2 | let value = defaultValue; 3 | let message, view; 4 | function setValue (newVlalue) { 5 | value = newValue; 6 | } 7 | function callback (sentMessage, viewInstance) { 8 | message = sentMessage; 9 | view = viewInstance; 10 | } 11 | return [value, setValue, callback]; 12 | } 13 | 14 | export function deleteAfter (time = 5000) { // Called when creating the view 15 | return function (message, view) { // Called after message is sent 16 | setTimeout(() => { 17 | message.delete(); 18 | }, time); 19 | } 20 | } -------------------------------------------------------------------------------- /conflict/loader/initializer.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conflictjs/conflict/e794e7f7f6da6690af8e1d62b2762f068492ef59/conflict/loader/initializer.js -------------------------------------------------------------------------------- /conflict/loader/loader.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conflictjs/conflict/e794e7f7f6da6690af8e1d62b2762f068492ef59/conflict/loader/loader.js -------------------------------------------------------------------------------- /conflict/logger.js: -------------------------------------------------------------------------------- 1 | import Stump from 'stump.js' 2 | const logger = new Stump(['Debug']) 3 | 4 | export { logger as default, logger as stump, logger as logger } -------------------------------------------------------------------------------- /conflict/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "conflict", 3 | "version": "0.1.5", 4 | "description": "The first and only UI framework for Discord bots", 5 | "main": "exports.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "components": "cd components && npx swc src --out-dir dist" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/conflictjs/conflict.git" 13 | }, 14 | "keywords": [ 15 | "conflict", 16 | "js", 17 | "discord", 18 | "discord.js" 19 | ], 20 | "bin": { 21 | "conflict": "./cli/index.js" 22 | }, 23 | "author": "YodaLightsabr", 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/conflictjs/conflict/issues" 27 | }, 28 | "homepage": "https://github.com/conflictjs/conflict#readme", 29 | "dependencies": { 30 | "@discordjs/rest": "^0.3.0", 31 | "chokidar": "^3.5.3", 32 | "deep-equal": "^2.2.0", 33 | "discord-api-types": "^0.29.0", 34 | "discord-interactions": "^3.2.0", 35 | "discord.js": "^13.8.1", 36 | "esm-dirname": "^0.1.1", 37 | "node-fetch": "^3.3.0", 38 | "stump.js": "^1.1.0", 39 | "@swc/cli": "^0.1.61", 40 | "@swc/core": "^1.3.35" 41 | }, 42 | "exports": { 43 | "./View": "./renderer/view.js", 44 | "./view": "./renderer/view.js", 45 | "./views": "./renderer/view.js", 46 | "./events": "./events.js", 47 | "./hooks": "./hooks.js", 48 | "./logger": "./logger.js", 49 | "./commands": "./commands.js", 50 | "./utils": "./utils.js", 51 | "./state": "./state.js", 52 | "./components": "./components.js", 53 | "./Components": "./components.js", 54 | "./global-ratelimit-plugin": "./plugins/global-ratelimit.js", 55 | "./plugins": "./plugins" 56 | }, 57 | "type": "module" 58 | } 59 | -------------------------------------------------------------------------------- /conflict/plugins/global-ratelimit.js: -------------------------------------------------------------------------------- 1 | export default function plugin ({ client, events, logger }) { 2 | events.onDebug(debug => { 3 | if (debug.startsWith('429 on /gateway/bot')) { 4 | logger.error('429 login ratelimit'); 5 | } 6 | }); 7 | } // A simple example plugin to tell you when you have a 429 on a login request 8 | 9 | -------------------------------------------------------------------------------- /conflict/renderer/setState.js: -------------------------------------------------------------------------------- 1 | 2 | export function setState (modifications) { 3 | try { 4 | let triggerUpdate = false; 5 | 6 | if (__ConflictRenderState) { 7 | for (const key in modifications) { 8 | if (__ConflictRenderState[key] !== modifications[key]) triggerUpdate = true; 9 | 10 | __ConflictRenderState[key] = modifications[key]; 11 | } 12 | 13 | return __ConflictRenderState; 14 | } 15 | 16 | if (triggerUpdate && __ConflictTriggerUpdate) __ConflictTriggerUpdate(); 17 | } catch (err) {} 18 | 19 | return null; 20 | } 21 | 22 | export default setState; -------------------------------------------------------------------------------- /conflict/renderer/templateRenderer.js: -------------------------------------------------------------------------------- 1 | import View from "./view.js"; 2 | 3 | export function renderTemplate (template, props) { 4 | const rawJsx = template(props); 5 | const __ConflictRenderState = props; 6 | const __ConflictTriggerUpdate = () => { 7 | 8 | }; 9 | 10 | const view = new View(rawJsx); 11 | return view; 12 | } -------------------------------------------------------------------------------- /conflict/renderer/view.js: -------------------------------------------------------------------------------- 1 | import Discord from 'discord.js'; 2 | import stump from '../logger.js'; 3 | 4 | export const createElement = (tag, props = {}, ...children) => { 5 | if (props == null) props = {}; 6 | if (children == null) children = []; 7 | 8 | if (typeof tag === 'function') { 9 | props.children = children; 10 | return tag(props); 11 | } 12 | 13 | return new Component({ 14 | tag: tag, 15 | props: props, 16 | children: children 17 | }) 18 | 19 | } 20 | 21 | export const parseView = (input) => { 22 | let { tag, props = {}, children = [] } = input; 23 | if (props == null) props = {}; 24 | if (children == null) children = []; 25 | if (children.length == 1 && children[0] instanceof Array) children = children[0]; 26 | if (children.length == 1 && children[0] instanceof Array) children = children[0]; 27 | let object = props; 28 | children.forEach((child, index) => { 29 | let childObject; 30 | if (child.children && child.children instanceof Array && child.children.filter(newChild => typeof newChild === 'string' || typeof newChild === 'number').length == child.children.length) { 31 | childObject = child.children.join(''); 32 | } 33 | else childObject = parseView(child); 34 | if (child.props && child.props.as && typeof child.props.as === 'function') { 35 | childObject = new(child.props.as)(childObject); 36 | delete child.props.as; 37 | } 38 | 39 | if (child.tag && child.tag.endsWith && child.tag.endsWith('_arr')) child.tag = child.tag.substring(0, child.tag.length - 4) + ('$' + Date.now() + index + 'R' + '$'); // Allow for multiple elements with the same tag, so long as it ends with _arr 40 | 41 | // if (!object[child.tag] && child.tag === 'embeds') object[child.tag] = []; 42 | if (!object[child.tag] && child.tag === 'components') object[child.tag] = []; 43 | 44 | else if (!object[child.tag] && child.tag === 'vstack') object[child.tag] = []; 45 | 46 | if (object[child.tag] && !(object[child.tag] instanceof Array)) object[child.tag] = [object[child.tag]]; 47 | 48 | if (object[child.tag] instanceof Array) object[child.tag].push(childObject); 49 | else object[child.tag] = childObject; 50 | }); 51 | 52 | 53 | let keys = Object.keys(object); 54 | // if (keys.length == 1 && keys[0] === 'embed' && tag === 'embeds') object = object[keys[0]]; 55 | if (keys.length == 1 && keys[0] === 'hstack' && tag === 'vstack') object = object[keys[0]]; 56 | //console.log('isComponent', keys.length == 1 && keys[0] === 'component' && tag === 'components'); 57 | // if (keys.length == 1 && keys[0] === 'component' && tag === 'components') object = [object[keys[0]]]; 58 | if (object.components && object.components[0]) { 59 | //console.log(object.components[0]) 60 | } 61 | return new Component(object); 62 | } 63 | 64 | export function recursiveArray (tree) { 65 | for (const key in tree) { 66 | let newName; 67 | if (key.includes('$')) { 68 | newName = key.substring(0, key.indexOf('$')); 69 | if (tree[newName]) tree[newName].push(Object.values(tree[key])[0]); 70 | else { 71 | tree[newName] = [Object.values(tree[key])[0]]; 72 | } 73 | delete tree[key]; 74 | } 75 | if (tree[key] instanceof Array) { 76 | tree[key] = tree[key].map(item => recursiveArray(item)); 77 | } else if (newName && tree[newName] instanceof Array) { 78 | tree[newName] = tree[newName].map(item => recursiveArray(item)); 79 | } else if (typeof tree[key] == 'object') tree[key] = recursiveArray(tree[key]); 80 | } 81 | return new Component(tree); 82 | } 83 | 84 | export function parseTree (tree) { 85 | /** 86 | * Parses a tree of elements to deal with syntax 87 | * @param {object} A tree of JSX elements 88 | * @returns {object} A parsed message ready to be sent 89 | */ 90 | tree = recursiveArray(tree); 91 | // console.log(JSON.stringify(tree, null, 4)); 92 | return tree; 93 | } 94 | 95 | export class Component { 96 | constructor (target) { 97 | for (const key in target) { 98 | this[key] = target[key]; 99 | } 100 | } 101 | } 102 | 103 | export class View { 104 | constructor (target) { 105 | let parsed = parseView(target); 106 | parsed = parseTree(parsed); 107 | let $hooks = []; 108 | let attachments = []; 109 | for (const key in parsed) { 110 | if (key === 'attachments') { 111 | attachments = parsed[key]; 112 | } else this[key] = parsed[key]; 113 | } 114 | this.callback = async function (message) { 115 | if (message instanceof Discord.Message) { 116 | let hooks = $hooks; 117 | for (const hook of hooks) { 118 | hook(output, this); 119 | } 120 | } 121 | } 122 | this.applyTo = async function (channel, options, isInteraction, isVercel) { 123 | let output = isInteraction ? channel.reply(this, options, ...attachments) : channel.send(this, ...attachments); 124 | if (output instanceof Promise) output = await output; 125 | if (output instanceof Discord.Message) { 126 | let hooks = $hooks; 127 | for (const hook of hooks) { 128 | hook(output, this) 129 | } 130 | } 131 | } 132 | this.applyHooks = function (...hooks) { 133 | $hooks.push(...hooks); 134 | return this; 135 | } 136 | this.useHooks = function (...hooks) { 137 | $hooks.push(...hooks); 138 | return this; 139 | } 140 | } 141 | static createElement (tag, props = {}, ...children) { 142 | return createElement(tag, props, ...children); 143 | } 144 | toObject () { 145 | let object = {}; 146 | for (const key in this) { 147 | object[key] = this[key]; 148 | } 149 | return object; 150 | } 151 | } 152 | 153 | export default View; -------------------------------------------------------------------------------- /conflict/replit.js: -------------------------------------------------------------------------------- 1 | import stump from './logger.js'; 2 | import { dirname } from "esm-dirname" 3 | const __dirname = dirname(import.meta); 4 | 5 | stump.info("Running Conflict on Replit..."); 6 | 7 | await import(global.__ConflictFilePrefix + __dirname + '/devserver/index.js'); -------------------------------------------------------------------------------- /conflict/state.js: -------------------------------------------------------------------------------- 1 | import { uuid, queryString } from './utils.js' 2 | import crypto from 'crypto' 3 | import fs from 'fs' 4 | import path from 'path' 5 | 6 | class StateManager { 7 | constructor (type) { 8 | this.type = type; 9 | this.items = {}; 10 | } 11 | select (item) { 12 | if (this.items[item]) return this.items[item]; 13 | this.items[item] = new State(item, this.type); 14 | return this.items[item]; 15 | } 16 | drop (item) { 17 | if (this.items[item]) delete this.items[item]; 18 | } 19 | } 20 | class ComponentManager extends StateManager { 21 | constructor (type) { 22 | super(type); 23 | } 24 | select (item) { 25 | if (this.items[item]) return this.items[item]; 26 | this.items[item] = new ComponentState(item, this.type); 27 | return this.items[item]; 28 | } 29 | } 30 | class State { 31 | constructor (name, type) { 32 | this.name = name; 33 | this.type = type; 34 | this.data = {}; 35 | } 36 | static command (commandName) { 37 | return managers.command.select(commandName); 38 | } 39 | static guild (guildId) { 40 | return managers.guild.select(guildId); 41 | } 42 | static user (userId) { 43 | return managers.user.select(userId); 44 | } 45 | static kv () { 46 | return managers.kv.select('*'); 47 | } 48 | static components () { 49 | return managers.components.select('*'); 50 | } 51 | drop () { 52 | managers[this.type].drop(this.name); 53 | } 54 | get (key) { 55 | return this.data[key]; 56 | } 57 | set (key, value) { 58 | this.data[key] = value; 59 | } 60 | delete (key) { 61 | if (this.data[key]) delete this.data[key]; 62 | } 63 | } 64 | class ComponentState extends State { 65 | constructor (name, type) { 66 | super(name, type); 67 | this.statelessPath = global.__ConflictEnvironment == 'vercel' ? path.join(process.cwd(), '.stateless.cache') : path.join(process.cwd(), '.conflict', '.stateless.cache'); 68 | } 69 | store (code) { 70 | let id = uuid(); 71 | let queryString = 'c?type=code&id=' + encodeURIComponent(id); 72 | this.set(id, code); 73 | return queryString; 74 | } 75 | statelessStore (code) { 76 | let id = crypto.createHmac("sha256", 'shhh').update(code.toString()).digest("base64"); 77 | let queryString = 'c?type=stateless&r=' + Math.floor(Math.random() * 10000) + (Date.now() + '').substring(5) + '&id=' + encodeURIComponent(id); 78 | if (this.get(id)) return queryString; 79 | this.set(id, code); 80 | let cwd = process.cwd(); 81 | let cache = fs.readFileSync(this.statelessPath, 'utf8'); 82 | cache = cache.split('\n\n[===]\n\n').filter(segment => segment); 83 | let data = id + '\n' + Buffer.from(code.toString()).toString('base64'); 84 | if (cache.includes(data)) return queryString; 85 | cache.push(data); 86 | fs.writeFileSync(this.statelessPath, cache.join('\n\n[===]\n\n'), 'utf8') 87 | return queryString; 88 | } 89 | statelessLoad () { 90 | let cwd = process.cwd(); 91 | if (!fs.existsSync(this.statelessPath)) 92 | fs.writeFileSync( 93 | path.join(cwd, ".conflict", ".stateless.cache"), 94 | "", 95 | "utf8" 96 | ); 97 | let cache = fs.readFileSync(this.statelessPath, "utf8"); 98 | cache = cache 99 | .split("\n\n[===]\n\n") 100 | .filter((segment) => segment) 101 | .map((cacheSegment) => { 102 | let [id, code] = cacheSegment.split("\n"); 103 | code = Buffer.from(code, "base64").toString("utf8"); 104 | return { id, code }; 105 | }); 106 | // for (const segment of cache) { 107 | // this.set(segment.id, eval(segment.code)); 108 | // } 109 | return cache; 110 | } 111 | fetch (url) { 112 | let id = decodeURIComponent(queryString('https://conflict.local/' + url, 'id')); 113 | return this.get(id); 114 | } 115 | } 116 | 117 | const managers = { 118 | command: new StateManager('command'), 119 | guild: new StateManager('guild'), 120 | user: new StateManager('user'), 121 | kv: new StateManager('kv'), 122 | components: new ComponentManager('components'), 123 | }; 124 | 125 | export { State as default, State, managers } -------------------------------------------------------------------------------- /conflict/utils.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | import { exec as execute } from 'child_process'; 4 | 5 | export function uuid () { 6 | let time = new Date().getTime(); 7 | let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, character => { 8 | let random = (time + Math.random() * 16) %16 | 0; 9 | time = Math.floor(time / 16); 10 | return (character == 'x' ? random :(random&0x3|0x8)).toString(16); 11 | }); 12 | return uuid; 13 | } 14 | 15 | export function queryString (url, name) { 16 | name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 17 | var regexS = "[\\?&]"+name+"=([^&#]*)"; 18 | var regex = new RegExp( regexS ); 19 | var results = regex.exec( url ); 20 | if( results == null ) 21 | return ""; 22 | else 23 | return results[1]; 24 | } 25 | 26 | export function getFile (error) { 27 | let output = 'Unable to find file location'; 28 | try { 29 | let fileLine = error.stack.split('\n')[1]; 30 | let stackTrace = (fileLine.includes('(') && fileLine.includes(')')) ? fileLine.split('(')[1].split(')')[0] : fileLine.substring(fileLine.indexOf('at') + 3); 31 | let lastColon = stackTrace.lastIndexOf(':'); 32 | let col = stackTrace.substring(lastColon + 1); 33 | let filePath = stackTrace.substring(0, lastColon); 34 | lastColon = filePath.lastIndexOf(':'); 35 | let line = +filePath.substring(lastColon + 1); 36 | filePath = filePath.substring(0, lastColon); 37 | if (filePath.startsWith('file://')) filePath = filePath.substring(7); 38 | const fileData = fs.readFileSync(filePath, 'utf8'); 39 | let snippet = fileData.split('\n').slice(line - 4, line + 2).join('\n'); 40 | let lines = snippet.split('\n'); 41 | if (lines.length < 5) { 42 | snippet = snippet; 43 | } else { 44 | lines = [ 45 | '// ' + path.basename(filePath) + ':' + (line - 3), 46 | lines[0], 47 | lines[1], 48 | lines[2], 49 | lines[3], 50 | '//' + ' '.repeat(col - 3) + '^ ' + error.stack.split('\n')[0] + ' (:' + line + ':' + col + ')', 51 | lines[4], 52 | lines[5], 53 | lines[6] 54 | ]; 55 | snippet = lines.join('\n'); 56 | } 57 | output = "```js\n" + snippet + "```"; 58 | } catch (err) {} 59 | return output; 60 | } 61 | 62 | export function cleanLines (input, lines) { 63 | return input.split('\n').splice(0, input.split('\n').length - lines).join('\n'); 64 | } 65 | 66 | export function detectFlag (args, flag, allFlags = []) { 67 | let flagLetters = allFlags.map(flagItem => flagItem[0]); 68 | return ( 69 | args.includes('-' + flag) || 70 | args.includes('--' + flag) || 71 | args.includes('-' + ( flagLetters.includes(flag[0]) ? flag[0].toUpperCase() : flag[0] )) || 72 | args.includes('--' + ( flagLetters.includes(flag[0]) ? flag[0].toUpperCase() : flag[0] )) 73 | ); 74 | } 75 | 76 | class ExecOutput { 77 | constructor (stdout, stderr, time, args) { 78 | this.stdout = stdout; 79 | this.stderr = stderr; 80 | this.time = time; 81 | this.args = args; 82 | } 83 | } 84 | 85 | export function exec (...args) { 86 | return new Promise((resolve, reject) => { 87 | const start = performance.now(); 88 | 89 | execute(...args, (error, stdout, stderr) => { 90 | if (error) return reject(error); 91 | 92 | const end = performance.now(); 93 | resolve(new ExecOutput({ stdout, stderr, time: end - start, args })); 94 | }); 95 | }); 96 | } 97 | 98 | export function file (...paths) { 99 | const prefix = process.platform === 'win32' ? 'file://' : ''; 100 | 101 | return path.join(prefix, ...paths); 102 | } 103 | 104 | export function attempt (fn, ...args) { 105 | try { 106 | return [fn(...args), null]; 107 | } catch (err) { 108 | return [null, err]; 109 | } 110 | } -------------------------------------------------------------------------------- /conflict/vercel-kit/.vc-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtime": "nodejs16.x", 3 | "handler": "serve.js", 4 | "launcherType": "Nodejs", 5 | "shouldAddHelpers": true 6 | } -------------------------------------------------------------------------------- /conflict/vercel-kit/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "routes": [ 4 | { 5 | "src": "/", 6 | "dest": "/index.html" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /conflict/vercel-kit/dispatch.js: -------------------------------------------------------------------------------- 1 | // dispatch.js 2 | // Handles Discord interaction only; a complete level of abstraction above the server. 3 | 4 | import DiscordInteractions from 'discord-interactions'; 5 | const { 6 | InteractionResponseType, 7 | InteractionType, 8 | verifyKey, 9 | } = DiscordInteractions; 10 | 11 | import path from 'path'; 12 | import Command, { InteractionResponse } from '@conflict/beta/commands'; 13 | import View, { parseView } from '@conflict/beta/view'; 14 | global.__ConflictViewParser = View.createElement; 15 | global.__ConflictEnvironment = 'vercel'; 16 | 17 | import Discord from 'discord.js'; 18 | const { 19 | AutocompleteInteraction, 20 | ButtonInteraction, 21 | CommandInteraction, 22 | SelectMenuInteraction, 23 | UserContextMenuCommandInteraction, 24 | MessageContextMenuCommandInteraction, 25 | MessageEmbed, 26 | Constants 27 | } = Discord; 28 | const { Events, InteractionTypes, MessageComponentTypes, ApplicationCommandTypes } = Constants; 29 | 30 | import fs from 'fs'; 31 | import fetch from 'node-fetch'; 32 | const { all } = JSON.parse(fs.readFileSync('commands.json', 'utf8')); 33 | 34 | const commands = all; 35 | 36 | 37 | export function getFile (error) { 38 | let output = 'Unable to find file location'; 39 | try { 40 | let fileLine = error.stack.split('\n')[1]; 41 | let stackTrace = (fileLine.includes('(') && fileLine.includes(')')) ? fileLine.split('(')[1].split(')')[0] : fileLine.substring(fileLine.indexOf('at') + 3); 42 | let lastColon = stackTrace.lastIndexOf(':'); 43 | let col = stackTrace.substring(lastColon + 1); 44 | let filePath = stackTrace.substring(0, lastColon); 45 | lastColon = filePath.lastIndexOf(':'); 46 | let line = +filePath.substring(lastColon + 1); 47 | filePath = filePath.substring(0, lastColon); 48 | if (filePath.startsWith('file://')) filePath = filePath.substring(7); 49 | const fileData = fs.readFileSync(filePath, 'utf8'); 50 | let snippet = fileData.split('\n').slice(line - 4, line + 2).join('\n'); 51 | let lines = snippet.split('\n'); 52 | if (lines.length < 5) { 53 | snippet = snippet; 54 | } else { 55 | lines = [ 56 | '// ' + path.basename(filePath) + ':' + (line - 3), 57 | lines[0], 58 | lines[1], 59 | lines[2], 60 | lines[3], 61 | '//' + ' '.repeat(col - 3) + '^ ' + error.stack.split('\n')[0] + ' (:' + line + ':' + col + ')', 62 | lines[4], 63 | lines[5], 64 | lines[6] 65 | ]; 66 | snippet = lines.join('\n'); 67 | } 68 | output = "```js\n" + snippet + "```"; 69 | } catch (err) {} 70 | return output; 71 | } 72 | 73 | export function cleanLines (input, lines) { 74 | return input.split('\n').splice(0, input.split('\n').length - lines).join('\n'); 75 | } 76 | 77 | 78 | function status (...args) { 79 | if (args.length === 0) return { ___status: true, status: 200, payload: args[0] }; 80 | let code = 200, payload = {}; 81 | 82 | if ((args[0] + '').length === 3) { 83 | code = args[0]; 84 | payload = args[1]; 85 | } else { 86 | payload = args[0]; 87 | code = args[1]; 88 | } 89 | 90 | return { 91 | ___status: true, status: code, payload 92 | } 93 | } 94 | 95 | export default async function (message) { 96 | if (message.type === InteractionType.APPLICATION_COMMAND || true) { 97 | const data = message; 98 | const client = generateClient(process.env.TOKEN); 99 | 100 | // lmaoooo stolen from https://github.com/discordjs/discord.js/blob/033151cf92fe43536b8a4c0f4d7d9ed75a2095c5/packages/discord.js/src/client/actions/InteractionCreate.js 101 | 102 | 103 | 104 | let InteractionType; 105 | switch (data.type) { 106 | case InteractionTypes.APPLICATION_COMMAND: 107 | switch (data.data.type) { 108 | case ApplicationCommandTypes.CHAT_INPUT: 109 | InteractionType = CommandInteraction; 110 | break; 111 | case ApplicationCommandTypes.USER: 112 | InteractionType = UserContextMenuCommandInteraction; 113 | break; 114 | case ApplicationCommandTypes.MESSAGE: 115 | InteractionType = MessageContextMenuCommandInteraction; 116 | break; 117 | default: 118 | console.log('Received unknown type'); 119 | return; 120 | } 121 | break; 122 | case InteractionTypes.MESSAGE_COMPONENT: 123 | switch (data.data.component_type) { 124 | case MessageComponentTypes.BUTTON: 125 | InteractionType = ButtonInteraction; 126 | break; 127 | case MessageComponentTypes.SELECT_MENU: 128 | InteractionType = SelectMenuInteraction; 129 | break; 130 | default: 131 | console.log('Received unknown type'); 132 | return; 133 | } 134 | break; 135 | case InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE: 136 | InteractionType = AutocompleteInteraction; 137 | break; 138 | default: 139 | console.log('Received unknown type'); 140 | return; 141 | } 142 | 143 | const interaction = new InteractionType(client, data); 144 | 145 | let config; 146 | try { 147 | config = await import(process.cwd() + '/conflict.config.js'); 148 | } catch (err) { 149 | return console.error('Missing conflict.config.js'); 150 | } 151 | let { token, intents, errorHandler, plugins } = config.default; 152 | 153 | console.log({ 154 | cwd: process.cwd(), 155 | ls: fs.readdirSync(process.cwd()), 156 | 157 | 158 | }) 159 | try { 160 | if (interaction.isCommand() && commands[interaction.commandName]) { 161 | const file = './' + path.join('bundle', 'commands', commands[interaction.commandName]._filePath); 162 | const fileData = await import(file); 163 | let command = fileData.default; 164 | let output = command.execute(new InteractionResponse(interaction)); 165 | if (output instanceof Promise) output = await output; 166 | } else if (interaction.customId?.startsWith?.('!')) { 167 | const [name, params] = JSON.parse(interaction.customId.substring(1)); 168 | await (new InteractionResponse(interaction)).reply('ACK! ' + name + ' ' + params); 169 | } else { 170 | await interaction.reply({ embeds: [ 171 | new MessageEmbed() 172 | .setColor('#ff4444') 173 | .setTitle('Command Error') 174 | .setDescription('```' + `Conflict Erorr: CommandNotFound` + '```') 175 | .setTimestamp() 176 | ] }); 177 | } 178 | } catch (err) { 179 | 180 | console.error(err, 'initialCatchError'); 181 | try { 182 | if (errorHandler) return errorHandler(err, interaction); 183 | const file = getFile(err); 184 | await interaction.reply({ embeds: [ 185 | new MessageEmbed() 186 | .setColor('#ff4444') 187 | .setTitle('Command Error') 188 | .setDescription(file + ' ```' + cleanLines(err.stack, 4) + '```') 189 | .setTimestamp() 190 | ] }); 191 | } catch (nestedErr) { 192 | 193 | console.error('Conflict had a hard time figuring this one out.', nestedErr); 194 | if (errorHandler) return errorHandler(err, interaction); 195 | try { 196 | await interaction.channel.send( 197 | new MessageEmbed() 198 | .setColor('#ff4444') 199 | .setTitle('Command Error') 200 | .setDescription('```' + err.stack + '```') 201 | .setTimestamp() 202 | ); 203 | } catch (nestedNestedErr) { 204 | console.error('Nested error handling failed.'); 205 | } 206 | } 207 | } 208 | } 209 | } 210 | 211 | function generateClient (token) { 212 | const previousValue = process.env.DISCORD_TOKEN === undefined ? undefined : process.env.DISCORD_TOKEN; 213 | process.env.DISCORD_TOKEN = token; 214 | const client = new Discord.Client({ intents: [] }); 215 | process.env.DISCORD_TOKEN = previousValue; 216 | return client; 217 | } -------------------------------------------------------------------------------- /conflict/vercel-kit/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Conflict × Vercel 9 | 10 | 11 |

Conflict × Vercel

12 |

Congrats on deploying Conflict to Vercel! 🎉

13 |

Here are some next steps:

14 |
    15 |
  • Configure your bot to use this HTTP endpoint: loading...
  • 16 |
  • Make sure your bot works without relying on Conflict Events
  • 17 |
  • Test out your bot now that it's deployed to Vercel
  • 18 |
19 |

It's suggested that you use different bots for testing and deployment to avoid issues with the HTTP endpoint while testing.

20 | 23 | 26 | 27 | -------------------------------------------------------------------------------- /conflict/vercel-kit/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "dependencies": { 4 | "@discordjs/rest": "^0.3.0", 5 | "discord-api-types": "^0.29.0", 6 | "discord-interactions": "^3.2.0", 7 | "discord.js": "^13.8.1", 8 | "esm-dirname": "^0.1.1", 9 | "stump.js": "^1.1.0" 10 | } 11 | } -------------------------------------------------------------------------------- /conflict/vercel-kit/serve.js: -------------------------------------------------------------------------------- 1 | // Code for running on Vercel. Not part of Conflict server or Conflict build scripts. 2 | 3 | 4 | import DiscordInteractions from 'discord-interactions'; 5 | const { 6 | InteractionResponseType, 7 | InteractionType, 8 | verifyKey, 9 | } = DiscordInteractions; 10 | 11 | import dispatch from './dispatch.js'; 12 | 13 | export default async function (request, response) { 14 | if (request.method === "POST") { 15 | const signature = request.headers["x-signature-ed25519"]; 16 | const timestamp = request.headers["x-signature-timestamp"]; 17 | const isDiscord = request.headers["user-agent"].toLowerCase().includes('discord'); 18 | 19 | const rawBody = JSON.stringify(request.body); 20 | 21 | const isValidRequest = verifyKey( 22 | rawBody, 23 | signature, 24 | timestamp, 25 | process.env.PUBLIC_KEY 26 | ); 27 | 28 | if (!isValidRequest) { 29 | console.error("Invalid Request"); 30 | return response.status(401).send({ error: "Bad request signature" }); 31 | } 32 | 33 | const message = request.body; 34 | 35 | if (message.type === InteractionType.PING) { 36 | console.log("Handling Discord ping request"); 37 | response.send({ 38 | type: InteractionResponseType.PONG, 39 | }); 40 | 41 | } else { 42 | const output = await dispatch(message); 43 | if (output && output.___status) { 44 | response.status(output.status).send(output.payload); 45 | } else { 46 | response.status(200).send(output); 47 | } 48 | } 49 | } else { 50 | response.status(405).send({ error: "Method not allowed" }); 51 | } 52 | }; -------------------------------------------------------------------------------- /conflict/vercel.js: -------------------------------------------------------------------------------- 1 | // Compile .conflict/build to public/api/index.js for Vercel deployment 2 | 3 | import stump from './logger.js'; 4 | import fs from 'fs'; 5 | import path from 'path'; 6 | import { exec } from 'child_process'; 7 | import { dirname } from "esm-dirname"; 8 | import Discord from 'discord.js'; 9 | import { REST } from '@discordjs/rest'; 10 | import typesv9 from 'discord-api-types/v9'; 11 | import Command from './commands.js'; 12 | import View from './renderer/view.js'; 13 | const { Routes } = typesv9; 14 | const __dirname = dirname(import.meta); 15 | 16 | global.__ConflictFilePrefix = process.platform === 'win32' ? 'file://' : ''; 17 | global.__ConflictViewParser = View.createElement; 18 | const selfVersion = JSON.parse(fs.readFileSync('package.json', 'utf8')).version; 19 | 20 | if (fs.existsSync(path.join(process.cwd(), '.vercel'))) { 21 | fs.rmSync(path.join(process.cwd(), '.vercel'), { recursive: true, force: true }); 22 | // Remove public folder if it exists 23 | } 24 | 25 | let rest; 26 | if (process.env.TOKEN) rest = new REST({ version: '9' }).setToken(process.env.TOKEN); 27 | 28 | fs.mkdirSync(path.join(process.cwd(), '.vercel')); 29 | fs.mkdirSync(path.join(process.cwd(), '.vercel', 'output')); 30 | fs.writeFileSync(path.join(process.cwd(), '.vercel', 'output', 'config.json'), fs.readFileSync(path.join(__dirname, 'vercel-kit', 'config.json'), 'utf8'), 'utf8'); 31 | 32 | fs.mkdirSync(path.join(process.cwd(), '.vercel', 'output', 'static')); 33 | fs.writeFileSync(path.join(process.cwd(), '.vercel', 'output', 'static', 'index.html'), fs.readFileSync(path.join(__dirname, 'vercel-kit', 'index.html'), 'utf8'), 'utf8'); 34 | 35 | fs.mkdirSync(path.join(process.cwd(), '.vercel', 'output', 'functions')); 36 | fs.mkdirSync(path.join(process.cwd(), '.vercel', 'output', 'functions', 'discord.func')); 37 | fs.writeFileSync(path.join(process.cwd(), '.vercel', 'output', 'functions', 'discord.func', '.vc-config.json'), fs.readFileSync(path.join(__dirname, 'vercel-kit', '.vc-config.json'), 'utf8'), 'utf8'); 38 | fs.writeFileSync(path.join(process.cwd(), '.vercel', 'output', 'functions', 'discord.func', 'serve.js'), fs.readFileSync(path.join(__dirname, 'vercel-kit', 'serve.js'), 'utf8'), 'utf8'); 39 | fs.writeFileSync(path.join(process.cwd(), '.vercel', 'output', 'functions', 'discord.func', 'dispatch.js'), fs.readFileSync(path.join(__dirname, 'vercel-kit', 'dispatch.js'), 'utf8'), 'utf8'); 40 | fs.writeFileSync(path.join(process.cwd(), '.vercel', 'output', 'functions', 'discord.func', 'package.json'), fs.readFileSync(path.join(__dirname, 'vercel-kit', 'package.json'), 'utf8'), 'utf8'); 41 | fs.writeFileSync(path.join(process.cwd(), '.vercel', 'output', 'functions', 'discord.func', 'conflict.config.js'), fs.readFileSync(path.join('.', 'conflict.config.js'), 'utf8'), 'utf8'); 42 | 43 | stump.info('Generated core files'); 44 | 45 | export const finish = () => { 46 | return new Promise((resolve, reject) => { 47 | stump.info('Installing modules to function runtime'); 48 | 49 | exec('cp -r ./node_modules ./.vercel/output/functions/discord.func/node_modules && cp -r ./.conflict/build ./.vercel/output/functions/discord.func/bundle && npm i @conflict/beta@' + selfVersion, { cwd: process.cwd() }, async (error, stdout, stderr) => { 50 | if (error) return stump.error(error); 51 | stump.info('Installed modules'); 52 | 53 | let commands = {}; 54 | 55 | let commandsPath = path.join(process.cwd(), '.vercel', 'output', 'functions', 'discord.func', 'bundle', 'commands'); 56 | 57 | if (fs.existsSync(commandsPath)) { 58 | let files = fs.readdirSync(commandsPath); 59 | let filePaths = files.map(file => path.join(commandsPath, file)); 60 | let i = 0; 61 | for (const file of filePaths) { 62 | const fileName = files[i]; 63 | if (file.endsWith('.js') || file.endsWith('.cjs') || file.endsWith('.mjs')) { 64 | let fileData = await import(global.__ConflictFilePrefix + file + '?r=' + Math.random().toString(36).substring(3)); 65 | if (fileData.default && fileData.default.constructor.name === 'Command') { 66 | let command = fileData.default; 67 | command._filePath = fileName; 68 | commands[command.name] = command; 69 | } 70 | } 71 | i++; 72 | 73 | } 74 | } 75 | 76 | let publicCommands = []; 77 | let guildCommands = {}; 78 | let guilds = []; 79 | 80 | for (const command in commands) { 81 | let commandData = commands[command]; 82 | if (commandData.testing && commandData.testing.guildId) { 83 | if (!guildCommands[commandData.testing.guildId]) guildCommands[commandData.testing.guildId] = []; 84 | guilds.push(commandData.testing.guildId); 85 | guildCommands[commandData.testing.guildId].push({ 86 | name: commandData.name, 87 | description: commandData.description, 88 | options: commandData.options, 89 | name_localizations: commandData.name_localizations, 90 | description_localizations: commandData.description_localizations 91 | }); 92 | } else { 93 | publicCommands.push({ 94 | name: commandData.name, 95 | description: commandData.description, 96 | options: commandData.options, 97 | name_localizations: commandData.name_localizations, 98 | description_localizations: commandData.description_localizations 99 | }); 100 | } 101 | } 102 | 103 | fs.writeFileSync(path.join(process.cwd(), '.vercel', 'output', 'functions', 'discord.func', 'commands.json'), JSON.stringify({ guildCommands, publicCommands, all: commands }, null, 4), 'utf8'); 104 | 105 | if (process.env.TOKEN && process.env.APPLICATION_ID) { 106 | stump.info('Registering commands to Discord'); 107 | 108 | for (const guild in guildCommands) { 109 | const commandsForGuild = guildCommands[guild]; 110 | await rest.put(Routes.applicationGuildCommands(process.env.APPLICATION_ID, guild), { body: commandsForGuild }) 111 | } 112 | 113 | await rest.put(Routes.applicationCommands(process.env.APPLICATION_ID), { body: publicCommands }); 114 | 115 | stump.info(fs.readdirSync(process.cwd())); 116 | } else stump.warn('Did not register commands to Discord'); 117 | 118 | stump.success('Finished build process'); 119 | 120 | resolve(); 121 | }); 122 | }) 123 | } -------------------------------------------------------------------------------- /create-conflict-app/bot/commands/demo.js: -------------------------------------------------------------------------------- 1 | import { ActionRow } from "conflict/components"; 2 | 3 | export const name = "counter"; 4 | export const description = "Play with a counter"; 5 | export const options = [ 6 | { 7 | "type": 3, 8 | "name": "text", 9 | "description": "Text to display", 10 | } 11 | ]; 12 | 13 | export default function demo ({ count, text }) { 14 | return ( 15 | 16 | Hello! Current count: {count}. Custom text: {text}. 17 | 18 | 23 | 24 | 25 | ); 26 | } 27 | 28 | export function getProps ({ args, interaction }) { 29 | return { 30 | count: 0, 31 | text: args[0] || 'Hello' 32 | }; 33 | } -------------------------------------------------------------------------------- /create-conflict-app/bot/commands/help.js: -------------------------------------------------------------------------------- 1 | import Command from 'conflict/commands'; 2 | import { Button, StatelessButton, ActionRow, Embed, SelectMenu, SelectOption, TextInput, Modal } from 'conflict/components'; 3 | import View from 'conflict/View'; 4 | 5 | export default new Command({ 6 | name: 'chelp', 7 | description: 'Get help', 8 | options: [], 9 | execute: async (command, options, utils) => { 10 | const buttonView = ( 11 | 12 | 13 | Hello, world! 14 | Welcome to **Conflict**. 15 | 16 | 17 | 18 | { 19 | event.respond({ content: 'You clicked me!', ephemeral: true }); 20 | }} variant="green">Green Button 21 | { 22 | event.respond({ content: 'You clicked me!', ephemeral: true }); 23 | }} variant="green">Green Button 24 | 25 | 26 | 27 | 42 | 43 | 44 | 45 | { 46 | event.respond({ content: `You selected ${JSON.stringify(event.values)}`, ephemeral: true }); 47 | }}> 48 | 49 | This the first option. 50 | This is the second option. 51 | 52 | 53 | 54 | 55 | ); 56 | command.respond(buttonView); 57 | } 58 | }).localize({ 59 | 'es-ES': { 60 | name: 'ayuda', 61 | description: 'Obtener ayuda' 62 | } 63 | }); -------------------------------------------------------------------------------- /create-conflict-app/bot/commands/slides.js: -------------------------------------------------------------------------------- 1 | import Command from 'conflict/commands'; 2 | import { EmbedSlideshow, Button, StatelessButton, ActionRow, Embed, SelectMenu, SelectOption, TextInput, Modal } from 'conflict/components'; 3 | import View from 'conflict/View'; 4 | 5 | export default new Command({ 6 | name: 'slides', 7 | description: 'Run slides', 8 | options: [ 9 | { 10 | "type": 3, 11 | "name": "text", 12 | "description": "Text to display", 13 | } 14 | ], 15 | execute: async (command, options, utils) => { 16 | // command.respond( 17 | // 19 | // hi 20 | // 21 | // ]} /> 22 | // ) 23 | command.respond( 24 | 25 | Hello 26 | 27 | 30 | 31 | {/*`⏪ ⬅️ 🔵 ➡️ ⏩ 32 | ⏪ ⬅️ ⏺️ ➡️ ⏩ 33 | ⏪ ⬅️ 🟦 ➡️ ⏩ 34 | ⏪ ⬅️ ⏹️ ➡️ ⏩ 35 | ⏪ ⬅️ ⏺️ ➡️ ⏩`*/} 36 | 37 | ) 38 | } 39 | }); -------------------------------------------------------------------------------- /create-conflict-app/bot/commands/welcome.js: -------------------------------------------------------------------------------- 1 | import Command from 'conflict/commands'; 2 | import welcome from '../views/welcome.js'; 3 | 4 | export default new Command({ 5 | name: 'welcome', 6 | description: 'Display the Welcome view', 7 | options: [], 8 | execute: async (command, options, utils) => { 9 | command.respond(welcome()); 10 | } 11 | }); -------------------------------------------------------------------------------- /create-conflict-app/bot/events/interval.js: -------------------------------------------------------------------------------- 1 | import { onInterval } from 'conflict/events'; 2 | 3 | onInterval(120000, _ => { 4 | console.log("This runs every 2 minutes.") 5 | }); -------------------------------------------------------------------------------- /create-conflict-app/bot/events/message.js: -------------------------------------------------------------------------------- 1 | import { onMessageCreate } from 'conflict/events'; 2 | import Welcome from '../views/welcome.js'; 3 | 4 | onMessageCreate(message => { 5 | if (message.content === "hello") message.channel.send(":wave: Hey there!"); 6 | if (message.content === "welcome") message.channel.view(Welcome()); 7 | }); -------------------------------------------------------------------------------- /create-conflict-app/bot/views/welcome.js: -------------------------------------------------------------------------------- 1 | import { View } from 'conflict/view'; 2 | import { deleteAfter } from 'conflict/hooks'; 3 | 4 | let phrases = [ 5 | "Discord Bots", 6 | "Slash Commands", 7 | "Message Components", 8 | "User Interfaces", 9 | "Scalable Bots", 10 | "User Experiences", 11 | "Message Embeds" 12 | ]; 13 | 14 | export default function () { 15 | return new View( 16 | 17 | 18 | 19 | Conflict.js 20 | 21 | Build better **{phrases[Math.floor((Math.random() * 1000)) % 6]}**. 22 | 23 | 24 | 25 | 26 | ).useHooks(deleteAfter(5000)); 27 | } -------------------------------------------------------------------------------- /create-conflict-app/conflict.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | intents: ["GUILDS", "GUILD_MESSAGES"], 3 | plugins: [import("conflict/global-ratelimit-plugin")], 4 | runtimes: ["@conflict/vercel"] 5 | }; -------------------------------------------------------------------------------- /create-conflict-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-conflict-app", 3 | "version": "0.1.3", 4 | "description": "A brand new project created with create-conflict-app", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "conflict build", 8 | "dev": "conflict dev", 9 | "start": "conflict" 10 | }, 11 | "author": "Conflict.js", 12 | "type": "module", 13 | "devDependencies": { 14 | "@swc/cli": "^0.1.61", 15 | "@swc/core": "^1.3.35" 16 | }, 17 | "dependencies": { 18 | "@conflict/vercel": "^0.1.0", 19 | "chokidar": "^3.5.3", 20 | "conflict": "^0.1.5" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /create-conflict-app/vercel.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "ENABLE_VC_BUILD": "1" 4 | } 5 | } -------------------------------------------------------------------------------- /create-conflict-app/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@conflict/vercel@^0.1.0": 6 | version "0.1.0" 7 | resolved "https://registry.npmjs.org/@conflict/vercel/-/vercel-0.1.0.tgz" 8 | integrity sha512-hnKrg6zVzh+A8uCpgp2PuAeC/e1DiVlu9+2Df8Y01DR5bL0FSsSITDiv6j8I7MMHiUC+2H76O6NTDv6QQfktVw== 9 | 10 | "@mole-inc/bin-wrapper@^8.0.1": 11 | version "8.0.1" 12 | resolved "https://registry.npmjs.org/@mole-inc/bin-wrapper/-/bin-wrapper-8.0.1.tgz" 13 | integrity sha512-sTGoeZnjI8N4KS+sW2AN95gDBErhAguvkw/tWdCjeM8bvxpz5lqrnd0vOJABA1A+Ic3zED7PYoLP/RANLgVotA== 14 | dependencies: 15 | bin-check "^4.1.0" 16 | bin-version-check "^5.0.0" 17 | content-disposition "^0.5.4" 18 | ext-name "^5.0.0" 19 | file-type "^17.1.6" 20 | filenamify "^5.0.2" 21 | got "^11.8.5" 22 | os-filter-obj "^2.0.0" 23 | 24 | "@nodelib/fs.scandir@2.1.5": 25 | version "2.1.5" 26 | resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz" 27 | integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== 28 | dependencies: 29 | "@nodelib/fs.stat" "2.0.5" 30 | run-parallel "^1.1.9" 31 | 32 | "@nodelib/fs.stat@^2.0.2", "@nodelib/fs.stat@2.0.5": 33 | version "2.0.5" 34 | resolved "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz" 35 | integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== 36 | 37 | "@nodelib/fs.walk@^1.2.3": 38 | version "1.2.8" 39 | resolved "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz" 40 | integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== 41 | dependencies: 42 | "@nodelib/fs.scandir" "2.1.5" 43 | fastq "^1.6.0" 44 | 45 | "@sindresorhus/is@^4.0.0": 46 | version "4.6.0" 47 | resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz" 48 | integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== 49 | 50 | "@swc/cli@^0.1.61": 51 | version "0.1.61" 52 | resolved "https://registry.npmjs.org/@swc/cli/-/cli-0.1.61.tgz" 53 | integrity sha512-HeYMJ+8gKfJzM9xgcZqTpAHJYAJVGSljBSmWRUx2B6UiGraLsLjEcqxITwi6/t6Af+QboBMiQX5Wwll89oPK7g== 54 | dependencies: 55 | "@mole-inc/bin-wrapper" "^8.0.1" 56 | commander "^7.1.0" 57 | fast-glob "^3.2.5" 58 | semver "^7.3.8" 59 | slash "3.0.0" 60 | source-map "^0.7.3" 61 | 62 | "@swc/core-darwin-arm64@1.3.35": 63 | version "1.3.35" 64 | resolved "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.35.tgz" 65 | integrity sha512-zQUFkHx4gZpu0uo2IspvPnKsz8bsdXd5bC33xwjtoAI1cpLerDyqo4v2zIahEp+FdKZjyVsLHtfJiQiA1Qka3A== 66 | 67 | "@swc/core@^1.2.66", "@swc/core@^1.3.35": 68 | version "1.3.35" 69 | resolved "https://registry.npmjs.org/@swc/core/-/core-1.3.35.tgz" 70 | integrity sha512-KmiBin0XSVzJhzX19zTiCqmLslZ40Cl7zqskJcTDeIrRhfgKdiAsxzYUanJgMJIRjYtl9Kcg1V/Ip2o2wL8v3w== 71 | optionalDependencies: 72 | "@swc/core-darwin-arm64" "1.3.35" 73 | "@swc/core-darwin-x64" "1.3.35" 74 | "@swc/core-linux-arm-gnueabihf" "1.3.35" 75 | "@swc/core-linux-arm64-gnu" "1.3.35" 76 | "@swc/core-linux-arm64-musl" "1.3.35" 77 | "@swc/core-linux-x64-gnu" "1.3.35" 78 | "@swc/core-linux-x64-musl" "1.3.35" 79 | "@swc/core-win32-arm64-msvc" "1.3.35" 80 | "@swc/core-win32-ia32-msvc" "1.3.35" 81 | "@swc/core-win32-x64-msvc" "1.3.35" 82 | 83 | "@szmarczak/http-timer@^4.0.5": 84 | version "4.0.6" 85 | resolved "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz" 86 | integrity sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w== 87 | dependencies: 88 | defer-to-connect "^2.0.0" 89 | 90 | "@tokenizer/token@^0.3.0": 91 | version "0.3.0" 92 | resolved "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz" 93 | integrity sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A== 94 | 95 | "@types/cacheable-request@^6.0.1": 96 | version "6.0.3" 97 | resolved "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz" 98 | integrity sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw== 99 | dependencies: 100 | "@types/http-cache-semantics" "*" 101 | "@types/keyv" "^3.1.4" 102 | "@types/node" "*" 103 | "@types/responselike" "^1.0.0" 104 | 105 | "@types/http-cache-semantics@*": 106 | version "4.0.1" 107 | resolved "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz" 108 | integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ== 109 | 110 | "@types/keyv@^3.1.4": 111 | version "3.1.4" 112 | resolved "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz" 113 | integrity sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg== 114 | dependencies: 115 | "@types/node" "*" 116 | 117 | "@types/node@*": 118 | version "18.13.0" 119 | resolved "https://registry.npmjs.org/@types/node/-/node-18.13.0.tgz" 120 | integrity sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg== 121 | 122 | "@types/responselike@^1.0.0": 123 | version "1.0.0" 124 | resolved "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz" 125 | integrity sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA== 126 | dependencies: 127 | "@types/node" "*" 128 | 129 | anymatch@~3.1.2: 130 | version "3.1.3" 131 | resolved "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz" 132 | integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== 133 | dependencies: 134 | normalize-path "^3.0.0" 135 | picomatch "^2.0.4" 136 | 137 | arch@^2.1.0: 138 | version "2.2.0" 139 | resolved "https://registry.npmjs.org/arch/-/arch-2.2.0.tgz" 140 | integrity sha512-Of/R0wqp83cgHozfIYLbBMnej79U/SVGOOyuB3VVFv1NRM/PSFMK12x9KVtiYzJqmnU5WR2qp0Z5rHb7sWGnFQ== 141 | 142 | bin-check@^4.1.0: 143 | version "4.1.0" 144 | resolved "https://registry.npmjs.org/bin-check/-/bin-check-4.1.0.tgz" 145 | integrity sha512-b6weQyEUKsDGFlACWSIOfveEnImkJyK/FGW6FAG42loyoquvjdtOIqO6yBFzHyqyVVhNgNkQxxx09SFLK28YnA== 146 | dependencies: 147 | execa "^0.7.0" 148 | executable "^4.1.0" 149 | 150 | bin-version-check@^5.0.0: 151 | version "5.0.0" 152 | resolved "https://registry.npmjs.org/bin-version-check/-/bin-version-check-5.0.0.tgz" 153 | integrity sha512-Q3FMQnS5eZmrBGqmDXLs4dbAn/f+52voP6ykJYmweSA60t6DyH4UTSwZhtbK5UH+LBoWvDljILUQMLRUtsynsA== 154 | dependencies: 155 | bin-version "^6.0.0" 156 | semver "^7.3.5" 157 | semver-truncate "^2.0.0" 158 | 159 | bin-version@^6.0.0: 160 | version "6.0.0" 161 | resolved "https://registry.npmjs.org/bin-version/-/bin-version-6.0.0.tgz" 162 | integrity sha512-nk5wEsP4RiKjG+vF+uG8lFsEn4d7Y6FVDamzzftSunXOoOcOOkzcWdKVlGgFFwlUQCj63SgnUkLLGF8v7lufhw== 163 | dependencies: 164 | execa "^5.0.0" 165 | find-versions "^5.0.0" 166 | 167 | binary-extensions@^2.0.0: 168 | version "2.2.0" 169 | resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" 170 | integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== 171 | 172 | braces@^3.0.2, braces@~3.0.2: 173 | version "3.0.2" 174 | resolved "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz" 175 | integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== 176 | dependencies: 177 | fill-range "^7.0.1" 178 | 179 | cacheable-lookup@^5.0.3: 180 | version "5.0.4" 181 | resolved "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz" 182 | integrity sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA== 183 | 184 | cacheable-request@^7.0.2: 185 | version "7.0.2" 186 | resolved "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.2.tgz" 187 | integrity sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew== 188 | dependencies: 189 | clone-response "^1.0.2" 190 | get-stream "^5.1.0" 191 | http-cache-semantics "^4.0.0" 192 | keyv "^4.0.0" 193 | lowercase-keys "^2.0.0" 194 | normalize-url "^6.0.1" 195 | responselike "^2.0.0" 196 | 197 | chokidar@^3.5.1, chokidar@^3.5.3: 198 | version "3.5.3" 199 | resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz" 200 | integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== 201 | dependencies: 202 | anymatch "~3.1.2" 203 | braces "~3.0.2" 204 | glob-parent "~5.1.2" 205 | is-binary-path "~2.1.0" 206 | is-glob "~4.0.1" 207 | normalize-path "~3.0.0" 208 | readdirp "~3.6.0" 209 | optionalDependencies: 210 | fsevents "~2.3.2" 211 | 212 | clone-response@^1.0.2: 213 | version "1.0.3" 214 | resolved "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz" 215 | integrity sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA== 216 | dependencies: 217 | mimic-response "^1.0.0" 218 | 219 | commander@^7.1.0: 220 | version "7.2.0" 221 | resolved "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz" 222 | integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== 223 | 224 | conflict@^0.1.5: 225 | version "0.1.5" 226 | resolved "file:../conflict" 227 | dependencies: 228 | "@discordjs/rest" "^0.3.0" 229 | deep-equal "^2.2.0" 230 | discord-api-types "^0.29.0" 231 | discord-interactions "^3.2.0" 232 | discord.js "^13.8.1" 233 | esm-dirname "^0.1.1" 234 | node-fetch "^3.3.0" 235 | stump.js "^1.1.0" 236 | 237 | content-disposition@^0.5.4: 238 | version "0.5.4" 239 | resolved "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz" 240 | integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ== 241 | dependencies: 242 | safe-buffer "5.2.1" 243 | 244 | cross-spawn@^5.0.1: 245 | version "5.1.0" 246 | resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz" 247 | integrity sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A== 248 | dependencies: 249 | lru-cache "^4.0.1" 250 | shebang-command "^1.2.0" 251 | which "^1.2.9" 252 | 253 | cross-spawn@^7.0.3: 254 | version "7.0.3" 255 | resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz" 256 | integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== 257 | dependencies: 258 | path-key "^3.1.0" 259 | shebang-command "^2.0.0" 260 | which "^2.0.1" 261 | 262 | decompress-response@^6.0.0: 263 | version "6.0.0" 264 | resolved "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz" 265 | integrity sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ== 266 | dependencies: 267 | mimic-response "^3.1.0" 268 | 269 | defer-to-connect@^2.0.0: 270 | version "2.0.1" 271 | resolved "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz" 272 | integrity sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg== 273 | 274 | end-of-stream@^1.1.0: 275 | version "1.4.4" 276 | resolved "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz" 277 | integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== 278 | dependencies: 279 | once "^1.4.0" 280 | 281 | escape-string-regexp@^5.0.0: 282 | version "5.0.0" 283 | resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz" 284 | integrity sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw== 285 | 286 | execa@^0.7.0: 287 | version "0.7.0" 288 | resolved "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz" 289 | integrity sha512-RztN09XglpYI7aBBrJCPW95jEH7YF1UEPOoX9yDhUTPdp7mK+CQvnLTuD10BNXZ3byLTu2uehZ8EcKT/4CGiFw== 290 | dependencies: 291 | cross-spawn "^5.0.1" 292 | get-stream "^3.0.0" 293 | is-stream "^1.1.0" 294 | npm-run-path "^2.0.0" 295 | p-finally "^1.0.0" 296 | signal-exit "^3.0.0" 297 | strip-eof "^1.0.0" 298 | 299 | execa@^5.0.0: 300 | version "5.1.1" 301 | resolved "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz" 302 | integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== 303 | dependencies: 304 | cross-spawn "^7.0.3" 305 | get-stream "^6.0.0" 306 | human-signals "^2.1.0" 307 | is-stream "^2.0.0" 308 | merge-stream "^2.0.0" 309 | npm-run-path "^4.0.1" 310 | onetime "^5.1.2" 311 | signal-exit "^3.0.3" 312 | strip-final-newline "^2.0.0" 313 | 314 | executable@^4.1.0: 315 | version "4.1.1" 316 | resolved "https://registry.npmjs.org/executable/-/executable-4.1.1.tgz" 317 | integrity sha512-8iA79xD3uAch729dUG8xaaBBFGaEa0wdD2VkYLFHwlqosEj/jT66AzcreRDSgV7ehnNLBW2WR5jIXwGKjVdTLg== 318 | dependencies: 319 | pify "^2.2.0" 320 | 321 | ext-list@^2.0.0: 322 | version "2.2.2" 323 | resolved "https://registry.npmjs.org/ext-list/-/ext-list-2.2.2.tgz" 324 | integrity sha512-u+SQgsubraE6zItfVA0tBuCBhfU9ogSRnsvygI7wht9TS510oLkBRXBsqopeUG/GBOIQyKZO9wjTqIu/sf5zFA== 325 | dependencies: 326 | mime-db "^1.28.0" 327 | 328 | ext-name@^5.0.0: 329 | version "5.0.0" 330 | resolved "https://registry.npmjs.org/ext-name/-/ext-name-5.0.0.tgz" 331 | integrity sha512-yblEwXAbGv1VQDmow7s38W77hzAgJAO50ztBLMcUyUBfxv1HC+LGwtiEN+Co6LtlqT/5uwVOxsD4TNIilWhwdQ== 332 | dependencies: 333 | ext-list "^2.0.0" 334 | sort-keys-length "^1.0.0" 335 | 336 | fast-glob@^3.2.5: 337 | version "3.2.12" 338 | resolved "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz" 339 | integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== 340 | dependencies: 341 | "@nodelib/fs.stat" "^2.0.2" 342 | "@nodelib/fs.walk" "^1.2.3" 343 | glob-parent "^5.1.2" 344 | merge2 "^1.3.0" 345 | micromatch "^4.0.4" 346 | 347 | fastq@^1.6.0: 348 | version "1.15.0" 349 | resolved "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz" 350 | integrity sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw== 351 | dependencies: 352 | reusify "^1.0.4" 353 | 354 | file-type@^17.1.6: 355 | version "17.1.6" 356 | resolved "https://registry.npmjs.org/file-type/-/file-type-17.1.6.tgz" 357 | integrity sha512-hlDw5Ev+9e883s0pwUsuuYNu4tD7GgpUnOvykjv1Gya0ZIjuKumthDRua90VUn6/nlRKAjcxLUnHNTIUWwWIiw== 358 | dependencies: 359 | readable-web-to-node-stream "^3.0.2" 360 | strtok3 "^7.0.0-alpha.9" 361 | token-types "^5.0.0-alpha.2" 362 | 363 | filename-reserved-regex@^3.0.0: 364 | version "3.0.0" 365 | resolved "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-3.0.0.tgz" 366 | integrity sha512-hn4cQfU6GOT/7cFHXBqeBg2TbrMBgdD0kcjLhvSQYYwm3s4B6cjvBfb7nBALJLAXqmU5xajSa7X2NnUud/VCdw== 367 | 368 | filenamify@^5.0.2: 369 | version "5.1.1" 370 | resolved "https://registry.npmjs.org/filenamify/-/filenamify-5.1.1.tgz" 371 | integrity sha512-M45CbrJLGACfrPOkrTp3j2EcO9OBkKUYME0eiqOCa7i2poaklU0jhlIaMlr8ijLorT0uLAzrn3qXOp5684CkfA== 372 | dependencies: 373 | filename-reserved-regex "^3.0.0" 374 | strip-outer "^2.0.0" 375 | trim-repeated "^2.0.0" 376 | 377 | fill-range@^7.0.1: 378 | version "7.0.1" 379 | resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz" 380 | integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== 381 | dependencies: 382 | to-regex-range "^5.0.1" 383 | 384 | find-versions@^5.0.0: 385 | version "5.1.0" 386 | resolved "https://registry.npmjs.org/find-versions/-/find-versions-5.1.0.tgz" 387 | integrity sha512-+iwzCJ7C5v5KgcBuueqVoNiHVoQpwiUK5XFLjf0affFTep+Wcw93tPvmb8tqujDNmzhBDPddnWV/qgWSXgq+Hg== 388 | dependencies: 389 | semver-regex "^4.0.5" 390 | 391 | fsevents@~2.3.2: 392 | version "2.3.2" 393 | resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz" 394 | integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== 395 | 396 | get-stream@^3.0.0: 397 | version "3.0.0" 398 | resolved "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz" 399 | integrity sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ== 400 | 401 | get-stream@^5.1.0: 402 | version "5.2.0" 403 | resolved "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz" 404 | integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== 405 | dependencies: 406 | pump "^3.0.0" 407 | 408 | get-stream@^6.0.0: 409 | version "6.0.1" 410 | resolved "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz" 411 | integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== 412 | 413 | glob-parent@^5.1.2, glob-parent@~5.1.2: 414 | version "5.1.2" 415 | resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz" 416 | integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== 417 | dependencies: 418 | is-glob "^4.0.1" 419 | 420 | got@^11.8.5: 421 | version "11.8.6" 422 | resolved "https://registry.npmjs.org/got/-/got-11.8.6.tgz" 423 | integrity sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g== 424 | dependencies: 425 | "@sindresorhus/is" "^4.0.0" 426 | "@szmarczak/http-timer" "^4.0.5" 427 | "@types/cacheable-request" "^6.0.1" 428 | "@types/responselike" "^1.0.0" 429 | cacheable-lookup "^5.0.3" 430 | cacheable-request "^7.0.2" 431 | decompress-response "^6.0.0" 432 | http2-wrapper "^1.0.0-beta.5.2" 433 | lowercase-keys "^2.0.0" 434 | p-cancelable "^2.0.0" 435 | responselike "^2.0.0" 436 | 437 | http-cache-semantics@^4.0.0: 438 | version "4.1.1" 439 | resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz" 440 | integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== 441 | 442 | http2-wrapper@^1.0.0-beta.5.2: 443 | version "1.0.3" 444 | resolved "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz" 445 | integrity sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg== 446 | dependencies: 447 | quick-lru "^5.1.1" 448 | resolve-alpn "^1.0.0" 449 | 450 | human-signals@^2.1.0: 451 | version "2.1.0" 452 | resolved "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz" 453 | integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== 454 | 455 | ieee754@^1.2.1: 456 | version "1.2.1" 457 | resolved "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz" 458 | integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== 459 | 460 | inherits@^2.0.3: 461 | version "2.0.4" 462 | resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" 463 | integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== 464 | 465 | is-binary-path@~2.1.0: 466 | version "2.1.0" 467 | resolved "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz" 468 | integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== 469 | dependencies: 470 | binary-extensions "^2.0.0" 471 | 472 | is-extglob@^2.1.1: 473 | version "2.1.1" 474 | resolved "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz" 475 | integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== 476 | 477 | is-glob@^4.0.1, is-glob@~4.0.1: 478 | version "4.0.3" 479 | resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz" 480 | integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== 481 | dependencies: 482 | is-extglob "^2.1.1" 483 | 484 | is-number@^7.0.0: 485 | version "7.0.0" 486 | resolved "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz" 487 | integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== 488 | 489 | is-plain-obj@^1.0.0: 490 | version "1.1.0" 491 | resolved "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz" 492 | integrity sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg== 493 | 494 | is-stream@^1.1.0: 495 | version "1.1.0" 496 | resolved "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz" 497 | integrity sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ== 498 | 499 | is-stream@^2.0.0: 500 | version "2.0.1" 501 | resolved "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz" 502 | integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== 503 | 504 | isexe@^2.0.0: 505 | version "2.0.0" 506 | resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz" 507 | integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== 508 | 509 | json-buffer@3.0.1: 510 | version "3.0.1" 511 | resolved "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz" 512 | integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== 513 | 514 | keyv@^4.0.0: 515 | version "4.5.2" 516 | resolved "https://registry.npmjs.org/keyv/-/keyv-4.5.2.tgz" 517 | integrity sha512-5MHbFaKn8cNSmVW7BYnijeAVlE4cYA/SVkifVgrh7yotnfhKmjuXpDKjrABLnT0SfHWV21P8ow07OGfRrNDg8g== 518 | dependencies: 519 | json-buffer "3.0.1" 520 | 521 | lowercase-keys@^2.0.0: 522 | version "2.0.0" 523 | resolved "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz" 524 | integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== 525 | 526 | lru-cache@^4.0.1: 527 | version "4.1.5" 528 | resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz" 529 | integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== 530 | dependencies: 531 | pseudomap "^1.0.2" 532 | yallist "^2.1.2" 533 | 534 | lru-cache@^6.0.0: 535 | version "6.0.0" 536 | resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz" 537 | integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== 538 | dependencies: 539 | yallist "^4.0.0" 540 | 541 | merge-stream@^2.0.0: 542 | version "2.0.0" 543 | resolved "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz" 544 | integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== 545 | 546 | merge2@^1.3.0: 547 | version "1.4.1" 548 | resolved "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz" 549 | integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== 550 | 551 | micromatch@^4.0.4: 552 | version "4.0.5" 553 | resolved "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz" 554 | integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== 555 | dependencies: 556 | braces "^3.0.2" 557 | picomatch "^2.3.1" 558 | 559 | mime-db@^1.28.0: 560 | version "1.52.0" 561 | resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz" 562 | integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== 563 | 564 | mimic-fn@^2.1.0: 565 | version "2.1.0" 566 | resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz" 567 | integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== 568 | 569 | mimic-response@^1.0.0: 570 | version "1.0.1" 571 | resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz" 572 | integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== 573 | 574 | mimic-response@^3.1.0: 575 | version "3.1.0" 576 | resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz" 577 | integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== 578 | 579 | normalize-path@^3.0.0, normalize-path@~3.0.0: 580 | version "3.0.0" 581 | resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" 582 | integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== 583 | 584 | normalize-url@^6.0.1: 585 | version "6.1.0" 586 | resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz" 587 | integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A== 588 | 589 | npm-run-path@^2.0.0: 590 | version "2.0.2" 591 | resolved "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz" 592 | integrity sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw== 593 | dependencies: 594 | path-key "^2.0.0" 595 | 596 | npm-run-path@^4.0.1: 597 | version "4.0.1" 598 | resolved "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz" 599 | integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== 600 | dependencies: 601 | path-key "^3.0.0" 602 | 603 | once@^1.3.1, once@^1.4.0: 604 | version "1.4.0" 605 | resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz" 606 | integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== 607 | dependencies: 608 | wrappy "1" 609 | 610 | onetime@^5.1.2: 611 | version "5.1.2" 612 | resolved "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz" 613 | integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== 614 | dependencies: 615 | mimic-fn "^2.1.0" 616 | 617 | os-filter-obj@^2.0.0: 618 | version "2.0.0" 619 | resolved "https://registry.npmjs.org/os-filter-obj/-/os-filter-obj-2.0.0.tgz" 620 | integrity sha512-uksVLsqG3pVdzzPvmAHpBK0wKxYItuzZr7SziusRPoz67tGV8rL1szZ6IdeUrbqLjGDwApBtN29eEE3IqGHOjg== 621 | dependencies: 622 | arch "^2.1.0" 623 | 624 | p-cancelable@^2.0.0: 625 | version "2.1.1" 626 | resolved "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz" 627 | integrity sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg== 628 | 629 | p-finally@^1.0.0: 630 | version "1.0.0" 631 | resolved "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz" 632 | integrity sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow== 633 | 634 | path-key@^2.0.0: 635 | version "2.0.1" 636 | resolved "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz" 637 | integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw== 638 | 639 | path-key@^3.0.0, path-key@^3.1.0: 640 | version "3.1.1" 641 | resolved "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz" 642 | integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== 643 | 644 | peek-readable@^5.0.0: 645 | version "5.0.0" 646 | resolved "https://registry.npmjs.org/peek-readable/-/peek-readable-5.0.0.tgz" 647 | integrity sha512-YtCKvLUOvwtMGmrniQPdO7MwPjgkFBtFIrmfSbYmYuq3tKDV/mcfAhBth1+C3ru7uXIZasc/pHnb+YDYNkkj4A== 648 | 649 | picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: 650 | version "2.3.1" 651 | resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz" 652 | integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== 653 | 654 | pify@^2.2.0: 655 | version "2.3.0" 656 | resolved "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz" 657 | integrity sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog== 658 | 659 | pseudomap@^1.0.2: 660 | version "1.0.2" 661 | resolved "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz" 662 | integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ== 663 | 664 | pump@^3.0.0: 665 | version "3.0.0" 666 | resolved "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz" 667 | integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== 668 | dependencies: 669 | end-of-stream "^1.1.0" 670 | once "^1.3.1" 671 | 672 | queue-microtask@^1.2.2: 673 | version "1.2.3" 674 | resolved "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz" 675 | integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== 676 | 677 | quick-lru@^5.1.1: 678 | version "5.1.1" 679 | resolved "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz" 680 | integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== 681 | 682 | readable-stream@^3.6.0: 683 | version "3.6.0" 684 | resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz" 685 | integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== 686 | dependencies: 687 | inherits "^2.0.3" 688 | string_decoder "^1.1.1" 689 | util-deprecate "^1.0.1" 690 | 691 | readable-web-to-node-stream@^3.0.2: 692 | version "3.0.2" 693 | resolved "https://registry.npmjs.org/readable-web-to-node-stream/-/readable-web-to-node-stream-3.0.2.tgz" 694 | integrity sha512-ePeK6cc1EcKLEhJFt/AebMCLL+GgSKhuygrZ/GLaKZYEecIgIECf4UaUuaByiGtzckwR4ain9VzUh95T1exYGw== 695 | dependencies: 696 | readable-stream "^3.6.0" 697 | 698 | readdirp@~3.6.0: 699 | version "3.6.0" 700 | resolved "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz" 701 | integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== 702 | dependencies: 703 | picomatch "^2.2.1" 704 | 705 | resolve-alpn@^1.0.0: 706 | version "1.2.1" 707 | resolved "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz" 708 | integrity sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g== 709 | 710 | responselike@^2.0.0: 711 | version "2.0.1" 712 | resolved "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz" 713 | integrity sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw== 714 | dependencies: 715 | lowercase-keys "^2.0.0" 716 | 717 | reusify@^1.0.4: 718 | version "1.0.4" 719 | resolved "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz" 720 | integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== 721 | 722 | run-parallel@^1.1.9: 723 | version "1.2.0" 724 | resolved "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz" 725 | integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== 726 | dependencies: 727 | queue-microtask "^1.2.2" 728 | 729 | safe-buffer@~5.2.0, safe-buffer@5.2.1: 730 | version "5.2.1" 731 | resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" 732 | integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== 733 | 734 | semver-regex@^4.0.5: 735 | version "4.0.5" 736 | resolved "https://registry.npmjs.org/semver-regex/-/semver-regex-4.0.5.tgz" 737 | integrity sha512-hunMQrEy1T6Jr2uEVjrAIqjwWcQTgOAcIM52C8MY1EZSD3DDNft04XzvYKPqjED65bNVVko0YI38nYeEHCX3yw== 738 | 739 | semver-truncate@^2.0.0: 740 | version "2.0.0" 741 | resolved "https://registry.npmjs.org/semver-truncate/-/semver-truncate-2.0.0.tgz" 742 | integrity sha512-Rh266MLDYNeML5h90ttdMwfXe1+Nc4LAWd9X1KdJe8pPHP4kFmvLZALtsMNHNdvTyQygbEC0D59sIz47DIaq8w== 743 | dependencies: 744 | semver "^6.0.0" 745 | 746 | semver@^6.0.0: 747 | version "6.3.0" 748 | resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz" 749 | integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== 750 | 751 | semver@^7.3.5, semver@^7.3.8: 752 | version "7.3.8" 753 | resolved "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz" 754 | integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== 755 | dependencies: 756 | lru-cache "^6.0.0" 757 | 758 | shebang-command@^1.2.0: 759 | version "1.2.0" 760 | resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz" 761 | integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg== 762 | dependencies: 763 | shebang-regex "^1.0.0" 764 | 765 | shebang-command@^2.0.0: 766 | version "2.0.0" 767 | resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz" 768 | integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== 769 | dependencies: 770 | shebang-regex "^3.0.0" 771 | 772 | shebang-regex@^1.0.0: 773 | version "1.0.0" 774 | resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz" 775 | integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ== 776 | 777 | shebang-regex@^3.0.0: 778 | version "3.0.0" 779 | resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz" 780 | integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== 781 | 782 | signal-exit@^3.0.0, signal-exit@^3.0.3: 783 | version "3.0.7" 784 | resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz" 785 | integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== 786 | 787 | slash@3.0.0: 788 | version "3.0.0" 789 | resolved "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz" 790 | integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== 791 | 792 | sort-keys-length@^1.0.0: 793 | version "1.0.1" 794 | resolved "https://registry.npmjs.org/sort-keys-length/-/sort-keys-length-1.0.1.tgz" 795 | integrity sha512-GRbEOUqCxemTAk/b32F2xa8wDTs+Z1QHOkbhJDQTvv/6G3ZkbJ+frYWsTcc7cBB3Fu4wy4XlLCuNtJuMn7Gsvw== 796 | dependencies: 797 | sort-keys "^1.0.0" 798 | 799 | sort-keys@^1.0.0: 800 | version "1.1.2" 801 | resolved "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz" 802 | integrity sha512-vzn8aSqKgytVik0iwdBEi+zevbTYZogewTUM6dtpmGwEcdzbub/TX4bCzRhebDCRC3QzXgJsLRKB2V/Oof7HXg== 803 | dependencies: 804 | is-plain-obj "^1.0.0" 805 | 806 | source-map@^0.7.3: 807 | version "0.7.4" 808 | resolved "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz" 809 | integrity sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA== 810 | 811 | string_decoder@^1.1.1: 812 | version "1.3.0" 813 | resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz" 814 | integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== 815 | dependencies: 816 | safe-buffer "~5.2.0" 817 | 818 | strip-eof@^1.0.0: 819 | version "1.0.0" 820 | resolved "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz" 821 | integrity sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q== 822 | 823 | strip-final-newline@^2.0.0: 824 | version "2.0.0" 825 | resolved "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz" 826 | integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== 827 | 828 | strip-outer@^2.0.0: 829 | version "2.0.0" 830 | resolved "https://registry.npmjs.org/strip-outer/-/strip-outer-2.0.0.tgz" 831 | integrity sha512-A21Xsm1XzUkK0qK1ZrytDUvqsQWict2Cykhvi0fBQntGG5JSprESasEyV1EZ/4CiR5WB5KjzLTrP/bO37B0wPg== 832 | 833 | strtok3@^7.0.0-alpha.9: 834 | version "7.0.0" 835 | resolved "https://registry.npmjs.org/strtok3/-/strtok3-7.0.0.tgz" 836 | integrity sha512-pQ+V+nYQdC5H3Q7qBZAz/MO6lwGhoC2gOAjuouGf/VO0m7vQRh8QNMl2Uf6SwAtzZ9bOw3UIeBukEGNJl5dtXQ== 837 | dependencies: 838 | "@tokenizer/token" "^0.3.0" 839 | peek-readable "^5.0.0" 840 | 841 | to-regex-range@^5.0.1: 842 | version "5.0.1" 843 | resolved "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz" 844 | integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== 845 | dependencies: 846 | is-number "^7.0.0" 847 | 848 | token-types@^5.0.0-alpha.2: 849 | version "5.0.1" 850 | resolved "https://registry.npmjs.org/token-types/-/token-types-5.0.1.tgz" 851 | integrity sha512-Y2fmSnZjQdDb9W4w4r1tswlMHylzWIeOKpx0aZH9BgGtACHhrk3OkT52AzwcuqTRBZtvvnTjDBh8eynMulu8Vg== 852 | dependencies: 853 | "@tokenizer/token" "^0.3.0" 854 | ieee754 "^1.2.1" 855 | 856 | trim-repeated@^2.0.0: 857 | version "2.0.0" 858 | resolved "https://registry.npmjs.org/trim-repeated/-/trim-repeated-2.0.0.tgz" 859 | integrity sha512-QUHBFTJGdOwmp0tbOG505xAgOp/YliZP/6UgafFXYZ26WT1bvQmSMJUvkeVSASuJJHbqsFbynTvkd5W8RBTipg== 860 | dependencies: 861 | escape-string-regexp "^5.0.0" 862 | 863 | util-deprecate@^1.0.1: 864 | version "1.0.2" 865 | resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" 866 | integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== 867 | 868 | which@^1.2.9: 869 | version "1.3.1" 870 | resolved "https://registry.npmjs.org/which/-/which-1.3.1.tgz" 871 | integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== 872 | dependencies: 873 | isexe "^2.0.0" 874 | 875 | which@^2.0.1: 876 | version "2.0.2" 877 | resolved "https://registry.npmjs.org/which/-/which-2.0.2.tgz" 878 | integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== 879 | dependencies: 880 | isexe "^2.0.0" 881 | 882 | wrappy@1: 883 | version "1.0.2" 884 | resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" 885 | integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== 886 | 887 | yallist@^2.1.2: 888 | version "2.1.2" 889 | resolved "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz" 890 | integrity sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A== 891 | 892 | yallist@^4.0.0: 893 | version "4.0.0" 894 | resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz" 895 | integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== 896 | --------------------------------------------------------------------------------