mirror of
https://github.com/discordjs/discord.js.git
synced 2026-06-10 08:37:04 +00:00
Compare commits
871 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 92775abb49 | |||
| 02b257e1fc | |||
| 5dd25ac1f1 | |||
| 6fb0691a2b | |||
| 961346dcaa | |||
| 8984bf332c | |||
| ac2ad0dd23 | |||
| ea55b0efbd | |||
| 36435934c7 | |||
| 75b01e0a4a | |||
| 95369b0a89 | |||
| b39d959cdf | |||
| fba3508079 | |||
| 2aae20085b | |||
| 516e6556a0 | |||
| e24c1e55a0 | |||
| 7457985e60 | |||
| 95605863c7 | |||
| ac1f5f32e2 | |||
| 774b4d4694 | |||
| 38c85dc076 | |||
| 46b7628d59 | |||
| ebaaa65741 | |||
| b88498271c | |||
| 95de09f389 | |||
| ce6cb626dc | |||
| d7bcf9564f | |||
| 032d6613f7 | |||
| 9059eb13a2 | |||
| d365eb95e2 | |||
| 3dab19a3bc | |||
| 07f4a20f77 | |||
| b476473a2c | |||
| 8f1216d9a5 | |||
| aa5df43c50 | |||
| f0a9a1353f | |||
| 77e83fb85a | |||
| a52beaa78d | |||
| 21ad5668ba | |||
| e7eee3410a | |||
| 7ff9ac2bcc | |||
| 9e05caec0d | |||
| 3fba72107b | |||
| 7933d755be | |||
| af33b2b5bb | |||
| 5b8f882a0f | |||
| 272555d9ae | |||
| 350c893ead | |||
| 47d71d32f3 | |||
| 0833500d60 | |||
| 7da00cf0fe | |||
| 68879777d8 | |||
| e75dd2638c | |||
| 48f84c6178 | |||
| de6042a4d7 | |||
| 3e39861534 | |||
| 6a53255ed5 | |||
| 8f645267a9 | |||
| 00627ecde4 | |||
| 537b372b42 | |||
| a5a269b940 | |||
| 91a7d4f80e | |||
| 3f52ba27c9 | |||
| 78673139ca | |||
| fd564176ff | |||
| d7bf40cab0 | |||
| 894115758c | |||
| c6aa16277a | |||
| 8c0685fa9a | |||
| 9d1d7c5162 | |||
| 0d417b6432 | |||
| 4255dcd3ca | |||
| 84fe65ec78 | |||
| cd404fc7d3 | |||
| 9b45294814 | |||
| c405d67e09 | |||
| 4278a37e3c | |||
| b7204f33b9 | |||
| f192d16b5b | |||
| e57fe71387 | |||
| dd623891e2 | |||
| e44853ee6d | |||
| 8f9923976f | |||
| dbaaa8dc93 | |||
| 85fae72b7b | |||
| 8d3018e190 | |||
| 01d032abee | |||
| 9682adb9fe | |||
| f7a542f12b | |||
| 4be7a1bfd1 | |||
| d42b589528 | |||
| 9309b702eb | |||
| bbc9df0b0d | |||
| 8f04fae4c0 | |||
| 9888cef486 | |||
| 47a164bd36 | |||
| a5dfa08777 | |||
| 5563af0da5 | |||
| 9bef99c75c | |||
| 7fe032c785 | |||
| a6ae66e184 | |||
| 57acd4f41a | |||
| 594836b1bf | |||
| 978cf9d87f | |||
| 465ff074e1 | |||
| 9bdf670a14 | |||
| 31bdc4fb1e | |||
| 580550e5e2 | |||
| bc09da9a35 | |||
| 818649b94f | |||
| 73cb34ed37 | |||
| f185d892c7 | |||
| b9caa2ee5d | |||
| ab4707f9b4 | |||
| b7f582b7f0 | |||
| 3a790e74f4 | |||
| c7b4cf3d3f | |||
| f3286402fb | |||
| 17bee8084e | |||
| e4cac2d575 | |||
| 752e12116e | |||
| 9d694d2b67 | |||
| e1bda864f7 | |||
| bfc9de438a | |||
| 7fea0a3937 | |||
| 6bfad00229 | |||
| 910f47240d | |||
| 943767dc83 | |||
| 6dfe160c52 | |||
| bd113eef06 | |||
| dc7b07022c | |||
| e87c9bb9a0 | |||
| 799054df00 | |||
| 7a8c8f7453 | |||
| 2c6b804fc9 | |||
| 7b870d13de | |||
| 28169c0f55 | |||
| 5bd258a557 | |||
| 3b7d5e869b | |||
| 48e7fad1c9 | |||
| 4a252380d9 | |||
| bcab8805af | |||
| db9d5b8110 | |||
| bf3c283998 | |||
| 9f0db9d0d8 | |||
| 600541b476 | |||
| bc8924b255 | |||
| 7db345942f | |||
| 027f95b7b2 | |||
| 0741be6a95 | |||
| cb22f8efea | |||
| 69900f3652 | |||
| 302b1da9df | |||
| 4022c8167f | |||
| ab6c99f155 | |||
| cda16105f3 | |||
| 9ce3b93827 | |||
| 2762c1d439 | |||
| 28c9f94e11 | |||
| 4598f90183 | |||
| e666c4edf7 | |||
| 3f7244da8d | |||
| 0454674ceb | |||
| 7475f734ac | |||
| f23c07a08e | |||
| b1a25bd176 | |||
| 906672e538 | |||
| 89145b121d | |||
| 1155c482f1 | |||
| 9c915d1e0a | |||
| 4d2bb891a9 | |||
| 0c32e590a8 | |||
| 0b908f5bce | |||
| 5a9c42061f | |||
| 16fbbde35c | |||
| 5af09d335c | |||
| a3b9b0f1b4 | |||
| efd1d0c738 | |||
| 7f9ea762ed | |||
| fced6983d9 | |||
| 59a5862f2d | |||
| 432c5ccc82 | |||
| b6abe7dbab | |||
| 5d067d505c | |||
| 64d89b3748 | |||
| 44b34154e8 | |||
| 1be0270796 | |||
| 7ff2568cfc | |||
| 09dee3d46a | |||
| 68acf37fd4 | |||
| 2682c07bd8 | |||
| a172fffd76 | |||
| 513fdabd19 | |||
| 02324fbecb | |||
| d97ce2e181 | |||
| ec0a5cdfbc | |||
| 27652b94af | |||
| 44efcf3f52 | |||
| 1cbd1bda46 | |||
| 7d27667afc | |||
| ae17a89191 | |||
| b8a5669fda | |||
| 168256469e | |||
| 43f1c952c3 | |||
| df9cab3864 | |||
| 8d9a778320 | |||
| 552d603782 | |||
| aee547d28e | |||
| a725147f17 | |||
| 28ad224207 | |||
| 1298fefa2f | |||
| 5f5ee18543 | |||
| e8c1c228d0 | |||
| ff3148ddd4 | |||
| 91b1fa8359 | |||
| a638b6369a | |||
| e42f6b1024 | |||
| 1da8ec7ddd | |||
| 892e162229 | |||
| 7f09da5d35 | |||
| 631626a3f9 | |||
| b18aaa8711 | |||
| 8c3ae2fd90 | |||
| dbda589088 | |||
| 0adfc0fe95 | |||
| f02cc27735 | |||
| cde3bcb3bd | |||
| bce3cd2b8b | |||
| c70dfa83fb | |||
| 4df7968630 | |||
| 39f969c777 | |||
| 4f41a86dd3 | |||
| 680ac48e3d | |||
| 49d525109f | |||
| 907c1ed9f9 | |||
| 0860d5210b | |||
| d249aa10cc | |||
| 56352220af | |||
| 60a1ba3088 | |||
| 4f130a1a58 | |||
| ee64253f0b | |||
| 6d7e989e3b | |||
| c6688b94e6 | |||
| 090234cef2 | |||
| 817bea5a70 | |||
| 52adb3d8b2 | |||
| 1e2e940b98 | |||
| 78e0d88f55 | |||
| 897cbfec77 | |||
| d9ae732bfd | |||
| df934eccaf | |||
| 3541b0a88f | |||
| f6c95de85d | |||
| 5d06be6333 | |||
| 144638e746 | |||
| 001460acc0 | |||
| 727f3de45b | |||
| fe58105d04 | |||
| 0b4f4a559c | |||
| b44a3770d9 | |||
| 1dba048d2e | |||
| ba3d104619 | |||
| 9f1475f358 | |||
| a57d6b723a | |||
| 6ea2a523d6 | |||
| 3462bbc8d4 | |||
| 93771ce6d0 | |||
| a91fcd5cab | |||
| 309bc5da1f | |||
| 6bc7220ded | |||
| ae862c38ff | |||
| ac7e1a052c | |||
| a959cd339c | |||
| 83b33c5046 | |||
| 948a18dfe2 | |||
| ef0f38930f | |||
| 22062f1f86 | |||
| 2c056b6418 | |||
| 4d6c604322 | |||
| 6a1a36813f | |||
| 6faa409e96 | |||
| b356ccf1e5 | |||
| 9ea9623de0 | |||
| 7ae12ab325 | |||
| 135ab02104 | |||
| 6293f28ad9 | |||
| 8a1bfe559d | |||
| 50c6fa3433 | |||
| f2708dd26f | |||
| 3718841c7c | |||
| 19d976748c | |||
| f944dce5c7 | |||
| e47f3dda94 | |||
| 947f61e436 | |||
| b1772089d1 | |||
| 642d768cdc | |||
| b22bda74b8 | |||
| e5057a5b6a | |||
| 0988b47fcd | |||
| ee6ccc5e17 | |||
| 870f3590fe | |||
| 6ddc7a813c | |||
| 3a031c65e7 | |||
| d215e283e6 | |||
| 8507e34995 | |||
| 0a005cbd16 | |||
| 48762c642c | |||
| 2d6068010b | |||
| 8038903c3e | |||
| 7ba37a3511 | |||
| ccf513a2fc | |||
| 8d094cdfb1 | |||
| 64b0e6bc84 | |||
| fe3fdb7d6a | |||
| 6d7e649bb1 | |||
| 7b2d76429f | |||
| baff7a094c | |||
| d6f5df39fc | |||
| cdb74a75f2 | |||
| 253789f398 | |||
| 5500b87968 | |||
| 8683f45816 | |||
| 7892e62604 | |||
| 48444a5444 | |||
| 328f3c4ae8 | |||
| f9a553a7f0 | |||
| d0a76f3f38 | |||
| e370ccf806 | |||
| f713f52841 | |||
| d8b1ef47cd | |||
| fa085c18cd | |||
| dfbe44143a | |||
| d029227a8e | |||
| b065bf799c | |||
| 0edf838474 | |||
| f38aff7523 | |||
| c8be80abd7 | |||
| 84a4755f53 | |||
| 2ed4ff7a55 | |||
| 1ff7bce01d | |||
| ebfe3e2e62 | |||
| 355dd462d3 | |||
| 0916cd71a5 | |||
| 576a7f2488 | |||
| d710713c09 | |||
| 3a16f5147d | |||
| 50dcececfb | |||
| 51a399d558 | |||
| 1deefbd8cd | |||
| 725e0a8cfe | |||
| ce0d9a7272 | |||
| 2a1799f20f | |||
| ddd3ea9727 | |||
| c96ecec24c | |||
| c308a2a01c | |||
| 3fded1d7af | |||
| fb2392a1ed | |||
| 8fed1b1d80 | |||
| dd40b870d5 | |||
| 357502e520 | |||
| cf34f253cb | |||
| 59cc02de89 | |||
| 6ad970e311 | |||
| df456589ab | |||
| 89569d9249 | |||
| 6986752578 | |||
| c294a0fac4 | |||
| 85fd82818f | |||
| 6f2caffd32 | |||
| 00505d099a | |||
| 115850ad04 | |||
| be7ed4077a | |||
| 601987ed01 | |||
| cbb74e11d1 | |||
| 196fdfc31b | |||
| f255094760 | |||
| d66ac3fc39 | |||
| 4e53aa4a23 | |||
| 73b61b6b4e | |||
| ac7c543dfe | |||
| 985681f1f6 | |||
| 3e39d54933 | |||
| 30e6bbd7a4 | |||
| c7df7a4744 | |||
| c5ab580562 | |||
| 24f3a36701 | |||
| 2007ed7cef | |||
| 65350348a8 | |||
| f8b2629b18 | |||
| 3051ae7061 | |||
| d2cba74c13 | |||
| 8d5d90e222 | |||
| 82ab92ca2a | |||
| ad8b4c7698 | |||
| bd50e3c0a5 | |||
| 4400eb1b5c | |||
| 4f4ec3146b | |||
| 97e16e6eed | |||
| fb55b6dc60 | |||
| ed818d6e7f | |||
| 75ff9fb096 | |||
| c2e3d2b8ca | |||
| f012655e53 | |||
| fd64fb0a82 | |||
| 00be14b5d1 | |||
| dcba580d89 | |||
| 392133f927 | |||
| dbe978d926 | |||
| 871c60c8dd | |||
| e0c987c1b2 | |||
| 24df1bc621 | |||
| a52b46fab4 | |||
| 3c5a227ea0 | |||
| cc563f77c5 | |||
| 2dfd01d56e | |||
| 863495cda0 | |||
| 3e3a411a42 | |||
| 976584a5bc | |||
| 6f9f103821 | |||
| 21c4654705 | |||
| 839ff5ce43 | |||
| 3ac191a812 | |||
| 3d3766f129 | |||
| 0ac66287d7 | |||
| 329839318d | |||
| be7b0fb5ca | |||
| 18299970bd | |||
| 4d4258b4e2 | |||
| a5fd46d306 | |||
| 45f897fbe7 | |||
| 159233059e | |||
| 46e89f56c7 | |||
| 55630a38ac | |||
| bca3cc7915 | |||
| 22cdf0b258 | |||
| c37191b582 | |||
| 562e3b119e | |||
| 19f8f8e122 | |||
| 238a6824ef | |||
| ab92be4209 | |||
| 79ea663afe | |||
| 614c488f96 | |||
| 9dc8265a93 | |||
| 2b7dd39f3e | |||
| e7ef73ffdc | |||
| e7e6355cfe | |||
| 13db0db298 | |||
| 4fff20d66e | |||
| 1c7a5abd4e | |||
| fdfd41dd8c | |||
| e42178181d | |||
| 89bbf5d6be | |||
| 3b594fd86d | |||
| eba3bd0291 | |||
| ce198ef005 | |||
| 1ea53c18ac | |||
| 62856ff57a | |||
| 0224138dc9 | |||
| 0d44a801f2 | |||
| 603e231494 | |||
| b2950b2997 | |||
| 7ada70f856 | |||
| 75e3ee86fb | |||
| a2f8680514 | |||
| c02d7808c1 | |||
| 50af835774 | |||
| f2ccef1ce5 | |||
| b8db4c4f4b | |||
| 53d767ec04 | |||
| 1963bcfa10 | |||
| fe95e31f48 | |||
| 8085f5bde3 | |||
| d656c68e75 | |||
| c0ef815f9d | |||
| 0a648e80c9 | |||
| 420e8527c2 | |||
| 1624daa730 | |||
| 2b7f88ae3a | |||
| c2163a29c0 | |||
| 36245941b3 | |||
| da31ae589a | |||
| 461e5b337e | |||
| 4f713a3f6d | |||
| b05e18871a | |||
| 1049a1d70a | |||
| 810059200c | |||
| 34f71eaba1 | |||
| 95db1d611b | |||
| 41dab17ec0 | |||
| d956780d18 | |||
| b95058399e | |||
| 952cfc0456 | |||
| dc939c48ee | |||
| babf550459 | |||
| a102490b08 | |||
| c63c39eb1f | |||
| 422fffdbfb | |||
| 45d61f24db | |||
| f49f1ab3c8 | |||
| cd2642c293 | |||
| 7ae7a9aa34 | |||
| 0d53afe3ce | |||
| 3cd91a19aa | |||
| 849b8df2da | |||
| bbf0b0683a | |||
| 620d8cbf15 | |||
| c8ba6b5265 | |||
| 1577075e52 | |||
| d7026f80a4 | |||
| ba51df918c | |||
| 9c9768f772 | |||
| fe3f6c7d20 | |||
| 0e4612d7ab | |||
| 0f4566dd23 | |||
| 7f864578e0 | |||
| 4e8ac47f27 | |||
| 644061e881 | |||
| ea89b7f783 | |||
| d9fa561dd9 | |||
| 2cd1104d3d | |||
| 5133096a12 | |||
| 02f39e00bf | |||
| e59dd9b12a | |||
| 1672465768 | |||
| 293f416e15 | |||
| 6cd0561014 | |||
| 2bd7d9dc24 | |||
| 2ac679c169 | |||
| 627bbaf4ec | |||
| 636a095377 | |||
| c88feaa554 | |||
| 05def5b3f2 | |||
| 0128a88e25 | |||
| 1c8e773700 | |||
| afa2f33dfd | |||
| cf413bd472 | |||
| 883743e137 | |||
| bd15cc68ce | |||
| d913d04f44 | |||
| bf89d678d8 | |||
| f8bf945f9d | |||
| e6054c6ace | |||
| 00e3708e78 | |||
| a073010197 | |||
| 750f2a2b1b | |||
| 6b5f4fa773 | |||
| 6bc2750f3d | |||
| 7cf7c0e794 | |||
| b4dcd657cf | |||
| 95e3e3e3dc | |||
| 8d64435def | |||
| b9506d01ab | |||
| 2194632b7d | |||
| e912c72a95 | |||
| eff8caed85 | |||
| 16eb38a99e | |||
| ad7ffcecb4 | |||
| 0a5ce3dcd5 | |||
| 8bee117445 | |||
| 0f9741bb14 | |||
| fae03042cb | |||
| bea1663052 | |||
| fe1d0bb595 | |||
| 68bf4c9052 | |||
| ab2c9d9a8d | |||
| d42cbd1c14 | |||
| 79ee493a39 | |||
| d2f0f4993e | |||
| 48595ddd19 | |||
| 3fa3b0238e | |||
| 9015bb8139 | |||
| 00ff2f71a4 | |||
| e1808804c9 | |||
| 43b1cc1d56 | |||
| e6572caf6c | |||
| e8874bae37 | |||
| 1732cc71bd | |||
| 81cdb09363 | |||
| e7882a38ee | |||
| 873f78b02a | |||
| afc4c93119 | |||
| db7dca65b2 | |||
| 0e5a1d2df7 | |||
| 3221bde4db | |||
| d4b693c4b0 | |||
| 71db8555fe | |||
| d73ebcdfd4 | |||
| 0ac0005697 | |||
| 0c38d47ef6 | |||
| 42fd07c5e7 | |||
| 2a1d516a28 | |||
| 68c1e122c0 | |||
| af333ef4cc | |||
| 963b22e6ce | |||
| 726c0e9ed5 | |||
| fb49ad7d93 | |||
| 2eca16dee6 | |||
| 46bcd3f5e3 | |||
| bc443df11d | |||
| ab17375248 | |||
| 9700f8577b | |||
| ad84aa84b8 | |||
| 82ac3d1c44 | |||
| a0418a2551 | |||
| ebfc2169d5 | |||
| 5125407151 | |||
| f95c588d87 | |||
| ba82722264 | |||
| 96ed5a1e52 | |||
| 1f5002ae41 | |||
| e48f2ffae3 | |||
| 3a0426482e | |||
| 90cf787759 | |||
| 249b6f919a | |||
| b47540d6eb | |||
| 2341c83638 | |||
| 68e1549361 | |||
| b436fac5c4 | |||
| 2d3116d505 | |||
| e9d7dfaee3 | |||
| 618d8bb957 | |||
| 1676a5e73f | |||
| 9322c0bbd7 | |||
| 619139f871 | |||
| a5517c2c3b | |||
| 68a21ee679 | |||
| ad338c6a29 | |||
| d18fcdbeea | |||
| ca251423ea | |||
| 6f466a401e | |||
| c42e303b7b | |||
| a2841f285c | |||
| 03caddb4b5 | |||
| f3e1760538 | |||
| b6842d3e07 | |||
| 907f4f4b27 | |||
| 283c99dee8 | |||
| b8283a8f29 | |||
| acc9c9bf12 | |||
| da42b422f0 | |||
| 00327a5776 | |||
| d437fd31cf | |||
| c947e172d6 | |||
| 7f4751e7c4 | |||
| c36cc3b551 | |||
| ce2cf382b3 | |||
| d1d13f5c85 | |||
| 685d7b622c | |||
| abc3f9e2fa | |||
| 71a4cd6a93 | |||
| bbf7be7dfa | |||
| 4de1f4ce99 | |||
| 533d49d7d4 | |||
| 0d2b504bde | |||
| 41ead870b7 | |||
| 30f5e2943a | |||
| ccffe09bca | |||
| 9956e43c8e | |||
| a3cd539eac | |||
| 9083893d79 | |||
| 197c416642 | |||
| 487f3ea4f4 | |||
| 0d93ce9fbd | |||
| dd71bb9e27 | |||
| 5f1e1b989b | |||
| 3ed5f4fb90 | |||
| 864126976f | |||
| d0f2029fa6 | |||
| 9251fd01ce | |||
| ecc35eecda | |||
| fc74912a8f | |||
| 3e243a25d3 | |||
| 6b189cf3af | |||
| 2842b97776 | |||
| 28fce9ea34 | |||
| afa5fa1758 | |||
| b7f20956d7 | |||
| 675ea93bc3 | |||
| 71dd084667 | |||
| 78edc3b371 | |||
| afde031267 | |||
| b6d1cb88cd | |||
| c247a3979b | |||
| db1435910d | |||
| bf78c441dd | |||
| 877eaab3c1 | |||
| d53aabefb0 | |||
| d48458b80f | |||
| 0e54d77025 | |||
| 3a8d4499d0 | |||
| 5619e97a39 | |||
| 78399a77ae | |||
| a15b8e56c7 | |||
| 30d011c7ac | |||
| cfc1f7f6ae | |||
| 040ea21b33 | |||
| ad66991f36 | |||
| b3a65a4ed6 | |||
| 2c55a65ddb | |||
| dcd57277cd | |||
| c5732efdb1 | |||
| 8fa3c24b12 | |||
| 3a2c449197 | |||
| 910b5a7ae6 | |||
| e8cc571d6a | |||
| f591542735 | |||
| 8e6427963b | |||
| 77346e3415 | |||
| 18dd59fe42 | |||
| 74c06f7a69 | |||
| 99af4a7d66 | |||
| 28b7b9f5d6 | |||
| b069f818d9 | |||
| 95748f3721 | |||
| 3bbd4f46d2 | |||
| 93e3106404 | |||
| 703ac05400 | |||
| afdb93b3d6 | |||
| 583906fe81 | |||
| 72340845e5 | |||
| 4386daf7a0 | |||
| 462adfbad3 | |||
| 204bdca555 | |||
| 81549e737e | |||
| 86f2836828 | |||
| 4d6cca72f4 | |||
| 27a0361afc | |||
| 8614d4b2a5 | |||
| f0dd0cabdf | |||
| e525e3b722 | |||
| 42bedbeee4 | |||
| 930f276828 | |||
| 13055f67d2 | |||
| 5e64d96272 | |||
| 25f25f5506 | |||
| 13e8a39f9f | |||
| 14fffb12af | |||
| ea80677a79 | |||
| d2a9f15e82 | |||
| ef679e87c4 | |||
| b5c200901b | |||
| 4e58de8cd6 | |||
| dd6c158250 | |||
| b541cfa89a | |||
| 7ec859d5a1 | |||
| 538df5f76b | |||
| a8ee8e8759 | |||
| 6889743d5e | |||
| df73f52454 | |||
| 159602b359 | |||
| beb44b7bfa | |||
| 91a05be386 | |||
| 0ec5d3e8d7 | |||
| 7b24127de5 | |||
| 41924df875 | |||
| 47ecc934f1 | |||
| 78b18de1e1 | |||
| 5c9865fc3c | |||
| e4641fe701 | |||
| fd34c935a2 | |||
| f49600af17 | |||
| 315ae22a7f | |||
| 9a57e7ab03 | |||
| 7144ead048 | |||
| 4e03c0b1a2 | |||
| bd187540d3 | |||
| e404361858 | |||
| 54045de5f1 | |||
| f0c719cf71 | |||
| 60587c8d74 | |||
| abde946864 | |||
| 0571958033 | |||
| 5132c9ade4 | |||
| 42f053eb9f | |||
| 701c0ca9c4 | |||
| 9fc5a752f8 | |||
| 3c64cfce4a | |||
| ca873ac36e | |||
| 9ff798a8bc | |||
| b84af789c6 | |||
| c7103f8930 | |||
| 8607a2449c | |||
| c8acc17d8e | |||
| b32a40086e | |||
| fd5c981d83 | |||
| 4b8f85d44a | |||
| 287c143c0e | |||
| 3283283b4d | |||
| 8d5949842c | |||
| 9173ded903 | |||
| b7c1b6ebe6 | |||
| c773ea4e49 | |||
| e66311bdf5 | |||
| 6f7bd987b8 | |||
| 580f260933 | |||
| 6772222955 | |||
| 5e97d309bf | |||
| 417fd32721 | |||
| 76a5bec944 | |||
| 3a9d8fb518 | |||
| 7c0476a7a8 | |||
| 1ce2ce93c3 | |||
| 0e53b4fc44 | |||
| 5a5316dc66 | |||
| 2732cbb402 | |||
| f554c88b97 | |||
| cd25848bdc | |||
| 46807bf1c1 | |||
| 89e3396af6 | |||
| c1171e6973 | |||
| 3306067d7b | |||
| 634a5bd737 | |||
| 151b98e0a2 | |||
| fdd4cfc7cc | |||
| 358c40c355 | |||
| 7fb39b6dc0 | |||
| 5d4cd1fc28 | |||
| e3173d1561 | |||
| 8b392f359a | |||
| dad570a4ec | |||
| 35c800cc8f | |||
| b052d59e46 | |||
| 6af71bf639 | |||
| 8726b23730 | |||
| ee2172c1d5 | |||
| 2c8747995a | |||
| be083b717e | |||
| fe9911acc2 | |||
| 9fab8ed381 | |||
| c93ed88daf | |||
| 9cfcb3452b | |||
| 59060b27e6 | |||
| 4f65378a57 | |||
| 799039588b | |||
| 79039f08a1 | |||
| 4e9a11d7a9 | |||
| 2c17eaed02 | |||
| 2c6cbb6675 | |||
| 3b3f5d831a | |||
| 44c1fc5b29 | |||
| 3a8f1ddbf9 | |||
| 042d7d1dbe | |||
| c5174b4d93 | |||
| 2d68849027 | |||
| 3caf1f74cc | |||
| 47f35a942c | |||
| 76ab439033 | |||
| b49870f12f | |||
| dba7a1d06a | |||
| 68435f0619 | |||
| 94f067cc51 | |||
| 345d0da72b | |||
| 8571723ec1 | |||
| 6f31130726 | |||
| b3d5197013 | |||
| 0164d3e7b5 | |||
| fc58a0d5cf | |||
| cffdb5f5f6 | |||
| 51a8feb562 | |||
| 8a8ba51c2b | |||
| c7b632d854 | |||
| 6a09ca76df | |||
| f51fecf726 | |||
| fee5cade9e | |||
| 3e1568f536 | |||
| 3e2124e0bd | |||
| 4184e51ec3 | |||
| 404829a19d | |||
| 69bffc6279 | |||
| 2a00064646 | |||
| 718f0b9543 |
+133
@@ -0,0 +1,133 @@
|
||||
{
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6
|
||||
},
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"rules": {
|
||||
"no-extra-parens": ["warn", "all", {
|
||||
"nestedBinaryExpressions": false
|
||||
}],
|
||||
"valid-jsdoc": ["error", {
|
||||
"requireReturn": false,
|
||||
"requireReturnDescription": false,
|
||||
"preferType": {
|
||||
"String": "string",
|
||||
"Number": "number",
|
||||
"Boolean": "boolean",
|
||||
"Function": "function",
|
||||
"object": "Object",
|
||||
"date": "Date",
|
||||
"error": "Error"
|
||||
},
|
||||
"prefer": {
|
||||
"return": "returns"
|
||||
}
|
||||
}],
|
||||
|
||||
"accessor-pairs": "warn",
|
||||
"array-callback-return": "error",
|
||||
"complexity": "warn",
|
||||
"consistent-return": "error",
|
||||
"curly": ["error", "multi-line", "consistent"],
|
||||
"dot-location": ["error", "property"],
|
||||
"dot-notation": "error",
|
||||
"eqeqeq": "error",
|
||||
"no-empty-function": "error",
|
||||
"no-floating-decimal": "error",
|
||||
"no-implied-eval": "error",
|
||||
"no-invalid-this": "error",
|
||||
"no-lone-blocks": "error",
|
||||
"no-multi-spaces": "error",
|
||||
"no-new-func": "error",
|
||||
"no-new-wrappers": "error",
|
||||
"no-new": "error",
|
||||
"no-octal-escape": "error",
|
||||
"no-return-assign": "error",
|
||||
"no-self-compare": "error",
|
||||
"no-sequences": "error",
|
||||
"no-throw-literal": "error",
|
||||
"no-unmodified-loop-condition": "error",
|
||||
"no-unused-expressions": "error",
|
||||
"no-useless-call": "error",
|
||||
"no-useless-concat": "error",
|
||||
"no-useless-escape": "error",
|
||||
"no-void": "error",
|
||||
"no-warning-comments": "warn",
|
||||
"wrap-iife": "error",
|
||||
"yoda": "error",
|
||||
|
||||
"no-label-var": "error",
|
||||
"no-shadow": "error",
|
||||
"no-undef-init": "error",
|
||||
|
||||
"callback-return": "error",
|
||||
"handle-callback-err": "error",
|
||||
"no-mixed-requires": "error",
|
||||
"no-new-require": "error",
|
||||
"no-path-concat": "error",
|
||||
"no-process-env": "error",
|
||||
|
||||
"array-bracket-spacing": "error",
|
||||
"block-spacing": "error",
|
||||
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
||||
"comma-dangle": ["error", "always-multiline"],
|
||||
"comma-spacing": "error",
|
||||
"comma-style": "error",
|
||||
"computed-property-spacing": "error",
|
||||
"consistent-this": ["error", "$this"],
|
||||
"eol-last": "error",
|
||||
"func-names": "error",
|
||||
"func-style": ["error", "declaration", { "allowArrowFunctions": true }],
|
||||
"indent": ["error", 2, { "SwitchCase": 1 }],
|
||||
"key-spacing": "error",
|
||||
"keyword-spacing": "error",
|
||||
"max-depth": "error",
|
||||
"max-len": ["error", 120, 2],
|
||||
"max-nested-callbacks": ["error", { "max": 4 }],
|
||||
"max-statements-per-line": ["error", { "max": 2 }],
|
||||
"new-cap": "error",
|
||||
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 3 }],
|
||||
"no-array-constructor": "error",
|
||||
"no-inline-comments": "error",
|
||||
"no-lonely-if": "error",
|
||||
"no-mixed-operators": "error",
|
||||
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
|
||||
"no-new-object": "error",
|
||||
"no-spaced-func": "error",
|
||||
"no-trailing-spaces": "error",
|
||||
"no-unneeded-ternary": "error",
|
||||
"no-whitespace-before-property": "error",
|
||||
"object-curly-spacing": ["error", "always"],
|
||||
"operator-assignment": "error",
|
||||
"operator-linebreak": ["error", "after"],
|
||||
"padded-blocks": ["error", "never"],
|
||||
"quote-props": ["error", "as-needed"],
|
||||
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
|
||||
"semi-spacing": "error",
|
||||
"semi": "error",
|
||||
"space-before-blocks": "error",
|
||||
"space-before-function-paren": ["error", "never"],
|
||||
"space-in-parens": "error",
|
||||
"space-infix-ops": "error",
|
||||
"space-unary-ops": "error",
|
||||
"spaced-comment": "error",
|
||||
"unicode-bom": "error",
|
||||
|
||||
"arrow-body-style": "error",
|
||||
"arrow-spacing": "error",
|
||||
"no-duplicate-imports": "error",
|
||||
"no-useless-computed-key": "error",
|
||||
"no-useless-constructor": "error",
|
||||
"prefer-arrow-callback": "error",
|
||||
"prefer-rest-params": "error",
|
||||
"prefer-spread": "error",
|
||||
"prefer-template": "error",
|
||||
"rest-spread-spacing": "error",
|
||||
"template-curly-spacing": "error",
|
||||
"yield-star-spacing": "error"
|
||||
}
|
||||
}
|
||||
+37
-38
@@ -1,39 +1,38 @@
|
||||
# Created by https://www.gitignore.io
|
||||
|
||||
hydrabot/config.json
|
||||
hydrabot/authority.json
|
||||
hydrabot/tokencache.json
|
||||
|
||||
.tmp/
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directory
|
||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
|
||||
node_modules
|
||||
test/auth.json
|
||||
examples/auth.json
|
||||
# Created by https://www.gitignore.io
|
||||
|
||||
.tmp/
|
||||
.vscode/
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
test/auth.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directory
|
||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
|
||||
node_modules
|
||||
test/auth.json
|
||||
examples/auth.json
|
||||
docs/_build
|
||||
@@ -1,7 +0,0 @@
|
||||
.vscode/
|
||||
docs/
|
||||
examples/
|
||||
web-dist/
|
||||
src/
|
||||
.travis.yml
|
||||
TODO.md
|
||||
+7
-13
@@ -1,13 +1,7 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- stable
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- indev
|
||||
before_install: npm install -g grunt-cli eslint
|
||||
install: npm install
|
||||
before_script: grunt --dev
|
||||
language: node_js
|
||||
node_js:
|
||||
- "6"
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
install: npm install
|
||||
|
||||
Vendored
-30
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"program": "./entrypoint.js",
|
||||
"stopOnEntry": false,
|
||||
"args": [],
|
||||
"cwd": ".",
|
||||
"runtimeExecutable": null,
|
||||
"runtimeArgs": [
|
||||
"--nolazy"
|
||||
],
|
||||
"env": {
|
||||
"NODE_ENV": "development"
|
||||
},
|
||||
"externalConsole": false,
|
||||
"sourceMaps": false,
|
||||
"outDir": null
|
||||
},
|
||||
{
|
||||
"name": "Attach",
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"port": 5858
|
||||
}
|
||||
]
|
||||
}
|
||||
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"editor.wrappingColumn": 0,
|
||||
"editor.formatOnType": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
}
|
||||
Vendored
-220
@@ -1,220 +0,0 @@
|
||||
// Available variables which can be used inside of strings.
|
||||
// ${workspaceRoot}: the root folder of the team
|
||||
// ${file}: the current opened file
|
||||
// ${fileBasename}: the current opened file's basename
|
||||
// ${fileDirname}: the current opened file's dirname
|
||||
// ${fileExtname}: the current opened file's extension
|
||||
// ${cwd}: the current working directory of the spawned process
|
||||
|
||||
// A task runner that calls the Typescript compiler (tsc) and
|
||||
// Compiles a HelloWorld.ts program
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command" : "babel",
|
||||
"isShellCommand": true,
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "watch",
|
||||
"suppressTaskName": true,
|
||||
"isBuildCommand": true,
|
||||
"isWatching": true,
|
||||
"args": [
|
||||
"src", "--out-dir", "lib", "-w", "--loose=all"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// A task runner that calls the Typescript compiler (tsc) and
|
||||
// compiles based on a tsconfig.json file that is present in
|
||||
// the root of the folder open in VSCode
|
||||
/*
|
||||
{
|
||||
"version": "0.1.0",
|
||||
|
||||
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
|
||||
"command": "tsc",
|
||||
|
||||
// The command is a shell script
|
||||
"isShellCommand": true,
|
||||
|
||||
// Show the output window only if unrecognized errors occur.
|
||||
"showOutput": "silent",
|
||||
|
||||
// Tell the tsc compiler to use the tsconfig.json from the open folder.
|
||||
"args": ["-p", "."],
|
||||
|
||||
// use the standard tsc problem matcher to find compile problems
|
||||
// in the output.
|
||||
"problemMatcher": "$tsc"
|
||||
}
|
||||
*/
|
||||
|
||||
// A task runner configuration for gulp. Gulp provides a less task
|
||||
// which compiles less to css.
|
||||
/*
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command": "gulp",
|
||||
"isShellCommand": true,
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "less",
|
||||
// Make this the default build command.
|
||||
"isBuildCommand": true,
|
||||
// Show the output window only if unrecognized errors occur.
|
||||
"showOutput": "silent",
|
||||
// Use the standard less compilation problem matcher.
|
||||
"problemMatcher": "$lessCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
// Uncomment the following section to use gulp in a watching mode that compiles a
|
||||
// less file. The gulp task prints "[hh:mm:ss] Starting 'clean-styles'" to the console
|
||||
// when existing css files get deleted and "[hh:mm:ss] Finished 'styles'" when the
|
||||
// overall less compilation has finished. When the clean pattern is detect internal less
|
||||
// problems are cleaned. When the finshed pattern is detected in the output less
|
||||
// problems are published.
|
||||
/*
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command": "gulp",
|
||||
"isShellCommand": true,
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "watch-less",
|
||||
// Make this the default build command.
|
||||
"isBuildCommand": true,
|
||||
// Show the output window only if unrecognized errors occur.
|
||||
"showOutput": "silent",
|
||||
// Task is running in watching mode.
|
||||
"isWatching": true,
|
||||
"problemMatcher": {
|
||||
// Use the standard less compilation problem matcher as the base.
|
||||
"base": "$lessCompile",
|
||||
// A regular expression signalling that a watched task begins executing (usually triggered through file watching).
|
||||
"watchedTaskBeginsRegExp": "^\\[\\d+:\\d+:\\d+\\] Starting 'clean-styles'\\.\\.\\.$",
|
||||
// A regular expression signalling that a watched tasks ends executing.
|
||||
"watchedTaskEndsRegExp": "^\\[\\d+:\\d+:\\d+\\] Finished 'styles' after \\d+"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
// Uncomment the following section to use jake to build a workspace
|
||||
// cloned from https://github.com/Microsoft/TypeScript.git
|
||||
/*
|
||||
{
|
||||
"version": "0.1.0",
|
||||
// Task runner is jake
|
||||
"command": "jake",
|
||||
// Need to be executed in shell / cmd
|
||||
"isShellCommand": true,
|
||||
"showOutput": "silent",
|
||||
"tasks": [
|
||||
{
|
||||
// TS build command is local.
|
||||
"taskName": "local",
|
||||
// Make this the default build command.
|
||||
"isBuildCommand": true,
|
||||
// Show the output window only if unrecognized errors occur.
|
||||
"showOutput": "silent",
|
||||
// Use the redefined Typescript output problem matcher.
|
||||
"problemMatcher": [
|
||||
"$tsc"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
// Uncomment the section below to use msbuild and generate problems
|
||||
// for csc, cpp, tsc and vb. The configuration assumes that msbuild
|
||||
// is available on the path and a solution file exists in the
|
||||
// workspace folder root.
|
||||
/*
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command": "msbuild",
|
||||
"args": [
|
||||
// Ask msbuild to generate full paths for file names.
|
||||
"/property:GenerateFullPaths=true"
|
||||
],
|
||||
"taskSelector": "/t:",
|
||||
"showOutput": "silent",
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "build",
|
||||
// Show the output window only if unrecognized errors occur.
|
||||
"showOutput": "silent",
|
||||
// Use the standard MS compiler pattern to detect errors, warnings
|
||||
// and infos in the output.
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
// Uncomment the following section to use msbuild which compiles Typescript
|
||||
// and less files.
|
||||
/*
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command": "msbuild",
|
||||
"args": [
|
||||
// Ask msbuild to generate full paths for file names.
|
||||
"/property:GenerateFullPaths=true"
|
||||
],
|
||||
"taskSelector": "/t:",
|
||||
"showOutput": "silent",
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "build",
|
||||
// Show the output window only if unrecognized errors occur.
|
||||
"showOutput": "silent",
|
||||
// Use the standard MS compiler pattern to detect errors, warnings
|
||||
// and infos in the output.
|
||||
"problemMatcher": [
|
||||
"$msCompile",
|
||||
"$lessCompile"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
// A task runner example that defines a problemMatcher inline instead of using
|
||||
// a predfined one.
|
||||
/*
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command": "tsc",
|
||||
"isShellCommand": true,
|
||||
"args": ["HelloWorld.ts"],
|
||||
"showOutput": "silent",
|
||||
"problemMatcher": {
|
||||
// The problem is owned by the typescript language service. Ensure that the problems
|
||||
// are merged with problems produced by Visual Studio's language service.
|
||||
"owner": "typescript",
|
||||
// The file name for reported problems is relative to the current working directory.
|
||||
"fileLocation": ["relative", "${cwd}"],
|
||||
// The actual pattern to match problems in the output.
|
||||
"pattern": {
|
||||
// The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'.
|
||||
"regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$",
|
||||
// The match group that denotes the file containing the problem.
|
||||
"file": 1,
|
||||
// The match group that denotes the problem location.
|
||||
"location": 2,
|
||||
// The match group that denotes the problem's severity. Can be omitted.
|
||||
"severity": 3,
|
||||
// The match group that denotes the problem code. Can be omitted.
|
||||
"code": 4,
|
||||
// The match group that denotes the problem's message.
|
||||
"message": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,14 @@
|
||||
# Contributing
|
||||
If you wish to contribute to the discord.js codebase or documentation, feel free to fork the repository and submit a
|
||||
pull request. We use ESLint to enforce a consistent coding style, so having that set up in your editor of choice
|
||||
is a great boon to your coding process.
|
||||
|
||||
## Setup
|
||||
To get ready to work on the codebase, please do the following:
|
||||
|
||||
1. Fork & clone the repository
|
||||
2. Run `npm install`, or `npm install --no-optional` if you're not working on voice
|
||||
3. Code your heart out!
|
||||
4. Run `npm test` to run ESLint
|
||||
5. Run `npm run docs` to build any documentation changes
|
||||
6. [Submit a pull request](https://github.com/hydrabolt/discord.js/compare)
|
||||
@@ -199,4 +199,3 @@
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
@@ -1,104 +1,57 @@
|
||||
<p align="center">
|
||||
<a href="https://hydrabolt.github.io/discord.js">
|
||||
<img alt="discord.js" src="http://hydrabolt.github.io/discord.js/res/logo.png" width="546">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
[](https://travis-ci.org/hydrabolt/discord.js) [](http://discordjs.readthedocs.org/en/latest/?badge=latest)
|
||||
|
||||
[](https://nodei.co/npm/discord.js/)
|
||||
|
||||
|
||||
discord.js is a node module used as a way of interfacing with [Discord](https://discordapp.com/). It is a very useful module for creating bots.
|
||||
|
||||
### Installation
|
||||
|
||||
**Requires node 0.12+**
|
||||
|
||||
`npm install --save discord.js`
|
||||
|
||||
---
|
||||
|
||||
### Example: ping-pong
|
||||
```js
|
||||
var Discord = require("discord.js");
|
||||
|
||||
var mybot = new Discord.Client();
|
||||
|
||||
mybot.on("message", function(message){
|
||||
if(message.content === "ping")
|
||||
mybot.reply(message, "pong");
|
||||
});
|
||||
|
||||
mybot.login("email", "password");
|
||||
```
|
||||
---
|
||||
|
||||
### Contributing
|
||||
|
||||
Feel free to contribute! Just clone the repo and edit the files in the **src folder, not the lib folder.**
|
||||
|
||||
Whenever you come to making a pull request, make sure it's to the *indev* branch and that you have built the lib files by running `grunt --dev`
|
||||
|
||||
---
|
||||
|
||||
### Related Projects
|
||||
|
||||
Here is a list of other Discord APIs:
|
||||
|
||||
#### Java:
|
||||
[Discord4J](https://github.com/nerd/Discord4J)
|
||||
|
||||
[JDiscord](https://github.com/NotGGhost/jDiscord)
|
||||
|
||||
[JDA](https://github.com/DV8FromTheWorld/JDA)
|
||||
|
||||
#### Go:
|
||||
[Go-Discord](https://github.com/gdraynz/go-discord)
|
||||
|
||||
[DiscordGo](https://github.com/bwmarrin/discordgo)
|
||||
|
||||
#### .NET:
|
||||
[Discord.Net](https://github.com/RogueException/Discord.Net)
|
||||
|
||||
[DiscordSharp](https://github.com/Luigifan/DiscordSharp)
|
||||
|
||||
#### NodeJS
|
||||
[discord.io](https://github.com/izy521/node-discord) (similar to discord.js but lower level)
|
||||
|
||||
[discordie](https://github.com/qeled/discordie)
|
||||
|
||||
#### PHP
|
||||
[DiscordPHP](https://github.com/teamreflex/DiscordPHP)
|
||||
|
||||
[Discord-PHP](https://github.com/Cleanse/discord-php)
|
||||
|
||||
#### Python
|
||||
[discord.py](https://github.com/Rapptz/discord.py)
|
||||
|
||||
#### Ruby
|
||||
[discordrb](https://github.com/meew0/discordrb)
|
||||
|
||||
---
|
||||
|
||||
### Links
|
||||
**[Documentation](http://discordjs.readthedocs.org/en/latest/)**
|
||||
|
||||
**[GitHub](https://github.com/discord-js/discord.js)**
|
||||
|
||||
**[Wiki](https://github.com/discord-js/discord.js/wiki)**
|
||||
|
||||
**[Website](http://discord-js.github.io/)**
|
||||
|
||||
**[NPM](http://npmjs.com/package/discord.js)**
|
||||
|
||||
---
|
||||
|
||||
### Contact
|
||||
|
||||
If you have an issue or want to know if a feature exists, [read the documentation](http://discordjs.readthedocs.org/en/latest/) before contacting me about any issues! If it's badly/wrongly implemented, let me know!
|
||||
|
||||
|
||||
If you would like to contact me, you can create an issue on the GitHub repo, e-mail me via the one available on my NPM profile.
|
||||
|
||||
Alternatively, you could just send a DM to **hydrabolt** in [**Discord API**](https://discord.gg/0SBTUU1wZTYd2XyW).
|
||||
<p align="center">
|
||||
<a href="https://hydrabolt.github.io/discord.js">
|
||||
<img alt="discord.js" src="http://i.imgur.com/sPOLh9y.png" width="546"><br />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
[](https://discord.gg/bRCvFy9)
|
||||
[](https://www.npmjs.com/package/discord.js)
|
||||
[](https://www.npmjs.com/package/discord.js)
|
||||
[](https://travis-ci.org/hydrabolt/discord.js)
|
||||
[](https://david-dm.org/hydrabolt/discord.js)
|
||||
|
||||
[](https://nodei.co/npm/discord.js/)
|
||||
|
||||
discord.js is a powerful node.js module that allows you to interact with the [Discord API](https://discordapp.com/developers/docs/intro).
|
||||
|
||||
## Installation
|
||||
**Node.js 6.0.0 or newer is required.**
|
||||
With voice support: `npm install --save discord.js --production`
|
||||
Without voice support: `npm install --save discord.js --production --no-optional`
|
||||
|
||||
By default, discord.js uses [opusscript](https://www.npmjs.com/package/opusscript) when playing audio over voice connections.
|
||||
If you're looking to play over multiple voice connections, it might be better to install [node-opus](https://www.npmjs.com/package/node-opus).
|
||||
discord.js will automatically prefer node-opus over opusscript.
|
||||
|
||||
## Example Usage
|
||||
```js
|
||||
const Discord = require('discord.js');
|
||||
const client = new Discord.Client();
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log('I am ready!');
|
||||
});
|
||||
|
||||
client.on('message', message => {
|
||||
if (message.content === 'ping') {
|
||||
message.reply('pong');
|
||||
}
|
||||
});
|
||||
|
||||
client.login('your token');
|
||||
```
|
||||
|
||||
## Links
|
||||
* [Website](http://hydrabolt.github.io/discord.js/)
|
||||
* [Discord.js Server](https://discord.gg/bRCvFy9)
|
||||
* [Discord API Server](https://discord.gg/rV4BwdK)
|
||||
* [Documentation](http://hydrabolt.github.io/discord.js/#!/docs/tag/master)
|
||||
* [Legacy Documentation](http://discordjs.readthedocs.io/en/8.1.0/docs_client.html)
|
||||
* [GitHub](https://github.com/hydrabolt/discord.js)
|
||||
* [NPM](https://www.npmjs.com/package/discord.js)
|
||||
* [Examples](https://github.com/hydrabolt/discord.js/tree/master/docs/custom/examples)
|
||||
* [Related Libraries](https://discordapi.com/unofficial/libs.html)
|
||||
|
||||
## Contact
|
||||
Before reporting an issue, please read the [documentation](http://hydrabolt.github.io/discord.js/#!/docs/tag/master).
|
||||
If you can't find help there, you can ask in the official [Discord.js Server](https://discord.gg/bRCvFy9).
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# Things yet to be implemented:
|
||||
|
||||
* Unbanning
|
||||
* Re-ordering of roles (no effect, just aesthetics)
|
||||
* Normalising attachments and embeds of messages
|
||||
* Normalising parameter types
|
||||
* More Documentation
|
||||
* Voice Chat
|
||||
-192
@@ -1,192 +0,0 @@
|
||||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = _build
|
||||
|
||||
# User-friendly check for sphinx-build
|
||||
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
|
||||
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
|
||||
endif
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
# the i18n builder cannot share the environment and doctrees with the others
|
||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " dirhtml to make HTML files named index.html in directories"
|
||||
@echo " singlehtml to make a single large HTML file"
|
||||
@echo " pickle to make pickle files"
|
||||
@echo " json to make JSON files"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " qthelp to make HTML files and a qthelp project"
|
||||
@echo " applehelp to make an Apple Help Book"
|
||||
@echo " devhelp to make HTML files and a Devhelp project"
|
||||
@echo " epub to make an epub"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
|
||||
@echo " text to make text files"
|
||||
@echo " man to make manual pages"
|
||||
@echo " texinfo to make Texinfo files"
|
||||
@echo " info to make Texinfo files and run them through makeinfo"
|
||||
@echo " gettext to make PO message catalogs"
|
||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
||||
@echo " xml to make Docutils-native XML files"
|
||||
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||
@echo " coverage to run coverage check of the documentation (if enabled)"
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)/*
|
||||
|
||||
html:
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
dirhtml:
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
singlehtml:
|
||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||
|
||||
pickle:
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
json:
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
htmlhelp:
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||
|
||||
qthelp:
|
||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/discordjs.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/discordjs.qhc"
|
||||
|
||||
applehelp:
|
||||
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
|
||||
@echo
|
||||
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
|
||||
@echo "N.B. You won't be able to view it unless you put it in" \
|
||||
"~/Library/Documentation/Help or install it in your application" \
|
||||
"bundle."
|
||||
|
||||
devhelp:
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/discordjs"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/discordjs"
|
||||
@echo "# devhelp"
|
||||
|
||||
epub:
|
||||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||
@echo
|
||||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||
|
||||
latex:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||
"(use \`make latexpdf' here to do that automatically)."
|
||||
|
||||
latexpdf:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through pdflatex..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
latexpdfja:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through platex and dvipdfmx..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
text:
|
||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||
@echo
|
||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||
|
||||
man:
|
||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||
@echo
|
||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||
|
||||
texinfo:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo
|
||||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
||||
@echo "Run \`make' in that directory to run these through makeinfo" \
|
||||
"(use \`make info' here to do that automatically)."
|
||||
|
||||
info:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo "Running Texinfo files through makeinfo..."
|
||||
make -C $(BUILDDIR)/texinfo info
|
||||
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
||||
|
||||
gettext:
|
||||
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
||||
@echo
|
||||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
||||
|
||||
changes:
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||
@echo
|
||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
||||
|
||||
linkcheck:
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
"or in $(BUILDDIR)/linkcheck/output.txt."
|
||||
|
||||
doctest:
|
||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||
@echo "Testing of doctests in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/doctest/output.txt."
|
||||
|
||||
coverage:
|
||||
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
|
||||
@echo "Testing of coverage in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/coverage/python.txt."
|
||||
|
||||
xml:
|
||||
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
|
||||
@echo
|
||||
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
|
||||
|
||||
pseudoxml:
|
||||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
||||
@echo
|
||||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
||||
-292
@@ -1,292 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# discord.js documentation build configuration file, created by
|
||||
# sphinx-quickstart on Fri Sep 25 17:25:49 2015.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import shlex
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'discord.js'
|
||||
copyright = u'2015, hydrabolt'
|
||||
author = u'hydrabolt'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '5.3'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '5.3.1'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
#keep_warnings = False
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = False
|
||||
|
||||
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
#html_static_path = ['_static']
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
# directly to the root of the documentation.
|
||||
#html_extra_path = []
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Language to be used for generating the HTML full-text search index.
|
||||
# Sphinx supports the following languages:
|
||||
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
|
||||
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
|
||||
#html_search_language = 'en'
|
||||
|
||||
# A dictionary with options for the search language support, empty by default.
|
||||
# Now only 'ja' uses this config value
|
||||
#html_search_options = {'type': 'default'}
|
||||
|
||||
# The name of a javascript file (relative to the configuration directory) that
|
||||
# implements a search results scorer. If empty, the default will be used.
|
||||
#html_search_scorer = 'scorer.js'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'discordjsdoc'
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'discordjs.tex', u'discord.js Documentation',
|
||||
u'hydrabolt', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'discordjs', u'discord.js Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'discordjs', u'discord.js Documentation',
|
||||
author, 'discordjs', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
||||
|
||||
if not os.environ.get('READTHEDOCS', None) == 'True':
|
||||
try:
|
||||
import sphinx_rtd_theme
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||
except ImportError:
|
||||
print("sphinx_rtd_theme not found! Do 'pip install sphinx_rtd_theme' to make local builds use the RTD theme.")
|
||||
@@ -0,0 +1,10 @@
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = {
|
||||
category: 'Examples',
|
||||
name: 'Avatars',
|
||||
data:
|
||||
`\`\`\`js
|
||||
${fs.readFileSync('./docs/custom/examples/avatar.js').toString('utf-8')}
|
||||
\`\`\``,
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
# About Version 9
|
||||
The version 9 (v9) rewrite takes a much more object-oriented approach than previous versions,
|
||||
which allows your code to be much more readable and manageable.
|
||||
It's been rebuilt from the ground up and should be much more stable, fixing caching issues that affected
|
||||
older versions. It also has support for newer Discord Features, such as emojis.
|
||||
|
||||
## Upgrading your code
|
||||
Version 9, while containing a sizable number of breaking changes, does not require much change in your code's logic -
|
||||
most of the concepts are still the same, but loads of functions have been moved around.
|
||||
The vast majority of methods you're used to using have been moved out of the Client class,
|
||||
into other more relevant classes where they belong.
|
||||
Because of this, you will need to convert most of your calls over to the new methods.
|
||||
|
||||
Here are a few examples of methods that have changed:
|
||||
* `Client.sendMessage(channel, message)` ==> `TextChannel.sendMessage(message)`
|
||||
* `Client.sendMessage(user, message)` ==> `User.sendMessage(message)`
|
||||
* `Client.updateMessage(message, "New content")` ==> `Message.edit("New Content")`
|
||||
* `Client.getChannelLogs(channel, limit)` ==> `TextChannel.fetchMessages({options})`
|
||||
* `Server.detailsOfUser(User)` ==> `Server.members.get(User).properties` (retrieving a member gives a GuildMember object)
|
||||
* `Client.joinVoiceChannel(voicechannel)` => `VoiceChannel.join()`
|
||||
|
||||
A couple more important details:
|
||||
* `Client.loginWithToken("token")` ==> `client.login("token")`
|
||||
* `Client.servers.length` ==> `client.guilds.size` (all instances of `server` are now `guild`)
|
||||
|
||||
## Callbacks
|
||||
Version 9 eschews callbacks in favour of Promises. This means all code relying on callbacks must be changed.
|
||||
For example, the following code:
|
||||
|
||||
```js
|
||||
client.getChannelLogs(channel, 100, function(messages) {
|
||||
console.log(`${messages.length} messages found`);
|
||||
});
|
||||
```
|
||||
|
||||
```js
|
||||
channel.fetchMessages({limit: 100}).then(messages => {
|
||||
console.log(`${messages.size} messages found`);
|
||||
});
|
||||
```
|
||||
@@ -0,0 +1,47 @@
|
||||
<p align="center">
|
||||
<a href="https://hydrabolt.github.io/discord.js">
|
||||
<img alt="discord.js" src="http://i.imgur.com/sPOLh9y.png" width="546"><br />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
[](https://discord.gg/bRCvFy9)
|
||||
[](https://www.npmjs.com/package/discord.js)
|
||||
[](https://www.npmjs.com/package/discord.js)
|
||||
[](https://travis-ci.org/hydrabolt/discord.js)
|
||||
[](https://david-dm.org/hydrabolt/discord.js)
|
||||
|
||||
[](https://nodei.co/npm/discord.js/)
|
||||
|
||||
discord.js is a powerful node.js module that allows you to interact with the [Discord API](https://discordapp.com/developers/docs/intro).
|
||||
|
||||
# Welcome!
|
||||
Welcome to the discord.js v9 documentation. The v9 rewrite has taken a lot of time, but it should be much more
|
||||
stable and performant than previous versions.
|
||||
|
||||
## Installation
|
||||
**Node.js 6.0.0 or newer is required.**
|
||||
With voice support: `npm install --save discord.js --production`
|
||||
Without voice support: `npm install --save discord.js --production --no-optional`
|
||||
|
||||
By default, discord.js uses [opusscript](https://www.npmjs.com/package/opusscript) when playing audio over voice connections.
|
||||
If you're looking to play over multiple voice connections, it might be better to install [node-opus](https://www.npmjs.com/package/node-opus).
|
||||
discord.js will automatically prefer node-opus over opusscript.
|
||||
|
||||
## Guides
|
||||
* [LuckyEvie's general guide](https://eslachance.gitbooks.io/discord-js-bot-guide/content/)
|
||||
* [York's v9 upgrade guide](https://yorkaargh.wordpress.com/2016/09/03/updating-discord-js-bots/)
|
||||
|
||||
## Links
|
||||
* [Website](http://hydrabolt.github.io/discord.js/)
|
||||
* [Discord.js Server](https://discord.gg/bRCvFy9)
|
||||
* [Discord API Server](https://discord.gg/rV4BwdK)
|
||||
* [Documentation](http://hydrabolt.github.io/discord.js/#!/docs/tag/master)
|
||||
* [Legacy Documentation](http://discordjs.readthedocs.io/en/8.1.0/docs_client.html)
|
||||
* [GitHub](https://github.com/hydrabolt/discord.js)
|
||||
* [NPM](https://www.npmjs.com/package/discord.js)
|
||||
* [Examples](https://github.com/hydrabolt/discord.js/tree/master/docs/custom/examples)
|
||||
* [Related Libraries](https://discordapi.com/unofficial/libs.html)
|
||||
|
||||
## Help
|
||||
If you don't understand something in this documentation, you are experiencing problems, or you just need a gentle
|
||||
nudge in the right direction, please don't hesitate to join our official [Discord.js Server](https://discord.gg/bRCvFy9).
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Send a user a link to their avatar
|
||||
*/
|
||||
|
||||
// import the discord.js module
|
||||
const Discord = require('discord.js');
|
||||
|
||||
// create an instance of a Discord Client, and call it bot
|
||||
const bot = new Discord.Client();
|
||||
|
||||
// the token of your bot - https://discordapp.com/developers/applications/me
|
||||
const token = 'your bot token here';
|
||||
|
||||
// the ready event is vital, it means that your bot will only start reacting to information
|
||||
// from Discord _after_ ready is emitted.
|
||||
bot.on('ready', () => {
|
||||
console.log('I am ready!');
|
||||
});
|
||||
|
||||
// create an event listener for messages
|
||||
bot.on('message', message => {
|
||||
// if the message is "what is my avatar",
|
||||
if (message.content === 'what is my avatar') {
|
||||
// send the user's avatar URL
|
||||
message.reply(message.author.avatarURL);
|
||||
}
|
||||
});
|
||||
|
||||
// log our bot in
|
||||
bot.login(token);
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
A ping pong bot, whenever you send "ping", it replies "pong".
|
||||
*/
|
||||
|
||||
// import the discord.js module
|
||||
const Discord = require('discord.js');
|
||||
|
||||
// create an instance of a Discord Client, and call it bot
|
||||
const bot = new Discord.Client();
|
||||
|
||||
// the token of your bot - https://discordapp.com/developers/applications/me
|
||||
const token = 'your bot token here';
|
||||
|
||||
// the ready event is vital, it means that your bot will only start reacting to information
|
||||
// from Discord _after_ ready is emitted.
|
||||
bot.on('ready', () => {
|
||||
console.log('I am ready!');
|
||||
});
|
||||
|
||||
// create an event listener for messages
|
||||
bot.on('message', message => {
|
||||
// if the message is "ping",
|
||||
if (message.content === 'ping') {
|
||||
// send "pong" to the same channel.
|
||||
message.channel.sendMessage('pong');
|
||||
}
|
||||
});
|
||||
|
||||
// log our bot in
|
||||
bot.login(token);
|
||||
@@ -0,0 +1,17 @@
|
||||
const files = [
|
||||
require('./welcome'),
|
||||
require('./updating'),
|
||||
require('./ping_pong'),
|
||||
require('./avatar'),
|
||||
];
|
||||
|
||||
const categories = {};
|
||||
for (const file of files) {
|
||||
file.category = file.category.toLowerCase();
|
||||
if (!categories[file.category]) {
|
||||
categories[file.category] = [];
|
||||
}
|
||||
categories[file.category].push(file);
|
||||
}
|
||||
|
||||
module.exports = categories;
|
||||
@@ -0,0 +1,10 @@
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = {
|
||||
category: 'Examples',
|
||||
name: 'Ping Pong',
|
||||
data:
|
||||
`\`\`\`js
|
||||
${fs.readFileSync('./docs/custom/examples/ping_pong.js').toString('utf-8')}
|
||||
\`\`\``,
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = {
|
||||
category: 'General',
|
||||
name: 'Updating your code',
|
||||
data: fs.readFileSync('./docs/custom/documents/updating.md').toString('utf-8'),
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = {
|
||||
category: 'General',
|
||||
name: 'Welcome',
|
||||
data: fs.readFileSync('./docs/custom/documents/welcome.md').toString('utf-8'),
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -1,51 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Cache
|
||||
=====
|
||||
|
||||
**extends Array**
|
||||
|
||||
A Cache object extends an Array (so it can be used like a regular array) but introduces helper functions to make it more useful when developing with discord.js. Unlike a regular array, it doesn't care about the instance or prototype of an object, it works purely on properties.
|
||||
|
||||
**Examples:**
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
client.users.get("id", 11238414);
|
||||
|
||||
client.channels.getAll("name", "general");
|
||||
|
||||
--------
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
get(key, value)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Returns a contained object where ``object[key] == value``. Returns the first object found that matches the criteria.
|
||||
|
||||
getAll(key, value)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Similar to ``cache.get(key, value)``, but returns a Cache of any objects that meet the criteria.
|
||||
|
||||
has(key, value)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Returns `true` if there is an object that meets the condition ``object[key] == value`` in the cache
|
||||
|
||||
add(data)
|
||||
~~~~~~~~~
|
||||
|
||||
Adds an object to the Cache as long as all the other objects in the cache don't have the same ID as it.
|
||||
|
||||
update(old, data)
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Updates an old object in the Cache (if it exists) with the new one.
|
||||
|
||||
remove(data)
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Removes an object from the cache if it exists.
|
||||
@@ -1,28 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Channel
|
||||
=======
|
||||
|
||||
**extends** Equality_
|
||||
|
||||
The Channel class is the base class for all types of channel.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
The ID of the channel, a `String`.
|
||||
|
||||
client
|
||||
~~~~~~
|
||||
|
||||
The Client_ that cached the channel.
|
||||
|
||||
isPrivate
|
||||
~~~~~~~~~
|
||||
|
||||
Indicates whether the channel is PM channel, is `Boolean`.
|
||||
@@ -1,42 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
ChannelPermissions
|
||||
==================
|
||||
|
||||
ChannelPermissions is used to represent the final permissions of a user in a channel, to see exactly what they are and aren't allowed to do.
|
||||
|
||||
**Examples:**
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
var user_permissions = channel.permissionsOf(user);
|
||||
|
||||
var can_mention_everyone = user_permissions.hasPermission("mentionEveryone");
|
||||
|
||||
--------
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
serialize()
|
||||
~~~~~~~~~~~
|
||||
|
||||
**Aliases:** `serialise`
|
||||
|
||||
Returns an object containing permission names and values. E.g:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
createInstantInvite : true,
|
||||
kickMembers : false
|
||||
}
|
||||
|
||||
For more on valid permission names, see `Permission Constants`_.
|
||||
|
||||
hasPermission(permission)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sees whether the user has the permission given.
|
||||
|
||||
- **permission** - See `Permission Constants`_ for valid permission names.
|
||||
@@ -1,672 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Client
|
||||
======
|
||||
|
||||
**extends** EventEmitter_
|
||||
|
||||
This page contains documentation on the `Discord.Client` class. This should be used when you want to start creating things with the API.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
users
|
||||
~~~~~
|
||||
|
||||
A Cache_ of User_ objects that the client has cached.
|
||||
|
||||
channels
|
||||
~~~~~~~~
|
||||
|
||||
A Cache_ of ServerChannel_ objects that the client has cached.
|
||||
|
||||
privateChannels
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
A Cache_ of PMChannel_ objects that the client has cached. These are all the Private/Direct Chats the client is in.
|
||||
|
||||
servers
|
||||
~~~~~~~
|
||||
|
||||
A Cache_ of Server_ objects that the client has cached.
|
||||
|
||||
voiceConnection
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
A VoiceConnection_ object that is the current voice connection (if any).
|
||||
|
||||
readyTime
|
||||
~~~~~~~~~
|
||||
|
||||
A `Number` unix timestamp dating to when the Client emitted `ready`.
|
||||
|
||||
uptime
|
||||
~~~~~~
|
||||
|
||||
A `Number` in milliseconds representing how long the Client has been ready for.
|
||||
|
||||
user
|
||||
~~~~
|
||||
|
||||
A User_ object representing the logged in client's user.
|
||||
|
||||
userAgent
|
||||
~~~~~~~~~
|
||||
|
||||
An object containing `url`, `version` and `full`.
|
||||
Setting this property allows the discord developers to keep track of active bots,
|
||||
it defaults to the discord.js git repo and the current version of the package.
|
||||
`url` should be the repository/homepage of the creator.
|
||||
`version` should be the version of your bot.
|
||||
`full` is read only and will be automatically generated upon setting.
|
||||
|
||||
-----
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
.. note :: Any functions used here that take callbacks as an optional parameter can also be used as Promises_. Promises take the exact same parameters for each use case, except errors are moved to catch statements instead of then. For example, you can do:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.login(email, password).then(success).catch(err);
|
||||
|
||||
function success(token){
|
||||
// handle success
|
||||
}
|
||||
|
||||
function err(error){
|
||||
// handle error
|
||||
}
|
||||
|
||||
or use callbacks:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
bot.login(email, password, function(error, token){
|
||||
// handle error and success
|
||||
});
|
||||
|
||||
login(email, password, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Logs the client in so it can begin initialising. Use this `after` registering your events to ensure they are called!
|
||||
|
||||
- **email** - The e-mail used to sign in, `String`.
|
||||
- **password** - The password used to sign in, `String`.
|
||||
- **callback** - `function` that takes the following parameters:
|
||||
- **error** - An error if any occurred
|
||||
- **token** - The token received after logging in, `String`.
|
||||
|
||||
logout(`callback`)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Logs the client out and closes the WebSocket connections.
|
||||
|
||||
- **callback** - `function` that takes the following parameter:
|
||||
- **error** - An error if any occurred
|
||||
|
||||
sendMessage(channel, content, `options`, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sends a message to the specified channel.
|
||||
|
||||
- **channel** - a `Channel Resolvable`_
|
||||
- **content** - a `String Resolvable`_ - the message you want to send
|
||||
- **options** - `object` containing:
|
||||
- **tts** - `Boolean`, should message be text-to-speech
|
||||
- **callback** - `function` that takes the following parameters:
|
||||
- **error** - error object if any occurred
|
||||
- **message** - the sent Message_
|
||||
|
||||
sendFile(channel, attachment, name, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sends a file to the specified channel.
|
||||
|
||||
- **channel** - a `Channel Resolvable`_
|
||||
- **attachment** - A ReadableStream, String or Buffer
|
||||
- **name** - `String`, name of the file containing the extension
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
- **message** - the sent Message_
|
||||
|
||||
reply(message, content, `options`, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Shortcut to `sendMessage` but prepends a mention to the sender of the original message to the start of your message.
|
||||
|
||||
- **message** - The Message_ to reply to
|
||||
- **content** - a `String Resolvable`_ - the message you want to send
|
||||
- **options** - `object` containing:
|
||||
- **tts** - `Boolean`, should message be text-to-speech
|
||||
- **callback** - `function` that takes the following parameters:
|
||||
- **error** - error object if any occurred
|
||||
- **message** - the sent Message_
|
||||
|
||||
updateMessage(message, content, `options`, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Updates the content of a previously sent message
|
||||
|
||||
- **message** - The Message_ to update
|
||||
- **content** - a `String Resolvable`_ - the content you want to update the message with
|
||||
- **options** - `object` containing:
|
||||
- **tts** - `Boolean`, should message be text-to-speech
|
||||
- **callback** - `function` that takes the following parameters:
|
||||
- **error** - error object if any occurred
|
||||
- **message** - the sent Message_
|
||||
|
||||
deleteMessage(message, `options`, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Attempts to delete a message
|
||||
|
||||
- **message** - The Message_ to delete
|
||||
- **options** - `object` containing the following:
|
||||
- **wait** - Milliseconds as a `number` to wait before deleting the message
|
||||
- **callback**
|
||||
- **error** - error object if any occurred
|
||||
|
||||
getChannelLogs(channel, `limit`, `options`, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Gets a list of previously sent messages in a channel.
|
||||
|
||||
- **channel** - The Channel_ to get messages from
|
||||
- **limit** - The maximum amount of messages to retrieve - defaults to 500. A `Number`
|
||||
- **options** - An `object` containing either of the following:
|
||||
- **before** - A `Message Resolvable`_ - gets messages before this message.
|
||||
- **after** - A `Message Resolvable`_ - gets messages after this message.
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
- **messages** - `array` of Message_ objects sent in channel
|
||||
|
||||
getBans(server, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Gets a list of banned users in a server.
|
||||
|
||||
- **server** - `Server Resolvable`_ - The server to get banned users of
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
- **users** - `array` of banned users in the server
|
||||
|
||||
joinServer(invite, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Joins a server from the given invite
|
||||
|
||||
- **invite** - an `Invite Resolvable`_
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
- **server** - the joined Server_
|
||||
|
||||
createServer(name, region, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Creates a server
|
||||
|
||||
- **name** - `String`, name of the server
|
||||
- **region** - `String`, region of the server, currently **us-west, us-east, singapore, london, sydney** or **amsterdam**
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
- **server** - the created Server_
|
||||
|
||||
leaveServer(server, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Leaves/deletes a server that the client is in
|
||||
|
||||
- **server** - a `Server Resolvable`_
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
createChannel(server, name, `type`, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Creates a channel in a server
|
||||
|
||||
- **server** - a `Server Resolvable`_
|
||||
- **name** - `String`, name of the channel. Spaces not allowed.
|
||||
- **type** - defaults to `text`, but can also be `voice`
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
- **channel** - the created ServerChannel_
|
||||
|
||||
deleteChannel(channel, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Deletes a channel in a server.
|
||||
|
||||
- **channel** - a `Channel Resolvable`_ to delete
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred.
|
||||
|
||||
banMember(user, server, `length`, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Bans a user from a server.
|
||||
|
||||
- **user** - A `User Resolvable`_ to ban
|
||||
- **server** - A `Server Resolvable`_ to ban the user from
|
||||
- **length** - `Number`, how many days to go back and delete messages from that user
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred.
|
||||
|
||||
unbanMember(user, server, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Unbans a user from a server.
|
||||
|
||||
- **user** - A `User Resolvable`_ to unban
|
||||
- **server** - A `Server Resolvable`_ to unban the user from
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred.
|
||||
|
||||
kickMember(user, server, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Removes a user from a server
|
||||
|
||||
- **user** - A `User Resolvable`_ to kick
|
||||
- **server** - A `Server Resolvable`_ to kick the user from
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred.
|
||||
|
||||
createInvite(channel, `options`, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Creates an invite for the specified channel (or server)
|
||||
|
||||
- **channel** - A `Channel Resolvable`_
|
||||
- **options** - `object` containing:
|
||||
- **maxAge** - `Number` for maximum time in seconds for invite's validity
|
||||
- **maxUses** - `Number`, maximum uses of invite
|
||||
- **temporary** - `Boolean`, whether the invite should be temporary
|
||||
- **xkcd** - `Boolean`, whether the invite should be human-readable-friendly.
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
- **invite** - the created Invite_
|
||||
|
||||
deleteInvite(invite, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Deletes an invite
|
||||
|
||||
- **invite** - An `Invite ID Resolvable`_
|
||||
- **callback** - a `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
setStatus(status, `game`, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sets the Discord Status of the Client
|
||||
|
||||
- **status** - `String`, either ``online, here, active, available`` or ``idle, away``
|
||||
- **game** - `String/Number`, ID of Discord Game being played
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
setStatusIdle()
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
**Alias:** `setStatusAway`
|
||||
|
||||
Sets the status of the Client to Idle/Away
|
||||
|
||||
setStatusOnline()
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
**Aliases:** `setStatusHere`, `setStatusActive`, `setStatusAvailable`
|
||||
|
||||
Sets the status of the Client to Online
|
||||
|
||||
setTopic(channel, topic, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sets the topic of a channel
|
||||
|
||||
- **channel** - A `Channel Resolvable`_
|
||||
- **topic** - A `String`
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
setChannelName(channel, name, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sets the name of a channel
|
||||
|
||||
- **channel** - A `Channel Resolvable`_
|
||||
- **name** - A `String`
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
setChannelNameAndTopic(channel, name, topic, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sets the name and topic of a channel
|
||||
|
||||
- **channel** - A `Channel Resolvable`_
|
||||
- **name** - A `String`
|
||||
- **topic** - A `String`
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
startTyping(channel, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Marks the client as typing in a channel.
|
||||
|
||||
- **channel** - A `Channel Resolvable`_
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
stopTyping(channel, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Marks the client as not typing in a channel (takes a few seconds to go active).
|
||||
|
||||
- **channel** - A `Channel Resolvable`_
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
updateDetails(details, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Updates the details of the client
|
||||
|
||||
- **details** - `object` containing any of the following:
|
||||
- **avatar** - `Base64 Resolvable`_, new avatar of the client
|
||||
- **email** - `String`, new email of the client
|
||||
- **newPassword** - `String`, new password of the client
|
||||
- **username** - `String`, new username of the client
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
setAvatar(avatar, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sets the avatar of the client
|
||||
|
||||
- **avatar** - `Base64 Resolvable`_, new avatar of the client
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
setUsername(name, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sets the username of the client
|
||||
|
||||
- **username** - `String`, new username of the Client
|
||||
- **callback** - `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
joinVoiceChannel(channel, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Joins a Voice Channel to begin transmitting audio
|
||||
|
||||
- **channel** - A `VoiceChannel Resolvable`_
|
||||
- **callback** - `function` that takes the following:
|
||||
- **error** - error if any occurred
|
||||
- **connection** - VoiceConnection_, the created Voice Connection.
|
||||
|
||||
leaveVoiceChannel(`callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Leaves the currently connected Voice Channel if connected
|
||||
|
||||
- **callback** - `function` that takes the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
createRole(server, `data`, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Creates a new role in a server.
|
||||
|
||||
- **server** - a `Server Resolvable`_
|
||||
- **data** - `object` containing the structure below
|
||||
- **callback** - `function` that takes the following:
|
||||
- **error** - error if any occurred
|
||||
- **role** - the created Role_
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
// structure of data parameter (all attrs optional):
|
||||
{
|
||||
color : 0xFF0000,
|
||||
hoist : false,
|
||||
name : "A New Role!",
|
||||
permissions : [
|
||||
// see the constants documentation for full permissions
|
||||
"attachFiles", "sendMessages"
|
||||
]
|
||||
}
|
||||
|
||||
updateRole(role, data, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Updates a role in a server.
|
||||
|
||||
- **role** - a Role_
|
||||
- **data** - an `object` taking the structure shown below
|
||||
- **callback** - a `function` taking the following:
|
||||
- **error** - error if any occurred
|
||||
- **role** - the updated Role_
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
// structure of data parameter (all attrs optional):
|
||||
{
|
||||
color : 0xFF0000,
|
||||
hoist : false,
|
||||
name : "A New Role!",
|
||||
permissions : [
|
||||
// see the constants documentation for full permissions
|
||||
"attachFiles", "sendMessages"
|
||||
]
|
||||
}
|
||||
|
||||
deleteRole(role, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Deletes a role from a server
|
||||
|
||||
- **role** - The Role_ to delete
|
||||
- **callback** - `function` that takes the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
addMemberToRole(member, role, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
**Aliases** : `addUserToRole`
|
||||
|
||||
Adds a member of a server to a role in the server
|
||||
|
||||
- **member** - A `User Resolvable`_
|
||||
- **role** - A Role_
|
||||
- **callback** - `function` that takes the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
removeMemberFromRole(member, role, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
**Aliases** : `removeUserFromRole`
|
||||
|
||||
Removes a member of a server from a role in the server
|
||||
|
||||
- **member** - A `User Resolvable`_
|
||||
- **role** - A Role_
|
||||
- **callback** - `function` that takes the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
overwritePermissions(channel, roleOrUser, options, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Overwrites the permissions of a role or a user in a channel
|
||||
|
||||
- **channel** - a `Channel Resolvable`_
|
||||
- **roleOrUser** - a Role_ or a User_ object
|
||||
- **options** - an `object` containing a structure as shown below
|
||||
- **callback** - `function` that takes the following:
|
||||
- **error** - error if any occurred
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
"sendMessages" : false,
|
||||
"attachFiles" : true
|
||||
}
|
||||
|
||||
Events
|
||||
------
|
||||
|
||||
`Discord.Client` is an EventEmitter, so you can use `.on()` and `.off()` to add and remove events.
|
||||
|
||||
ready
|
||||
~~~~~
|
||||
|
||||
Emitted when the client is ready to use
|
||||
|
||||
debug
|
||||
~~~~~
|
||||
|
||||
Emitted when the client debugs or wants to log something internally
|
||||
|
||||
message
|
||||
~~~~~~~
|
||||
|
||||
Emitted when the client receives a message, supplies a Message_ object.
|
||||
|
||||
warn
|
||||
~~~~
|
||||
|
||||
Emitted when the client has encountered a small error that can be avoided.
|
||||
|
||||
messageDeleted
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a message has been deleted and the Client finds out, supplies a Message_ object IF available, and a Channel_ object.
|
||||
|
||||
messageUpdated
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a message has been updated and the client finds out. Supplies two Message_ objects, the first being the new updated messages, the latter being the old message.
|
||||
|
||||
disconnected
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Emitted when the client is disconnected from the Discord server.
|
||||
|
||||
error
|
||||
~~~~~
|
||||
|
||||
Emitted when the client runs into a big problem, supplies an error object.
|
||||
|
||||
raw
|
||||
~~~
|
||||
|
||||
Emitted when a message over WebSocket is received, it supplies one `object` containing the raw data from the WebSocket.
|
||||
|
||||
serverCreated
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a server is joined by the Client, supplies a Server_ object.
|
||||
|
||||
serverDeleted
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Emitted when the client leaves a server, supplies a Server_ object.
|
||||
|
||||
serverUpdated
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a server is updated (e.g. name change). Supplies two Server_ objects, the first being the server before the update, the second being the new, updated server.
|
||||
|
||||
channelCreated
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a channel is created, supplies a Channel_ object (includes PM chats as well as server channels).
|
||||
|
||||
channelDeleted
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a channel is deleted, supplies a Channel_ object.
|
||||
|
||||
channelUpdated
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a channel is updated (e.g. name/topic change). Supplies a Channel_ object.
|
||||
|
||||
serverRoleCreated
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a role is created in a server, supplies a Role_ object.
|
||||
|
||||
serverRoleDeleted
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a role is deleted from a server, supplies a Role_ object.
|
||||
|
||||
serverRoleUpdated
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a role is updated in a server, supplies two Role_ objects. The first is the old role, the second is the updated role.
|
||||
|
||||
serverNewMember
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a user joins a server, supplies a Server_ object and a User_ object.
|
||||
|
||||
serverMemberRemoved
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a member is removed from a server. Supplies a Server_ object and a User_ object.
|
||||
|
||||
serverMemberUpdated
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a member in a server is updated. Supplies a Server_ object and a User_ object.
|
||||
|
||||
presence
|
||||
~~~~~~~~
|
||||
|
||||
Emitted when a user goes online/offline/idle or starts/stops playing a game. Supplies 3 parameters, the first being the User_ object, the second being the status, the third being the game ID they are playing.
|
||||
|
||||
userUpdated
|
||||
~~~~~~~~~~~
|
||||
|
||||
Emitted when a user changes their name, avatar or similar. Supplies two User_ objects, the first being the user before being updated, the second being the updated user.
|
||||
|
||||
userTypingStarted
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a user starts typing in a channel. Supplies two parameters, a User_ object and a Channel_ object.
|
||||
|
||||
userTypingStopped
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Emitted when a user stop typing in a channel. Supplies two parameters, a User_ object and a Channel_ object.
|
||||
|
||||
userBanned
|
||||
~~~~~~~~~~
|
||||
|
||||
Emitted when a user is banned from a server. Supplies two parameters, a User_ object and a Server_ object.
|
||||
|
||||
userUnbanned
|
||||
~~~~~~~~~~
|
||||
|
||||
Emitted when a user is unbanned from a server. Supplies two parameters, a User_ object and a Server_ object.
|
||||
|
||||
voiceJoin
|
||||
~~~~~~~~
|
||||
|
||||
Emitted when a user joins a voice channel, supplies a User_ and a VoiceChannel_
|
||||
|
||||
voiceLeave
|
||||
~~~~~~~~~~
|
||||
|
||||
Emitted when a user leaves a voice channel, supplies a User_ and a VoiceChannel_
|
||||
@@ -1,26 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Equality
|
||||
========
|
||||
|
||||
The Equality class is used to see if two objects are equal, based on ``object_1.id === object_2.id``.
|
||||
|
||||
If any class in Discord extends equality, it means you should never the default equality operands (``==`` & ``===``) as they could potentially be different instances and therefore appear not to be equal. Instead, use ``equalityObject.equals()`` as shown below.
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
object1.equals(object2); // GOOD ✓
|
||||
|
||||
object1 == object2; // BAD ✖
|
||||
|
||||
--------
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
equals(object)
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Returns true if the specified object is the same as this one.
|
||||
|
||||
- **object** - Any `object` with an ``id`` property.
|
||||
@@ -1,66 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Invite
|
||||
======
|
||||
|
||||
Used to represent data of an invite.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
maxAge
|
||||
~~~~~~
|
||||
|
||||
`Number`, how long (in seconds) the invite has since creation before expiring.
|
||||
|
||||
code
|
||||
~~~~
|
||||
|
||||
`String`, the invite code.
|
||||
|
||||
server
|
||||
~~~~~~
|
||||
|
||||
The Server_ the invite is for.
|
||||
|
||||
channel
|
||||
~~~~~~~
|
||||
|
||||
The ServerChannel_ the invite is for.
|
||||
|
||||
revoked
|
||||
~~~~~~~
|
||||
|
||||
`Boolean`, whether the invite has been revoked or not.
|
||||
|
||||
createdAt
|
||||
~~~~~~~~~
|
||||
|
||||
`Number`, timestamp of when the invite was created.
|
||||
|
||||
temporary
|
||||
~~~~~~~~~
|
||||
|
||||
`Boolean`, whether the invite is temporary or not.
|
||||
|
||||
uses
|
||||
~~~~
|
||||
|
||||
`Number`, uses of the invite remaining.
|
||||
|
||||
maxUses
|
||||
~~~~~~~
|
||||
|
||||
`Number`, maximum uses of the invite.
|
||||
|
||||
inviter
|
||||
~~~~~~~
|
||||
|
||||
User_ who sent/created the invite.
|
||||
|
||||
xkcd
|
||||
~~~~
|
||||
|
||||
`Boolean`, whether the invite is intended to be easy to read and remember by a human.
|
||||
@@ -1,85 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Message
|
||||
=======
|
||||
|
||||
**extends** Equality_
|
||||
|
||||
A Message object is used to represent the data of a message.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
channel
|
||||
~~~~~~~
|
||||
|
||||
The channel the message sent in, either a TextChannel_ or PMChannel_.
|
||||
|
||||
client
|
||||
~~~~~~
|
||||
|
||||
The Client_ that cached the message.
|
||||
|
||||
attachments
|
||||
~~~~~~~~~~~
|
||||
|
||||
A raw array of attachment objects.
|
||||
|
||||
tts
|
||||
~~~
|
||||
|
||||
`Boolean`, true if the message was text-to-speech.
|
||||
|
||||
embeds
|
||||
~~~~~~
|
||||
|
||||
A raw array of embed objects.
|
||||
|
||||
timestamp
|
||||
~~~~~~~~~
|
||||
|
||||
`Number`, timestamp of when the message was sent.
|
||||
|
||||
everyoneMentioned
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
`Boolean`, true if ``@everyone`` was mentioned.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
`String`, ID of the message.
|
||||
|
||||
editedTimestamp
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Timestamp on when the message was last edited, `Number`. Potentially null.
|
||||
|
||||
author
|
||||
~~~~~~
|
||||
|
||||
**Alias:** `sender`
|
||||
|
||||
The User_ that sent the message.
|
||||
|
||||
content
|
||||
~~~~~~~
|
||||
|
||||
`String`, content of the message.
|
||||
|
||||
mentions
|
||||
~~~~~~~~
|
||||
|
||||
A Cache_ of User_ objects that were mentioned in the message.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
isMentioned(user)
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Returns true if the given user was mentioned in the message.
|
||||
|
||||
- **user** : A `User Resolvable`_
|
||||
@@ -1,55 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Permission Constants
|
||||
====================
|
||||
|
||||
In discord.js, you can handle permissions in two ways. The preferred way is to just use the string name of the permission, alternatively you can use ``Discord.Constants.Permissions["permission name"]``.
|
||||
|
||||
--------
|
||||
|
||||
Valid Permission Names
|
||||
----------------------
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
// general
|
||||
createInstantInvite,
|
||||
kickMembers,
|
||||
banMembers,
|
||||
manageRoles,
|
||||
managePermissions,
|
||||
manageChannels,
|
||||
manageChannel,
|
||||
manageServer,
|
||||
// text
|
||||
readMessages,
|
||||
sendMessages,
|
||||
sendTTSMessages,
|
||||
manageMessages,
|
||||
embedLinks,
|
||||
attachFiles,
|
||||
readMessageHistory,
|
||||
mentionEveryone,
|
||||
// voice
|
||||
voiceConnect,
|
||||
voiceSpeak,
|
||||
voiceMuteMembers,
|
||||
voiceDeafenMembers,
|
||||
voiceMoveMembers,
|
||||
voiceUseVAD
|
||||
};
|
||||
|
||||
Preferred Way
|
||||
-------------
|
||||
|
||||
The preferred way of using permissions in discord.js is to just use the name. E.g:
|
||||
|
||||
``role.hasPermission("voiceUseVAD")``
|
||||
|
||||
Alternative
|
||||
-----------
|
||||
|
||||
You can also go the long way round and use the numerical permission like so:
|
||||
|
||||
``role.hasPermission( Discord.Constants.Permissions.voiceUseVAD )``
|
||||
@@ -1,31 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
PermissionOverwrite
|
||||
===================
|
||||
|
||||
PermissionOverwrite is used to represent data about permission overwrites for roles or users in channels.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
`String`, the ID of the PermissionOverwrite. If ``overwrite.type`` is ``role``, this is the role's ID. Otherwise, it is a User_ overwrite.
|
||||
|
||||
type
|
||||
~~~~
|
||||
|
||||
`String`, type of the overwrite. Either ``member`` or ``role``.
|
||||
|
||||
allowed
|
||||
~~~~~~~
|
||||
|
||||
Returns the permissions explicitly allowed by the overwrite. An `Array` of Strings, which are names of permissions. More can be found at `Permission Constants`_
|
||||
|
||||
denied
|
||||
~~~~~~
|
||||
|
||||
Returns the permissions explicitly denied by the overwrite. An `Array` of Strings, which are names of permissions. More can be found at `Permission Constants`_
|
||||
@@ -1,28 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
PMChannel
|
||||
=========
|
||||
|
||||
**extends** Channel_
|
||||
|
||||
A PMChannel is a Private/Direct channel between the Client and another user.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
messages
|
||||
~~~~~~~~
|
||||
|
||||
A Cache_ of Message_ objects.
|
||||
|
||||
recipient
|
||||
~~~~~~~~~
|
||||
|
||||
The User_ that is the recipient of the Channel.
|
||||
|
||||
lastMessage
|
||||
~~~~~~~~~~~
|
||||
|
||||
The last Message_ sent in the channel, may be null if no messages have been sent during the time the bound Client_ has been online.
|
||||
@@ -1,81 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Resolvables
|
||||
===========
|
||||
|
||||
In discord.js, the aim is to allow the end developer to have freedom in what sort of data types they supply. References to any sort of resolvable basically mean what types of data you can provide. The different resolvables are shown before:
|
||||
|
||||
--------
|
||||
|
||||
Channel Resolvable
|
||||
------------------
|
||||
|
||||
A Channel Resolvable allows:
|
||||
|
||||
- Channel_
|
||||
- Server_
|
||||
- Message_
|
||||
- User_ (in some instances)
|
||||
- String of Channel ID
|
||||
|
||||
Voice Channel Resolvable
|
||||
------------------------
|
||||
|
||||
A Voice Channel Resolvable allows:
|
||||
|
||||
- VoiceChannel_
|
||||
|
||||
Message Resolvable
|
||||
------------------
|
||||
|
||||
A Message Resolvable allows:
|
||||
|
||||
- Message_
|
||||
- TextChannel_
|
||||
- PMChannel_
|
||||
|
||||
User Resolvable
|
||||
---------------
|
||||
|
||||
A User Resolvable allows:
|
||||
|
||||
- User_
|
||||
- Message_
|
||||
- TextChannel_
|
||||
- PMChannel_
|
||||
- Server_
|
||||
- String of User ID
|
||||
|
||||
String Resolvable
|
||||
-----------------
|
||||
|
||||
A String Resolvable allows:
|
||||
|
||||
- Array
|
||||
- String
|
||||
|
||||
Server Resolvable
|
||||
-----------------
|
||||
|
||||
A Server Resolvable allows:
|
||||
|
||||
- Server_
|
||||
- ServerChannel_
|
||||
- Message_ (only for messages from server channels)
|
||||
- String of Server ID
|
||||
|
||||
Invite ID Resolvable
|
||||
--------------------
|
||||
|
||||
An Invite ID Resolvable allows:
|
||||
|
||||
- Invite_
|
||||
- String_ containing either a http link to the invite or the invite code on its own.
|
||||
|
||||
Base64 Resolvable
|
||||
-----------------
|
||||
|
||||
A Base64 Resolvable allows:
|
||||
|
||||
- Buffer
|
||||
- String
|
||||
@@ -1,73 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Role
|
||||
====
|
||||
|
||||
Represents data for a Server Role.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
position
|
||||
~~~~~~~~
|
||||
|
||||
`Number`, position of the role when viewing the roles of a server.
|
||||
|
||||
name
|
||||
~~~~
|
||||
|
||||
`String`, name of the role.
|
||||
|
||||
managed
|
||||
~~~~~~~
|
||||
|
||||
`Boolean`, whether Discord has created the role itself. Currently only used for Twitch integration.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
`String`, ID of the role.
|
||||
|
||||
hoist
|
||||
~~~~~
|
||||
|
||||
`Boolean`, whether the role should be displayed as a separate category in the users section.
|
||||
|
||||
color
|
||||
~~~~~
|
||||
|
||||
`Number`, a base 10 colour. Use ``role.colorAsHex()`` to get a hex colour instead.
|
||||
|
||||
server
|
||||
~~~~~~
|
||||
|
||||
The Server_ the role belongs to.
|
||||
|
||||
client
|
||||
~~~~~~
|
||||
|
||||
The Client_ that cached the role.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
serialise()
|
||||
~~~~~~~~~~~
|
||||
|
||||
**Aliases:** `serialize`
|
||||
|
||||
Makes an object with the permission names found in `Permission Constants`_ and a boolean value for them.
|
||||
|
||||
hasPermission(permission)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sees whether the role has the permission given.
|
||||
|
||||
- **permission** - See `Permission Constants`_ for valid permission names.
|
||||
|
||||
colorAsHex()
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Returns the role's colour as hex, e.g. ``#FF0000``.
|
||||
@@ -1,195 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Server
|
||||
======
|
||||
|
||||
**extends** Equality_
|
||||
|
||||
Stores information about a Discord Server.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
client
|
||||
~~~~~~
|
||||
|
||||
The Client_ that cached the Server.
|
||||
|
||||
region
|
||||
~~~~~~
|
||||
|
||||
`String`, region of the server.
|
||||
|
||||
name
|
||||
~~~~
|
||||
|
||||
`String`, name of the server.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
`String`, ID of the server - never changes.
|
||||
|
||||
members
|
||||
~~~~~~~
|
||||
|
||||
Members of the server, a Cache_ of User_ objects.
|
||||
|
||||
channels
|
||||
~~~~~~~~
|
||||
|
||||
Channels in the server, a Cache_ of ServerChannel_ objects.
|
||||
|
||||
roles
|
||||
~~~~~
|
||||
|
||||
Roles of the server, a Cache_ of Role_ objects.
|
||||
|
||||
icon
|
||||
~~~~
|
||||
|
||||
ID/Hash of server icon, use ``server.iconURL`` for an URL to the icon.
|
||||
|
||||
afkTimeout
|
||||
~~~~~~~~~~
|
||||
|
||||
`Number`, the AFK timeout in seconds before a user is classed as AFK. If there isn't an AFK timeout, this will be null.
|
||||
|
||||
afkChannel
|
||||
~~~~~~~~~~
|
||||
|
||||
The channel where AFK users are moved to, ServerChannel_ object. If one isn't set, this will be null.
|
||||
|
||||
defaultChannel
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
**Aliases** `generalChannel, general`
|
||||
|
||||
The ``#general`` ServerChannel_ of the server.
|
||||
|
||||
owner
|
||||
~~~~~
|
||||
|
||||
The founder of the server, a User_ object.
|
||||
|
||||
iconURL
|
||||
~~~~~~~
|
||||
|
||||
The URL of the Server's icon. If the server doesn't have an icon, this will be null.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
rolesOfUser(user)
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
**Aliases**: `rolesOf`
|
||||
|
||||
Returns an array of the roles affecting a user server-wide.
|
||||
|
||||
------
|
||||
|
||||
detailsOfUser(user)
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
**Aliases** `detailsOf`
|
||||
|
||||
Returns an object containing metadata of a user within the server, containing a structure similar to the following:
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
joinedAt : 1449339323747,
|
||||
mute : false,
|
||||
deaf : false
|
||||
}
|
||||
|
||||
----------
|
||||
|
||||
leave()
|
||||
~~~~~~~
|
||||
|
||||
| **Shortcut of** ``client.leaveServer(server)``
|
||||
| **Aliases** `delete`
|
||||
| **See** client.leaveServer_
|
||||
|
||||
------
|
||||
|
||||
|
|
||||
|
||||
createInvite(`options`, `callback`)
|
||||
~~~~~~~
|
||||
|
||||
| **Shortcut of** ``client.createInvite(server, options, callback)``
|
||||
| **See** client.createInvite_
|
||||
|
|
||||
|
||||
------
|
||||
|
||||
createRole(`data`, `callback`)
|
||||
~~~~~~~
|
||||
|
||||
| **Shortcut of** ``client.createRole(server, data, callback)``
|
||||
| **See** client.createRole_
|
||||
|
|
||||
|
||||
------
|
||||
|
||||
createChannel(name, `type`, `callback`)
|
||||
~~~~~~~
|
||||
|
||||
| **Shortcut of** ``client.createChannel(server, name, type, callback)``
|
||||
| **See** client.createChannel_
|
||||
|
|
||||
|
||||
------
|
||||
|
||||
getBans(`callback`)
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
| **Shortcut of** ``client.getBans(server, callback)``
|
||||
| **See** client.getBans_
|
||||
|
|
||||
|
||||
------
|
||||
|
||||
banMember(user, `length`, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
| **Shortcut of** ``client.banMember(member, server, length, callback)``
|
||||
| **Aliases** `banUser, ban`
|
||||
| **See** client.banMember_
|
||||
|
|
||||
|
||||
------
|
||||
|
||||
unbanMember(user, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
| **Shortcut of** ``client.unbanMember(member, server, callback)``
|
||||
| **Aliases** `unbanUser, unban`
|
||||
| **See** client.unbanMember_
|
||||
|
|
||||
|
||||
------
|
||||
|
||||
kickMember(user, `callback`)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
| **Shortcut of** ``client.kickMember(member, server, callback)``
|
||||
| **Aliases** `kickUser, kick`
|
||||
| **See** client.kickMember_
|
||||
|
|
||||
|
||||
------
|
||||
|
||||
.. _client.leaveServer : ./docs_client.html#leaveserver-server-callback
|
||||
.. _client.createInvite : ./docs_client.html#createinvite-channel-options-callback
|
||||
.. _client.createRole : ./docs_client.html#createrole-server-data-callback
|
||||
.. _client.createChannel : ./docs_client.html#createchannel-server-name-type-callback
|
||||
.. _client.banMember : ./docs_client.html#banmember-user-server-length-callback
|
||||
.. _client.unbanMember : ./docs_client.html#unbanmember-user-server-callback
|
||||
.. _client.kickMember : ./docs_client.html#kickmember-user-server-callback
|
||||
.. _client.getBans : ./docs_client.html#getbans-server-callback
|
||||
@@ -1,53 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
ServerChannel
|
||||
=============
|
||||
|
||||
**extends** Channel_
|
||||
|
||||
A ServerChannel is a Channel_ that belongs to a Server_.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
name
|
||||
~~~~
|
||||
|
||||
`String`, name of the channel.
|
||||
|
||||
type
|
||||
~~~~
|
||||
|
||||
`String`, either ``voice`` or ``text``.
|
||||
|
||||
position
|
||||
~~~~~~~~
|
||||
|
||||
`Number`, position in the channel list.
|
||||
|
||||
permissionOverwrites
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Cache_ of all the PermissionOverwrite_ objects affecting the channel.
|
||||
|
||||
server
|
||||
~~~~~~
|
||||
|
||||
Server_ the channel belongs to.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
permissionsOf(user)
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
**Aliases:** permsOf
|
||||
|
||||
Returns a ChannelPermissions_ object of a user's permissions in that channel.
|
||||
|
||||
mention()
|
||||
~~~~~~~~~
|
||||
|
||||
Returns a `string` that can be used in discord messages to mention a channel. ``serverChannel.toString()` defaults to this.
|
||||
@@ -1,28 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
TextChannel
|
||||
===========
|
||||
|
||||
**extends** ServerChannel_
|
||||
|
||||
A text channel of a server.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
topic
|
||||
~~~~~
|
||||
|
||||
The topic of the channel, a `String`.
|
||||
|
||||
lastMessage
|
||||
~~~~~~~~~~~
|
||||
|
||||
Last Message_ sent in the channel. May be null if no messages sent whilst the Client was online.
|
||||
|
||||
messages
|
||||
~~~~~~~~
|
||||
|
||||
A Cache_ of Message_ objects.
|
||||
@@ -1,80 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
User
|
||||
====
|
||||
|
||||
**extends** Equality_
|
||||
|
||||
Stores information about users.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
client
|
||||
~~~~~~
|
||||
|
||||
The Client_ that created the user.
|
||||
|
||||
username
|
||||
~~~~~~~~
|
||||
|
||||
_Alias_ : ``name``
|
||||
|
||||
`String`, username of the User.
|
||||
|
||||
discriminator
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
`Integer` from 0-9999, don't use this to identify users. Used to separate the user from the 9998 others that may have the same username. Made redundant by ``user.id``.
|
||||
|
||||
id
|
||||
~~
|
||||
|
||||
`String` (do not parse to an Integer, will become inaccurate). The ID of a user, never changes.
|
||||
|
||||
avatar
|
||||
~~~~~~
|
||||
|
||||
`String`, the ID/hash of a user's avatar. To get a path to their avatar, see ``user.avatarURL``.
|
||||
|
||||
status
|
||||
~~~~~~
|
||||
|
||||
The status of a user, `String`. Either ``online``, ``offline`` or ``idle``.
|
||||
|
||||
gameID
|
||||
~~~~~~
|
||||
|
||||
The ID of the game a user is playing, `Number`.
|
||||
|
||||
typing
|
||||
~~~~~~
|
||||
|
||||
`Object` containing the following values;
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
since : 1448038288519, //timestamp of when
|
||||
channel : <Channel Object> // channel they are typing in.
|
||||
}
|
||||
|
||||
avatarURL
|
||||
~~~~~~~~~
|
||||
|
||||
A valid URL to the user's avatar if they have one, otherwise null.
|
||||
|
||||
voiceChannel
|
||||
~~~~~~~~~~~~
|
||||
|
||||
The VoiceChannel_ the user is connected to. If they aren't in any voice channels, this will be ``null``.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
mention()
|
||||
~~~~~~~~~
|
||||
|
||||
Returns a valid string that can be sent in a message to mention the user. By default, ``user.toString()`` does this so by adding a user object to a string, e.g. ``user + ""``, their mention code will be retrieved.
|
||||
@@ -1,19 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
VoiceChannel
|
||||
============
|
||||
|
||||
**extends** ServerChannel_
|
||||
|
||||
A voice channel of a server. Currently, the voice channel class has no differences to the ServerChannel class.
|
||||
|
||||
--------
|
||||
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
members
|
||||
~~~~~~~~
|
||||
|
||||
A Cache_ of Users_ that are connected to the voice channel
|
||||
@@ -1,25 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
VoiceConnection
|
||||
===============
|
||||
|
||||
**Warning! Still experimental!**
|
||||
|
||||
As of discord.js v5.0.0, voice support has been added. This means you can stream audio but not yet receive.
|
||||
|
||||
--------
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
||||
voiceChannel
|
||||
~~~~~~~~~~~~
|
||||
|
||||
VoiceChannel_ that the connection is for
|
||||
|
||||
client
|
||||
~~~~~~
|
||||
|
||||
Client_ the connection belongs to
|
||||
|
||||
more docs coming soon :O
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"GEN_VERSION": 13,
|
||||
"COMPRESS": false
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/* eslint no-console:0 no-return-assign:0 */
|
||||
const parse = require('jsdoc-parse');
|
||||
|
||||
module.exports = class DocumentationScanner {
|
||||
constructor(generator) {
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
scan(directory) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const stream = parse({
|
||||
src: [`${directory}*.js`, `${directory}**/*.js`],
|
||||
});
|
||||
|
||||
let json = '';
|
||||
stream.on('data', chunk => json += chunk.toString('utf-8'));
|
||||
stream.on('error', reject);
|
||||
stream.on('end', () => {
|
||||
json = JSON.parse(json);
|
||||
resolve(json);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,114 @@
|
||||
const DocumentedClass = require('./types/DocumentedClass');
|
||||
const DocumentedInterface = require('./types/DocumentedInterface');
|
||||
const DocumentedTypeDef = require('./types/DocumentedTypeDef');
|
||||
const DocumentedConstructor = require('./types/DocumentedConstructor');
|
||||
const DocumentedMember = require('./types/DocumentedMember');
|
||||
const DocumentedFunction = require('./types/DocumentedFunction');
|
||||
const DocumentedEvent = require('./types/DocumentedEvent');
|
||||
const GEN_VERSION = require('./config.json').GEN_VERSION;
|
||||
|
||||
class Documentation {
|
||||
constructor(items, custom) {
|
||||
this.classes = new Map();
|
||||
this.interfaces = new Map();
|
||||
this.typedefs = new Map();
|
||||
this.custom = custom;
|
||||
this.parse(items);
|
||||
}
|
||||
|
||||
registerRoots(data) {
|
||||
for (const item of data) {
|
||||
switch (item.kind) {
|
||||
case 'class':
|
||||
this.classes.set(item.name, new DocumentedClass(this, item));
|
||||
break;
|
||||
case 'interface':
|
||||
this.interfaces.set(item.name, new DocumentedInterface(this, item));
|
||||
break;
|
||||
case 'typedef':
|
||||
this.typedefs.set(item.name, new DocumentedTypeDef(this, item));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
findParent(item) {
|
||||
if (['constructor', 'member', 'function', 'event'].indexOf(item.kind) > -1) {
|
||||
if (this.classes.get(item.memberof)) {
|
||||
return this.classes.get(item.memberof);
|
||||
}
|
||||
if (this.interfaces.get(item.memberof)) {
|
||||
return this.interfaces.get(item.memberof);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
parse(items) {
|
||||
this.registerRoots(
|
||||
items.filter(
|
||||
item => ['class', 'interface', 'typedef'].indexOf(item.kind) > -1
|
||||
)
|
||||
);
|
||||
|
||||
const members = items.filter(
|
||||
item => ['class', 'interface', 'typedef'].indexOf(item.kind) === -1
|
||||
);
|
||||
|
||||
const unknowns = new Map();
|
||||
for (const member of members) {
|
||||
let item;
|
||||
switch (member.kind) {
|
||||
case 'constructor':
|
||||
item = new DocumentedConstructor(this, member);
|
||||
break;
|
||||
case 'member':
|
||||
item = new DocumentedMember(this, member);
|
||||
break;
|
||||
case 'function':
|
||||
item = new DocumentedFunction(this, member);
|
||||
break;
|
||||
case 'event':
|
||||
item = new DocumentedEvent(this, member);
|
||||
break;
|
||||
default:
|
||||
unknowns.set(member.kind, member);
|
||||
break;
|
||||
}
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
const parent = this.findParent(member);
|
||||
if (!parent) {
|
||||
console.log(new Error(`${member.name || member.directData.name} has no accessible parent`));
|
||||
continue;
|
||||
}
|
||||
parent.add(item);
|
||||
}
|
||||
if (unknowns.size > 0) {
|
||||
Array.from(unknowns.keys()).map(
|
||||
k => console.log(`Unknown documentation kind ${k} - \n${JSON.stringify(unknowns.get(k))}\n`
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
serialize() {
|
||||
const meta = {
|
||||
version: GEN_VERSION,
|
||||
date: Date.now(),
|
||||
};
|
||||
|
||||
const serialized = {
|
||||
meta,
|
||||
classes: Array.from(this.classes.values()).map(c => c.serialize()),
|
||||
interfaces: Array.from(this.interfaces.values()).map(i => i.serialize()),
|
||||
typedefs: Array.from(this.typedefs.values()).map(t => t.serialize()),
|
||||
custom: this.custom,
|
||||
};
|
||||
return serialized;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Documentation;
|
||||
@@ -0,0 +1,34 @@
|
||||
/* eslint no-console:0 no-return-assign:0 */
|
||||
const GEN_VERSION = require('./config.json').GEN_VERSION;
|
||||
const compress = require('./config.json').COMPRESS;
|
||||
const DocumentationScanner = require('./doc-scanner');
|
||||
const Documentation = require('./documentation');
|
||||
const fs = require('fs-extra');
|
||||
const zlib = require('zlib');
|
||||
const custom = require('../custom/index');
|
||||
|
||||
const docScanner = new DocumentationScanner(this);
|
||||
|
||||
function parseDocs(json) {
|
||||
console.log(`${json.length} items found`);
|
||||
const documentation = new Documentation(json, custom);
|
||||
console.log('serializing');
|
||||
let output = JSON.stringify(documentation.serialize(), null, 0);
|
||||
if (compress) {
|
||||
console.log('compressing');
|
||||
output = zlib.deflateSync(output).toString('utf8');
|
||||
}
|
||||
if (!process.argv.slice(2).includes('silent')) {
|
||||
console.log('writing to docs.json');
|
||||
fs.writeFileSync('./docs/docs.json', output);
|
||||
}
|
||||
console.log('done!');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.log(`using format version ${GEN_VERSION}`);
|
||||
console.log('scanning for documentation');
|
||||
|
||||
docScanner.scan('./src/')
|
||||
.then(parseDocs)
|
||||
.catch(console.error);
|
||||
@@ -0,0 +1,83 @@
|
||||
const DocumentedItem = require('./DocumentedItem');
|
||||
const DocumentedItemMeta = require('./DocumentedItemMeta');
|
||||
const DocumentedConstructor = require('./DocumentedConstructor');
|
||||
const DocumentedFunction = require('./DocumentedFunction');
|
||||
const DocumentedMember = require('./DocumentedMember');
|
||||
const DocumentedEvent = require('./DocumentedEvent');
|
||||
|
||||
/*
|
||||
{ id: 'VoiceChannel',
|
||||
longname: 'VoiceChannel',
|
||||
name: 'VoiceChannel',
|
||||
scope: 'global',
|
||||
kind: 'class',
|
||||
augments: [ 'GuildChannel' ],
|
||||
description: 'Represents a Server Voice Channel on Discord.',
|
||||
meta:
|
||||
{ lineno: 7,
|
||||
filename: 'VoiceChannel.js',
|
||||
path: 'src/structures' },
|
||||
order: 232 }
|
||||
*/
|
||||
|
||||
class DocumentedClass extends DocumentedItem {
|
||||
|
||||
constructor(docParent, data) {
|
||||
super(docParent, data);
|
||||
this.props = new Map();
|
||||
this.methods = new Map();
|
||||
this.events = new Map();
|
||||
}
|
||||
|
||||
add(item) {
|
||||
if (item instanceof DocumentedConstructor) {
|
||||
if (this.classConstructor) {
|
||||
throw new Error(`Doc ${this.directData.name} already has constructor - ${this.directData.classConstructor}`);
|
||||
}
|
||||
this.classConstructor = item;
|
||||
} else if (item instanceof DocumentedFunction) {
|
||||
if (this.methods.get(item.directData.name)) {
|
||||
throw new Error(`Doc ${this.directData.name} already has method ${item.directData.name}`);
|
||||
}
|
||||
this.methods.set(item.directData.name, item);
|
||||
} else if (item instanceof DocumentedMember) {
|
||||
if (this.props.get(item.directData.name)) {
|
||||
throw new Error(`Doc ${this.directData.name} already has prop ${item.directData.name}`);
|
||||
}
|
||||
this.props.set(item.directData.name, item);
|
||||
} else if (item instanceof DocumentedEvent) {
|
||||
if (this.events.get(item.directData.name)) {
|
||||
throw new Error(`Doc ${this.directData.name} already has event ${item.directData.name}`);
|
||||
}
|
||||
this.events.set(item.directData.name, item);
|
||||
}
|
||||
}
|
||||
|
||||
registerMetaInfo(data) {
|
||||
super.registerMetaInfo(data);
|
||||
this.directData = data;
|
||||
this.directData.meta = new DocumentedItemMeta(this, data.meta);
|
||||
}
|
||||
|
||||
serialize() {
|
||||
super.serialize();
|
||||
const { id, name, description, meta, augments, access } = this.directData;
|
||||
const serialized = {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
meta: meta.serialize(),
|
||||
extends: augments,
|
||||
access,
|
||||
};
|
||||
if (this.classConstructor) {
|
||||
serialized.classConstructor = this.classConstructor.serialize();
|
||||
}
|
||||
serialized.methods = Array.from(this.methods.values()).map(m => m.serialize());
|
||||
serialized.properties = Array.from(this.props.values()).map(p => p.serialize());
|
||||
serialized.events = Array.from(this.events.values()).map(e => e.serialize());
|
||||
return serialized;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DocumentedClass;
|
||||
@@ -0,0 +1,46 @@
|
||||
const DocumentedItem = require('./DocumentedItem');
|
||||
const DocumentedParam = require('./DocumentedParam');
|
||||
|
||||
/*
|
||||
{ id: 'Client()',
|
||||
longname: 'Client',
|
||||
name: 'Client',
|
||||
kind: 'constructor',
|
||||
description: 'Creates an instance of Client.',
|
||||
memberof: 'Client',
|
||||
params:
|
||||
[ { type: [Object],
|
||||
optional: true,
|
||||
description: 'options to pass to the client',
|
||||
name: 'options' } ],
|
||||
order: 10 }
|
||||
*/
|
||||
|
||||
class DocumentedConstructor extends DocumentedItem {
|
||||
|
||||
registerMetaInfo(data) {
|
||||
super.registerMetaInfo(data);
|
||||
this.directData = data;
|
||||
const newParams = [];
|
||||
for (const param of data.params) {
|
||||
newParams.push(new DocumentedParam(this, param));
|
||||
}
|
||||
this.directData.params = newParams;
|
||||
}
|
||||
|
||||
serialize() {
|
||||
super.serialize();
|
||||
const { id, name, description, memberof, access, params } = this.directData;
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
memberof,
|
||||
access,
|
||||
params: params.map(p => p.serialize()),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = DocumentedConstructor;
|
||||
@@ -0,0 +1,80 @@
|
||||
const DocumentedItem = require('./DocumentedItem');
|
||||
const DocumentedItemMeta = require('./DocumentedItemMeta');
|
||||
const DocumentedParam = require('./DocumentedParam');
|
||||
|
||||
/*
|
||||
{
|
||||
"id":"Client#event:guildMemberRolesUpdate",
|
||||
"longname":"Client#event:guildMemberRolesUpdate",
|
||||
"name":"guildMemberRolesUpdate",
|
||||
"scope":"instance",
|
||||
"kind":"event",
|
||||
"description":"Emitted whenever a Guild Member's Roles change - i.e. new role or removed role",
|
||||
"memberof":"Client",
|
||||
"params":[
|
||||
{
|
||||
"type":{
|
||||
"names":[
|
||||
"Guild"
|
||||
]
|
||||
},
|
||||
"description":"the guild that the update affects",
|
||||
"name":"guild"
|
||||
},
|
||||
{
|
||||
"type":{
|
||||
"names":[
|
||||
"Array.<Role>"
|
||||
]
|
||||
},
|
||||
"description":"the roles before the update",
|
||||
"name":"oldRoles"
|
||||
},
|
||||
{
|
||||
"type":{
|
||||
"names":[
|
||||
"Guild"
|
||||
]
|
||||
},
|
||||
"description":"the roles after the update",
|
||||
"name":"newRoles"
|
||||
}
|
||||
],
|
||||
"meta":{
|
||||
"lineno":91,
|
||||
"filename":"Guild.js",
|
||||
"path":"src/structures"
|
||||
},
|
||||
"order":110
|
||||
}
|
||||
*/
|
||||
|
||||
class DocumentedEvent extends DocumentedItem {
|
||||
|
||||
registerMetaInfo(data) {
|
||||
this.directData = data;
|
||||
this.directData.meta = new DocumentedItemMeta(this, data.meta);
|
||||
const newParams = [];
|
||||
data.params = data.params || [];
|
||||
for (const param of data.params) {
|
||||
newParams.push(new DocumentedParam(this, param));
|
||||
}
|
||||
this.directData.params = newParams;
|
||||
}
|
||||
|
||||
serialize() {
|
||||
super.serialize();
|
||||
const { id, name, description, memberof, meta, params } = this.directData;
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
memberof,
|
||||
meta: meta.serialize(),
|
||||
params: params.map(p => p.serialize()),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = DocumentedEvent;
|
||||
@@ -0,0 +1,91 @@
|
||||
const DocumentedItem = require('./DocumentedItem');
|
||||
const DocumentedItemMeta = require('./DocumentedItemMeta');
|
||||
const DocumentedVarType = require('./DocumentedVarType');
|
||||
const DocumentedParam = require('./DocumentedParam');
|
||||
|
||||
/*
|
||||
{
|
||||
"id":"ClientUser#sendTTSMessage",
|
||||
"longname":"ClientUser#sendTTSMessage",
|
||||
"name":"sendTTSMessage",
|
||||
"scope":"instance",
|
||||
"kind":"function",
|
||||
"inherits":"User#sendTTSMessage",
|
||||
"inherited":true,
|
||||
"implements":[
|
||||
"TextBasedChannel#sendTTSMessage"
|
||||
],
|
||||
"description":"Send a text-to-speech message to this channel",
|
||||
"memberof":"ClientUser",
|
||||
"params":[
|
||||
{
|
||||
"type":{
|
||||
"names":[
|
||||
"String"
|
||||
]
|
||||
},
|
||||
"description":"the content to send",
|
||||
"name":"content"
|
||||
}
|
||||
],
|
||||
"examples":[
|
||||
"// send a TTS message..."
|
||||
],
|
||||
"returns":[
|
||||
{
|
||||
"type":{
|
||||
"names":[
|
||||
"Promise.<Message>"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"meta":{
|
||||
"lineno":38,
|
||||
"filename":"TextBasedChannel.js",
|
||||
"path":src/structures/interface"
|
||||
},
|
||||
"order":293
|
||||
}
|
||||
*/
|
||||
|
||||
class DocumentedFunction extends DocumentedItem {
|
||||
|
||||
registerMetaInfo(data) {
|
||||
super.registerMetaInfo(data);
|
||||
this.directData = data;
|
||||
this.directData.meta = new DocumentedItemMeta(this, data.meta);
|
||||
this.directData.returns = new DocumentedVarType(this, data.returns ? data.returns[0].type : {
|
||||
names: ['null'],
|
||||
});
|
||||
const newParams = [];
|
||||
for (const param of data.params) {
|
||||
newParams.push(new DocumentedParam(this, param));
|
||||
}
|
||||
this.directData.params = newParams;
|
||||
}
|
||||
|
||||
serialize() {
|
||||
super.serialize();
|
||||
const {
|
||||
id, name, description, memberof, examples, inherits, inherited, meta, returns, params, access,
|
||||
} = this.directData;
|
||||
const serialized = {
|
||||
id,
|
||||
access,
|
||||
name,
|
||||
description,
|
||||
memberof,
|
||||
examples,
|
||||
inherits,
|
||||
inherited,
|
||||
meta: meta.serialize(),
|
||||
returns: returns.serialize(),
|
||||
params: params.map(p => p.serialize()),
|
||||
};
|
||||
serialized.implements = this.directData.implements;
|
||||
return serialized;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DocumentedFunction;
|
||||
@@ -0,0 +1,32 @@
|
||||
const DocumentedClass = require('./DocumentedClass');
|
||||
|
||||
/*
|
||||
{ id: 'TextBasedChannel',
|
||||
longname: 'TextBasedChannel',
|
||||
name: 'TextBasedChannel',
|
||||
scope: 'global',
|
||||
kind: 'interface',
|
||||
classdesc: 'Interface for classes that have text-channel-like features',
|
||||
params: [],
|
||||
meta:
|
||||
{ lineno: 5,
|
||||
filename: 'TextBasedChannel.js',
|
||||
path: 'src/structures/interface' },
|
||||
order: 175 }
|
||||
*/
|
||||
|
||||
class DocumentedInterface extends DocumentedClass {
|
||||
registerMetaInfo(data) {
|
||||
super.registerMetaInfo(data);
|
||||
this.directData = data;
|
||||
// this.directData.meta = new DocumentedItemMeta(this, data.meta);
|
||||
}
|
||||
|
||||
serialize() {
|
||||
const serialized = super.serialize();
|
||||
serialized.description = this.directData.classdesc;
|
||||
return serialized;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DocumentedInterface;
|
||||
@@ -0,0 +1,17 @@
|
||||
class DocumentedItem {
|
||||
constructor(parent, info) {
|
||||
this.parent = parent;
|
||||
this.directData = {};
|
||||
this.registerMetaInfo(info);
|
||||
}
|
||||
|
||||
registerMetaInfo() {
|
||||
return;
|
||||
}
|
||||
|
||||
serialize() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DocumentedItem;
|
||||
@@ -0,0 +1,29 @@
|
||||
const cwd = (`${process.cwd()}\\`).replace(/\\/g, '/');
|
||||
const backToForward = /\\/g;
|
||||
|
||||
const DocumentedItem = require('./DocumentedItem');
|
||||
|
||||
/*
|
||||
{ lineno: 7,
|
||||
filename: 'VoiceChannel.js',
|
||||
path: 'src/structures' },
|
||||
*/
|
||||
|
||||
class DocumentedItemMeta extends DocumentedItem {
|
||||
|
||||
registerMetaInfo(data) {
|
||||
super.registerMetaInfo(data);
|
||||
this.directData.line = data.lineno;
|
||||
this.directData.file = data.filename;
|
||||
this.directData.path = data.path.replace(backToForward, '/').replace(cwd, '');
|
||||
}
|
||||
|
||||
serialize() {
|
||||
super.serialize();
|
||||
const { line, file, path } = this.directData;
|
||||
return { line, file, path };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = DocumentedItemMeta;
|
||||
@@ -0,0 +1,58 @@
|
||||
const DocumentedItem = require('./DocumentedItem');
|
||||
const DocumentedItemMeta = require('./DocumentedItemMeta');
|
||||
const DocumentedVarType = require('./DocumentedVarType');
|
||||
const DocumentedParam = require('./DocumentedParam');
|
||||
|
||||
/*
|
||||
{ id: 'Client#rest',
|
||||
longname: 'Client#rest',
|
||||
name: 'rest',
|
||||
scope: 'instance',
|
||||
kind: 'member',
|
||||
description: 'The REST manager of the client',
|
||||
memberof: 'Client',
|
||||
type: { names: [ 'RESTManager' ] },
|
||||
access: 'private',
|
||||
meta:
|
||||
{ lineno: 32,
|
||||
filename: 'Client.js',
|
||||
path: 'src/client' },
|
||||
order: 11 }
|
||||
*/
|
||||
|
||||
class DocumentedMember extends DocumentedItem {
|
||||
|
||||
registerMetaInfo(data) {
|
||||
super.registerMetaInfo(data);
|
||||
this.directData = data;
|
||||
this.directData.meta = new DocumentedItemMeta(this, data.meta);
|
||||
this.directData.type = new DocumentedVarType(this, data.type);
|
||||
if (data.properties) {
|
||||
const newProps = [];
|
||||
for (const param of data.properties) {
|
||||
newProps.push(new DocumentedParam(this, param));
|
||||
}
|
||||
this.directData.properties = newProps;
|
||||
} else {
|
||||
data.properties = [];
|
||||
}
|
||||
}
|
||||
|
||||
serialize() {
|
||||
super.serialize();
|
||||
const { id, name, description, memberof, type, access, meta, properties } = this.directData;
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
memberof,
|
||||
type: type.serialize(),
|
||||
access,
|
||||
meta: meta.serialize(),
|
||||
props: properties.map(p => p.serialize()),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = DocumentedMember;
|
||||
@@ -0,0 +1,36 @@
|
||||
const DocumentedItem = require('./DocumentedItem');
|
||||
const DocumentedVarType = require('./DocumentedVarType');
|
||||
|
||||
/*
|
||||
{
|
||||
"type":{
|
||||
"names":[
|
||||
"Guild"
|
||||
]
|
||||
},
|
||||
"description":"the roles after the update",
|
||||
"name":"newRoles"
|
||||
}
|
||||
*/
|
||||
|
||||
class DocumentedParam extends DocumentedItem {
|
||||
|
||||
registerMetaInfo(data) {
|
||||
super.registerMetaInfo(data);
|
||||
this.directData = data;
|
||||
this.directData.type = new DocumentedVarType(this, data.type);
|
||||
}
|
||||
|
||||
serialize() {
|
||||
super.serialize();
|
||||
const { name, description, type, optional } = this.directData;
|
||||
return {
|
||||
name,
|
||||
description,
|
||||
optional,
|
||||
type: type.serialize(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DocumentedParam;
|
||||
@@ -0,0 +1,56 @@
|
||||
const DocumentedItem = require('./DocumentedItem');
|
||||
const DocumentedItemMeta = require('./DocumentedItemMeta');
|
||||
const DocumentedVarType = require('./DocumentedVarType');
|
||||
const DocumentedParam = require('./DocumentedParam');
|
||||
|
||||
/*
|
||||
{ id: 'StringResolvable',
|
||||
longname: 'StringResolvable',
|
||||
name: 'StringResolvable',
|
||||
scope: 'global',
|
||||
kind: 'typedef',
|
||||
description: 'Data that can be resolved to give a String...',
|
||||
type: { names: [ 'String', 'Array', 'Object' ] },
|
||||
meta:
|
||||
{ lineno: 142,
|
||||
filename: 'ClientDataResolver.js',
|
||||
path: 'src/client' },
|
||||
order: 37 }
|
||||
*/
|
||||
|
||||
class DocumentedTypeDef extends DocumentedItem {
|
||||
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
}
|
||||
|
||||
registerMetaInfo(data) {
|
||||
super.registerMetaInfo(data);
|
||||
this.props = new Map();
|
||||
this.directData = data;
|
||||
this.directData.meta = new DocumentedItemMeta(this, data.meta);
|
||||
this.directData.type = new DocumentedVarType(this, data.type);
|
||||
data.properties = data.properties || [];
|
||||
for (const prop of data.properties) {
|
||||
this.props.set(prop.name, new DocumentedParam(this, prop));
|
||||
}
|
||||
}
|
||||
|
||||
serialize() {
|
||||
super.serialize();
|
||||
const { id, name, description, type, access, meta } = this.directData;
|
||||
const serialized = {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
type: type.serialize(),
|
||||
access,
|
||||
meta: meta.serialize(),
|
||||
};
|
||||
serialized.properties = Array.from(this.props.values()).map(p => p.serialize());
|
||||
return serialized;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = DocumentedTypeDef;
|
||||
@@ -0,0 +1,50 @@
|
||||
const DocumentedItem = require('./DocumentedItem');
|
||||
|
||||
/*
|
||||
{
|
||||
"names":[
|
||||
"String"
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
const regex = /([\w]+)([^\w]+)/;
|
||||
const regexG = /([\w]+)([^\w]+)/g;
|
||||
|
||||
function splitVarName(str) {
|
||||
if (str === '*') {
|
||||
return ['*', ''];
|
||||
}
|
||||
const matches = str.match(regexG);
|
||||
const output = [];
|
||||
if (matches) {
|
||||
for (const match of matches) {
|
||||
const groups = match.match(regex);
|
||||
output.push([groups[1], groups[2]]);
|
||||
}
|
||||
} else {
|
||||
output.push([str.match(/(\w+)/g)[0], '']);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
class DocumentedVarType extends DocumentedItem {
|
||||
|
||||
registerMetaInfo(data) {
|
||||
super.registerMetaInfo(data);
|
||||
this.directData = data;
|
||||
}
|
||||
|
||||
serialize() {
|
||||
super.serialize();
|
||||
const names = [];
|
||||
for (const name of this.directData.names) {
|
||||
names.push(splitVarName(name));
|
||||
}
|
||||
return {
|
||||
types: names,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DocumentedVarType;
|
||||
@@ -1,61 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Welcome to discord.js's documentation!
|
||||
======================================
|
||||
|
||||
discord.js is an easy-to-use and intuitive JavaScript API for Discord_. It's fairly high level, so if you're
|
||||
looking for something low level, check out `discord.io`_.
|
||||
|
||||
Feel free to make any contributions you want, whether it be through creating an issue, giving a suggestion or making a pull request!
|
||||
|
||||
.. note:: This documentation is still a work-in-progress, apologies if something isn't yet documented!
|
||||
|
||||
.. _docs:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: General
|
||||
|
||||
installing
|
||||
migrating
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Documentation
|
||||
|
||||
docs_client
|
||||
docs_server
|
||||
docs_user
|
||||
docs_message
|
||||
docs_invite
|
||||
docs_voiceconnection
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Channel Documentation
|
||||
|
||||
docs_channel
|
||||
docs_pmchannel
|
||||
docs_serverchannel
|
||||
docs_textchannel
|
||||
docs_voicechannel
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Permission Documentation
|
||||
|
||||
docs_permissionconstants
|
||||
docs_role
|
||||
docs_permissionoverwrite
|
||||
docs_channelpermissions
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Utility Documentation
|
||||
|
||||
docs_cache
|
||||
docs_equality
|
||||
docs_resolvables
|
||||
|
||||
.. _Discord : https://discordapp.com/
|
||||
.. _discord.io : https://github.com/izy521/discord.io
|
||||
@@ -1,51 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Installing discord.js
|
||||
=====================
|
||||
|
||||
To install discord.js, you need a few dependencies.
|
||||
|
||||
.. warning:: **When installing with any of these methods, you'll encounter some errors.** This is because an optional dependency isn't working properly, but discord.js should still work fine.
|
||||
|
||||
-----------
|
||||
|
||||
Windows
|
||||
-------
|
||||
|
||||
------------
|
||||
|
||||
- You need `Visual Studio`_ and `Python 2.7`_.
|
||||
|
||||
Your Visual Studio installation ideally has to be recent, but you can try installing without it first. You can use **Express, Community, Enteprise** or any others apart from ``VS Code``.
|
||||
|
||||
After you have installed these things, to install just run: ``npm install --save --msvs_version=2015 discord.js`` to install the latest version of discord.js for your project.
|
||||
|
||||
Additional Audio Support
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- Install `ffmpeg`_ and add it to your PATH.
|
||||
|
||||
-----------
|
||||
|
||||
Linux
|
||||
-----
|
||||
|
||||
-----------
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ apt-get install make build-essentials
|
||||
$ npm install --save discord.js
|
||||
|
||||
|
||||
|
||||
Additional Audio Support
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ apt-get install libav-tools
|
||||
|
||||
.. _Visual Studio : https://www.visualstudio.com/downloads/download-visual-studio-vs
|
||||
.. _Python 2.7 : https://www.python.org/download/releases/2.7.8/
|
||||
.. _ffmpeg : https://www.ffmpeg.org/download.html
|
||||
-263
@@ -1,263 +0,0 @@
|
||||
@ECHO OFF
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set BUILDDIR=_build
|
||||
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
|
||||
set I18NSPHINXOPTS=%SPHINXOPTS% .
|
||||
if NOT "%PAPER%" == "" (
|
||||
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
|
||||
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
if "%1" == "help" (
|
||||
:help
|
||||
echo.Please use `make ^<target^>` where ^<target^> is one of
|
||||
echo. html to make standalone HTML files
|
||||
echo. dirhtml to make HTML files named index.html in directories
|
||||
echo. singlehtml to make a single large HTML file
|
||||
echo. pickle to make pickle files
|
||||
echo. json to make JSON files
|
||||
echo. htmlhelp to make HTML files and a HTML help project
|
||||
echo. qthelp to make HTML files and a qthelp project
|
||||
echo. devhelp to make HTML files and a Devhelp project
|
||||
echo. epub to make an epub
|
||||
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
|
||||
echo. text to make text files
|
||||
echo. man to make manual pages
|
||||
echo. texinfo to make Texinfo files
|
||||
echo. gettext to make PO message catalogs
|
||||
echo. changes to make an overview over all changed/added/deprecated items
|
||||
echo. xml to make Docutils-native XML files
|
||||
echo. pseudoxml to make pseudoxml-XML files for display purposes
|
||||
echo. linkcheck to check all external links for integrity
|
||||
echo. doctest to run all doctests embedded in the documentation if enabled
|
||||
echo. coverage to run coverage check of the documentation if enabled
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "clean" (
|
||||
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
|
||||
del /q /s %BUILDDIR%\*
|
||||
goto end
|
||||
)
|
||||
|
||||
|
||||
REM Check if sphinx-build is available and fallback to Python version if any
|
||||
%SPHINXBUILD% 2> nul
|
||||
if errorlevel 9009 goto sphinx_python
|
||||
goto sphinx_ok
|
||||
|
||||
:sphinx_python
|
||||
|
||||
set SPHINXBUILD=python -m sphinx.__init__
|
||||
%SPHINXBUILD% 2> nul
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:sphinx_ok
|
||||
|
||||
|
||||
if "%1" == "html" (
|
||||
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "dirhtml" (
|
||||
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "singlehtml" (
|
||||
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "pickle" (
|
||||
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can process the pickle files.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "json" (
|
||||
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can process the JSON files.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "htmlhelp" (
|
||||
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can run HTML Help Workshop with the ^
|
||||
.hhp project file in %BUILDDIR%/htmlhelp.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "qthelp" (
|
||||
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
||||
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
||||
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\discordjs.qhcp
|
||||
echo.To view the help file:
|
||||
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\discordjs.ghc
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "devhelp" (
|
||||
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "epub" (
|
||||
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The epub file is in %BUILDDIR%/epub.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latex" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latexpdf" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
cd %BUILDDIR%/latex
|
||||
make all-pdf
|
||||
cd %~dp0
|
||||
echo.
|
||||
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latexpdfja" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
cd %BUILDDIR%/latex
|
||||
make all-pdf-ja
|
||||
cd %~dp0
|
||||
echo.
|
||||
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "text" (
|
||||
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The text files are in %BUILDDIR%/text.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "man" (
|
||||
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The manual pages are in %BUILDDIR%/man.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "texinfo" (
|
||||
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "gettext" (
|
||||
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "changes" (
|
||||
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.The overview file is in %BUILDDIR%/changes.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "linkcheck" (
|
||||
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Link check complete; look for any errors in the above output ^
|
||||
or in %BUILDDIR%/linkcheck/output.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "doctest" (
|
||||
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Testing of doctests in the sources finished, look at the ^
|
||||
results in %BUILDDIR%/doctest/output.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "coverage" (
|
||||
%SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Testing of coverage in the sources finished, look at the ^
|
||||
results in %BUILDDIR%/coverage/python.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "xml" (
|
||||
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The XML files are in %BUILDDIR%/xml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "pseudoxml" (
|
||||
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
|
||||
goto end
|
||||
)
|
||||
|
||||
:end
|
||||
@@ -1,45 +0,0 @@
|
||||
.. include:: ./vars.rst
|
||||
|
||||
Updating to v5.0.0
|
||||
==================
|
||||
|
||||
If you're coming from versions below v5, you might find some changes. Here are the major changes:
|
||||
|
||||
Change 1
|
||||
--------
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
// OLD:
|
||||
|
||||
client.getUser();
|
||||
client.getServer();
|
||||
server.getMember(); // etc etc
|
||||
|
||||
// NEW:
|
||||
|
||||
client.users.get();
|
||||
client.servers.get();
|
||||
client.members.get();
|
||||
|
||||
Change 2
|
||||
--------
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
// OLD:
|
||||
|
||||
client.on("serverNewMember", (member, server) => {
|
||||
|
||||
});
|
||||
|
||||
// NEW:
|
||||
|
||||
client.on("serverNewMember", (server, user) => {
|
||||
|
||||
});
|
||||
|
||||
Change 3
|
||||
---------
|
||||
|
||||
The Member Class has been removed, meaning you can't use ``member.permissionsIn(channel)``. To get permissions, use ``channel.permissionsOf(user)``.
|
||||
@@ -1,10 +0,0 @@
|
||||
Troubleshooting
|
||||
===============
|
||||
|
||||
Occasionally, the API can stop working for whatever reason. If it was working previously and it stopped working on the same version, it means that there's been a change to the Discord API. In this case, please `make an issue`_ if one relating to a similar issue doesn't exist. Please post a stacktrace if there is one, and be as detailed as possible - *"the API isn't working"* doesn't help at all.
|
||||
|
||||
If there is already an issue, feel free to comment that you're also experiencing the same thing. This helps to see how widespread the bug is.
|
||||
|
||||
You can try reconnecting before submitting an issue, as sometimes some of the servers may be slightly different.
|
||||
|
||||
.. _make an issue : https://github.com/hydrabolt/discord.js/issues
|
||||
@@ -1,29 +0,0 @@
|
||||
.. _Client : ./docs_client.html
|
||||
.. _Cache : ./docs_cache.html
|
||||
.. _User : ./docs_user.html
|
||||
.. _Users : ./docs_user.html
|
||||
.. _Server : ./docs_server.html
|
||||
.. _Channel : ./docs_channel.html
|
||||
.. _ServerChannel : ./docs_serverchannel.html
|
||||
.. _TextChannel : ./docs_textchannel.html
|
||||
.. _VoiceChannel : ./docs_voicechannel.html
|
||||
.. _PMChannel : ./docs_pmchannel.html
|
||||
.. _Message : ./docs_message.html
|
||||
.. _Invite : ./docs_invite.html
|
||||
.. _Equality : ./docs_equality.html
|
||||
.. _Role : ./docs_role.html
|
||||
.. _ChannelPermissions : ./docs_channelpermissions.html
|
||||
.. _PermissionOverwrite : ./docs_permissionoverwrite.html
|
||||
.. _Permission Constants : ./docs_permissionconstants.html
|
||||
.. _Resolvables : ./docs_resolvables.html
|
||||
.. _VoiceConnection : ./docs_voiceconnection.html
|
||||
.. _Promises : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
||||
.. _EventEmitter : https://nodejs.org/api/events.html#events_class_events_eventemitter
|
||||
.. _Channel Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#channel-resolvable
|
||||
.. _String Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#string-resolvable
|
||||
.. _Message Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#message-resolvable
|
||||
.. _Server Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#server-resolvable
|
||||
.. _Invite Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#invite-id-resolvable
|
||||
.. _User Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#user-resolvable
|
||||
.. _Base64 Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#base64-resolvable
|
||||
.. _VoiceChannel Resolvable : http://discordjs.readthedocs.org/en/rewrite-docs/docs_resolvables.html#voice-channel-resolvable
|
||||
@@ -1,39 +0,0 @@
|
||||
/* global process */
|
||||
/*
|
||||
this is the entrypoint file, when node finally catches
|
||||
up with all ES6 drafts etc, the entrypoint file will stop
|
||||
using the transpiled ES5 and switch straight to the ES6
|
||||
code. This allows for easier debugging and potentially
|
||||
faster execution!
|
||||
*/
|
||||
var v = process.version;
|
||||
if(v.charAt(0) === "v"){
|
||||
v = v.substring(1);
|
||||
}
|
||||
|
||||
v = v.split(".");
|
||||
|
||||
var major = parseInt(v[0]),
|
||||
minor = parseInt(v[1]),
|
||||
patch = parseInt(v[2]);
|
||||
|
||||
if((major == 0 && minor < 12) || (major == 0 && minor == 12 && patch < 7)) {
|
||||
if(!process.env.OVERRIDE_DISCORD_MIN_VERSION) {
|
||||
throw new Error(
|
||||
"discord.js doesn't support node versions less than 0.12.7.\n"+
|
||||
"If you /really/ want to run it on this node " + process.version + ", then set OVERRIDE_DISCORD_MIN_VERSION as an environment variable.\n"+
|
||||
"This is unsupported and WILL cause problems."
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// at the moment no node version has full ES6 support
|
||||
use5();
|
||||
|
||||
function use6(){
|
||||
module.exports = require("./src/index.js");
|
||||
}
|
||||
|
||||
function use5(){
|
||||
module.exports = require("./lib/index.js");
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# Warning!
|
||||
|
||||
### These examples are not updated to v5.0.0, may not work!
|
||||
@@ -1,3 +0,0 @@
|
||||
# Analysis Bot
|
||||
|
||||
Analysis Bot provides Analysis and Utility to Discord Users!
|
||||
@@ -1,165 +0,0 @@
|
||||
/* global process */
|
||||
|
||||
var Discord = require("../../");
|
||||
var bot = new Discord.Client();
|
||||
var auth = require("../auth.json");
|
||||
var request = require("superagent");
|
||||
|
||||
var loose = false;
|
||||
|
||||
bot.on("message", msg => {
|
||||
|
||||
if (~msg.content.indexOf("https://discord.gg/")) {
|
||||
bot.joinServer(msg.content.substr(msg.content.indexOf("https://discord.gg/"), "https://discord.gg/".length + 16));
|
||||
}
|
||||
|
||||
if (!msg.content.startsWith("$")) return;
|
||||
|
||||
msg.content = msg.content.substr(1);
|
||||
|
||||
if (msg.content === "stats") {
|
||||
msg.reply([
|
||||
"I am connected/have access to:",
|
||||
`${bot.servers.length} servers`,
|
||||
`${bot.channels.length} channels`,
|
||||
`${bot.users.length} users`,
|
||||
].join("\n"));
|
||||
}
|
||||
|
||||
if (msg.content.startsWith("startplaying")) {
|
||||
var game = msg.content.split(" ").slice(1).join(" ");
|
||||
bot.setPlayingGame(game);
|
||||
}
|
||||
|
||||
if (msg.content.startsWith("setname") && loose) {
|
||||
bot.setUsername(msg.content.split(" ").slice(1).join(" ")).then(() => {
|
||||
msg.reply("done!");
|
||||
});
|
||||
}
|
||||
|
||||
if (msg.content === "updateav") {
|
||||
request
|
||||
.get("https://api.github.com/search/repositories?q=discord.js")
|
||||
.end((err, res) => {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
var text = res.body.items[0].stargazers_count
|
||||
|
||||
bot.updateDetails({
|
||||
username : "d.js star bot - " + text,
|
||||
avatar: getStars(text)
|
||||
}).then(() => {
|
||||
msg.reply("success!");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (msg.content.startsWith("setavatar") && loose) {
|
||||
request
|
||||
.get(msg.content.split(" ")[1])
|
||||
.end((err, res) => {
|
||||
bot.updateDetails({
|
||||
avatar: getStars(text)
|
||||
}).then(() => {
|
||||
|
||||
msg.reply("done!");
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (msg.content === "away") {
|
||||
bot.setStatusIdle();
|
||||
}
|
||||
|
||||
if (msg.content === "here") {
|
||||
bot.setStatusOnline();
|
||||
}
|
||||
|
||||
if (msg.content === "randomUser") {
|
||||
var random = bot.users.random();
|
||||
msg.reply([
|
||||
random.username,
|
||||
"avatar: ", random.avatarURL
|
||||
].join("\n"));
|
||||
}
|
||||
|
||||
if (msg.content.startsWith("mimic") && loose) {
|
||||
var toMimic = msg.mentions[0];
|
||||
|
||||
if (!toMimic) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!toMimic.avatar) {
|
||||
bot.updateDetails({
|
||||
username: toMimic.username,
|
||||
avatar: null
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
request
|
||||
.get(toMimic.avatarURL)
|
||||
.end((err, res) => {
|
||||
bot.updateDetails({
|
||||
username: toMimic.username,
|
||||
avatar: res.body
|
||||
}).then(() => {
|
||||
|
||||
msg.reply("done!");
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
setInterval(() => {
|
||||
|
||||
request
|
||||
.get("https://api.github.com/search/repositories?q=discord.js")
|
||||
.end((err, res) => {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
var text = res.body.items[0].stargazers_count
|
||||
|
||||
bot.updateDetails({
|
||||
username : "d.js star bot - " + text,
|
||||
avatar: getStars(text)
|
||||
}).then(() => {
|
||||
console.log("many successes");
|
||||
});
|
||||
});
|
||||
|
||||
}, 60000);
|
||||
|
||||
bot.on("disconnected", () => {
|
||||
console.log("Disconnected, exiting!");
|
||||
process.exit();
|
||||
})
|
||||
|
||||
bot.login(auth.email, auth.password);
|
||||
|
||||
function getStars(text) {
|
||||
var Canvas = require('canvas')
|
||||
, Image = Canvas.Image
|
||||
, canvas = new Canvas(90, 90)
|
||||
, ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = "black";
|
||||
ctx.fillRect(0, 0, 90, 90);
|
||||
|
||||
ctx.font = '45px Arial';
|
||||
ctx.fillStyle = "white";
|
||||
ctx.fillText(text, (ctx.measureText(text).width / 2) - 5, 60);
|
||||
|
||||
ctx.strokeStyle = 'rgb(255,255,255)';
|
||||
|
||||
return canvas.toDataURL();
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"email" : "your discord email here",
|
||||
"password" : "your discord password here"
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
this bot is an avatar bot, and will give a user their avatar's URL
|
||||
*/
|
||||
|
||||
var Discord = require("../");
|
||||
|
||||
var AuthDetails = require("./auth.json");
|
||||
|
||||
var bot = new Discord.Client();
|
||||
|
||||
bot.on("ready", () => {
|
||||
console.log("Ready to begin! Serving in " + bot.channels.length + " channels");
|
||||
});
|
||||
|
||||
bot.on("disconnected", () => {
|
||||
|
||||
console.log("Disconnected!");
|
||||
process.exit(1); //exit node.js with an error
|
||||
|
||||
});
|
||||
|
||||
bot.on("message", (msg) => {
|
||||
|
||||
if( msg.content === "avatar" ){
|
||||
// if the message was avatar
|
||||
bot.reply( msg, msg.sender.avatarURL );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
bot.login(AuthDetails.email, AuthDetails.password);
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES6"
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
this bot is a permissions bot and is currently working
|
||||
with the experimental additions. Some functions may
|
||||
change in the future.
|
||||
*/
|
||||
|
||||
var Discord = require("../../");
|
||||
|
||||
// Get the email and password
|
||||
var AuthDetails = require("../auth.json");
|
||||
|
||||
var bot = new Discord.Client();
|
||||
|
||||
bot.on("ready", function () {
|
||||
console.log("Ready to begin! Serving in " + bot.channels.length + " channels");
|
||||
});
|
||||
|
||||
bot.on("disconnected", function () {
|
||||
|
||||
console.log("Disconnected!");
|
||||
process.exit(1); //exit node.js with an error
|
||||
|
||||
});
|
||||
|
||||
bot.on("message", function (msg) {
|
||||
if (msg.content === "skype") {
|
||||
|
||||
//stop the user from speaking in the channel:
|
||||
bot.overwritePermissions(msg.channel, msg.sender, {
|
||||
sendMessages: false
|
||||
});
|
||||
|
||||
// send a barely funny message ;)
|
||||
bot.reply(msg, "how dare you mention that!");
|
||||
|
||||
}
|
||||
|
||||
if (msg.content === "discord") {
|
||||
|
||||
// if the role doesn't exist, make it
|
||||
bot.createRoleIfNotExists(msg.channel.server, {
|
||||
name: "good people",
|
||||
color: Discord.Colors.BLUE, // colour of blue
|
||||
hoist: true // make a seperate category in the users list
|
||||
}).then(addUserToList).catch(console.log);
|
||||
|
||||
function addUserToList(role, alreadyExists) {
|
||||
console.log(arguments);
|
||||
bot.addMemberToRole(msg.sender, role);
|
||||
bot.reply(msg, "welcome to the good people! " + alreadyExists);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (msg.content === "remove me") {
|
||||
// remove the user from the good people list, if it exists
|
||||
var found = false;
|
||||
|
||||
for (var role of msg.channel.server.roles) {
|
||||
if (role.name === "good people") {
|
||||
found = role;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
// if the role exists
|
||||
|
||||
if (msg.sender.hasRole(role)) {
|
||||
// remove the member from the role
|
||||
bot.removeMemberFromRole(msg.sender, role);
|
||||
bot.reply(msg, "removed!")
|
||||
} else {
|
||||
bot.reply(msg, "you're not in the role!");
|
||||
}
|
||||
|
||||
} else {
|
||||
// role doesn't exist
|
||||
bot.reply(msg, "the role doesn't even exist!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
bot.login(AuthDetails.email, AuthDetails.password);
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
this bot will demonstrate the different ways you
|
||||
can create colors in Discord.
|
||||
*/
|
||||
|
||||
var Discord = require("../../");
|
||||
|
||||
// Get the email and password
|
||||
var AuthDetails = require("../auth.json");
|
||||
|
||||
var bot = new Discord.Client();
|
||||
|
||||
bot.on("ready", function () {
|
||||
console.log("Ready to begin! Serving in " + bot.channels.length + " channels");
|
||||
});
|
||||
|
||||
bot.on("disconnected", function () {
|
||||
|
||||
console.log("Disconnected!");
|
||||
process.exit(1); //exit node.js with an error
|
||||
|
||||
});
|
||||
|
||||
bot.on("message", function (msg) {
|
||||
|
||||
// to use this example, you first have to send 'create role'
|
||||
// you can then change colors afterwards.
|
||||
|
||||
if (msg.content === "create role") {
|
||||
// create the role and add the user to it
|
||||
|
||||
bot.createRoleIfNotExists(msg.channel.server, {
|
||||
name: "Custom Colors",
|
||||
hoist: true, // so it is visible in the members list
|
||||
}).then(function (permission) {
|
||||
// this is executed when the role has been created or exists
|
||||
|
||||
// adds the sender to the role
|
||||
bot.addMemberToRole(msg.sender, permission).then(function () {
|
||||
bot.reply(msg, "added you to the role!");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (msg.content.indexOf("preset color") === 0) {
|
||||
|
||||
// set the role to a preset color
|
||||
var colorName = msg.content.split(" ")[2];
|
||||
|
||||
// get the role by its name
|
||||
var role = msg.channel.server.getRole("name", "Custom Colors");
|
||||
|
||||
// if the color exists as a preset
|
||||
if (Discord.Color[colorName]) {
|
||||
|
||||
// update the role with the new color
|
||||
bot.updateRole(role, {
|
||||
color: Discord.Color[colorName]
|
||||
}).then(function (role) {
|
||||
// this executes if the change was correct
|
||||
bot.reply(msg, "done! using the color " + Discord.Color.toHex(role.color));
|
||||
});
|
||||
|
||||
} else {
|
||||
bot.reply(msg, "that color isn't a preset color!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (msg.content.indexOf("custom color") === 0) {
|
||||
|
||||
// valid custom colors must follow the format of any of the following:
|
||||
/*
|
||||
#ff0000 <- valid 7 digit hex (including #)
|
||||
ff0000 <- valid 6 digit hex
|
||||
16711680 <- valid decimal number (this if #ff0000 as a decimal)
|
||||
*/
|
||||
|
||||
var colorName = msg.content.split(" ")[2];
|
||||
|
||||
// get the role by its name
|
||||
var role = msg.channel.server.getRole("name", "Custom Colors");
|
||||
|
||||
// updates the role with the given color
|
||||
bot.updateRole(role, {
|
||||
color: colorName
|
||||
}).then(function (role) {
|
||||
|
||||
// this executes if the change was successful
|
||||
bot.reply(msg, "done! using the color " + Discord.Color.toHex(role.color));
|
||||
|
||||
}).catch(function (e) {
|
||||
|
||||
// this executes if it wasn't successful
|
||||
bot.reply(msg, "an error occurred. Was that a valid hex/dec color?");
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
bot.login(AuthDetails.email, AuthDetails.password);
|
||||
@@ -1,50 +0,0 @@
|
||||
/* this bot will see if a user can send TTS messages */
|
||||
|
||||
var Discord = require("../../");
|
||||
|
||||
Discord.patchStrings();
|
||||
|
||||
var AuthDetails = require("../auth.json");
|
||||
|
||||
var bot = new Discord.Client();
|
||||
|
||||
bot.on("ready", () => {
|
||||
console.log("Ready to begin!");
|
||||
});
|
||||
|
||||
bot.on("message", (msg) => {
|
||||
|
||||
if(msg.content === "can I tts?"){
|
||||
|
||||
var user = msg.sender;
|
||||
|
||||
// get the evaluated permissions for a user in the channel they asked
|
||||
var permissions = msg.channel.permissionsOf(user);
|
||||
|
||||
if(permissions.sendTTSMessages){
|
||||
bot.reply(msg, "You " + "can".italic.bold + " send TTS messages.");
|
||||
}else{
|
||||
bot.reply(msg, "You " + "can't".italic.bold + " send TTS messages.");
|
||||
}
|
||||
|
||||
}else if(msg.content === "what are my full permissions?"){
|
||||
|
||||
var user = msg.sender;
|
||||
|
||||
// get the serialised permissions of the user
|
||||
var permissions = msg.channel.permissionsOf(user).serialise();
|
||||
|
||||
// if you want to stringify permissions, they need to be serialised first.
|
||||
|
||||
bot.reply(msg, JSON.stringify(permissions, null, 4).replace(/true/g, "**true**"));
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
for a list of more permissions, go to
|
||||
https://github.com/hydrabolt/discord.js/blob/master/src/EvaluatedPermissions.js
|
||||
*/
|
||||
|
||||
})
|
||||
|
||||
bot.login(AuthDetails.email, AuthDetails.password);
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
this bot is a ping pong bot, and every time a message
|
||||
beginning with "ping" is sent, it will reply with
|
||||
"pong!".
|
||||
*/
|
||||
|
||||
var Discord = require("../");
|
||||
|
||||
// Get the email and password
|
||||
var AuthDetails = require("./auth.json");
|
||||
|
||||
var bot = new Discord.Client();
|
||||
|
||||
//when the bot is ready
|
||||
bot.on("ready", function () {
|
||||
console.log("Ready to begin! Serving in " + bot.channels.length + " channels");
|
||||
});
|
||||
|
||||
//when the bot disconnects
|
||||
bot.on("disconnected", function () {
|
||||
//alert the console
|
||||
console.log("Disconnected!");
|
||||
|
||||
//exit node.js with an error
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
//when the bot receives a message
|
||||
bot.on("message", function (msg) {
|
||||
//if message begins with "ping"
|
||||
if (msg.content.indexOf("ping") === 0) {
|
||||
//send a message to the channel the ping message was sent in.
|
||||
bot.sendMessage(msg.channel, "pong!");
|
||||
|
||||
//alert the console
|
||||
console.log("pong-ed " + msg.author.username);
|
||||
}
|
||||
});
|
||||
|
||||
bot.login(AuthDetails.email, AuthDetails.password);
|
||||
@@ -1,33 +0,0 @@
|
||||
/* this bot will send an image to a channel */
|
||||
|
||||
var Discord = require("../");
|
||||
|
||||
var AuthDetails = require("./auth.json");
|
||||
|
||||
var bot = new Discord.Client();
|
||||
|
||||
bot.on("ready", () => {
|
||||
console.log("Ready to begin!");
|
||||
});
|
||||
|
||||
bot.on("message", (msg) => {
|
||||
|
||||
if (msg.content === "photos") {
|
||||
|
||||
bot.sendFile( msg.channel, "./test/image.png", "photo.png", (err, msg) => {
|
||||
if(err)
|
||||
console.log("couldn't send image:", err);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if( msg.content === "file" ) {
|
||||
bot.sendFile( msg.channel, new Buffer("Text in a file!"), "file.txt", (err, msg) => {
|
||||
if(err)
|
||||
console.log("couldn't send file:", err);
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
bot.login(AuthDetails.email, AuthDetails.password);
|
||||
@@ -1,53 +0,0 @@
|
||||
module.exports = function (grunt) {
|
||||
|
||||
require('load-grunt-tasks')(grunt);
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON("package.json"),
|
||||
// define source files and their destinations
|
||||
babel: {
|
||||
options: {
|
||||
loose: "all",
|
||||
compact: !grunt.option('dev')
|
||||
},
|
||||
dist: {
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: "src/",
|
||||
src: ["**/**.*"],
|
||||
dest: "lib/",
|
||||
ext: ".js"
|
||||
}]
|
||||
}
|
||||
},
|
||||
browserify: {
|
||||
dist: {
|
||||
files: {
|
||||
'web-dist/discord.<%= pkg.version %>.js': ["lib/index.js"],
|
||||
},
|
||||
options: {
|
||||
browserifyOptions: {
|
||||
standalone: "Discord"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
min: {
|
||||
files: {
|
||||
"./web-dist/discord.min.<%= pkg.version %>.js": "./web-dist/discord.<%= pkg.version %>.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// load plugins
|
||||
grunt.loadNpmTasks('grunt-browserify');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
|
||||
// register at least this one task
|
||||
grunt.registerTask('default', ['babel']);
|
||||
grunt.registerTask('web', ['browserify', "uglify"]);
|
||||
grunt.registerTask("dist", ["babel", "browserify", "uglify"])
|
||||
|
||||
};
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES6",
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _InternalClient=require("./InternalClient");var _InternalClient2=_interopRequireDefault(_InternalClient);var _events=require("events");var _events2=_interopRequireDefault(_events);var _StructuresPMChannel=require("../Structures/PMChannel");var _StructuresPMChannel2=_interopRequireDefault(_StructuresPMChannel); // This utility function creates an anonymous error handling wrapper function
|
||||
// for a given callback. It is used to allow error handling inside the callback
|
||||
// and using other means.
|
||||
function errorCallback(callback){return function(error){callback(error);throw error;};} // This utility function creates an anonymous handler function to separate the
|
||||
// error and the data arguments inside a callback and return the data if it is
|
||||
// eventually done (for promise propagation).
|
||||
function dataCallback(callback){return function(data){callback(null,data);return data;};}var Client=(function(_EventEmitter){_inherits(Client,_EventEmitter); /*
|
||||
this class is an interface for the internal
|
||||
client.
|
||||
*/function Client(){var options=arguments.length <= 0 || arguments[0] === undefined?{}:arguments[0];_classCallCheck(this,Client);_EventEmitter.call(this);this.options = options || {};this.options.compress = options.compress || true;this.options.revive = options.revive || false;this.options.rate_limit_as_error = options.rate_limit_as_error || false;this.internal = new _InternalClient2["default"](this);} // def login
|
||||
Client.prototype.login = function login(email,password){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, token*/{}:arguments[2];return this.internal.login(email,password).then(dataCallback(callback),errorCallback(callback));}; // def logout
|
||||
Client.prototype.logout = function logout(){var callback=arguments.length <= 0 || arguments[0] === undefined?function() /*err, {}*/{}:arguments[0];return this.internal.logout().then(dataCallback(callback),errorCallback(callback));}; // def destroy
|
||||
Client.prototype.destroy = function destroy(){var _this=this;var callback=arguments.length <= 0 || arguments[0] === undefined?function() /*err, {}*/{}:arguments[0];this.internal.logout().then(function(){return _this.internal.disconnected(true);}).then(dataCallback(callback),errorCallback(callback));}; // def sendMessage
|
||||
Client.prototype.sendMessage = function sendMessage(where,content){var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, msg*/{}:arguments[3];if(typeof options === "function"){ // options is the callback
|
||||
callback = options;}return this.internal.sendMessage(where,content,options).then(dataCallback(callback),errorCallback(callback));}; // def sendTTSMessage
|
||||
Client.prototype.sendTTSMessage = function sendTTSMessage(where,content){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, msg*/{}:arguments[2];return this.sendMessage(where,content,{tts:true}).then(dataCallback(callback),errorCallback(callback));}; // def reply
|
||||
Client.prototype.reply = function reply(where,content){var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, msg*/{}:arguments[3];if(typeof options === "function"){ // options is the callback
|
||||
callback = options;}var msg=this.internal.resolver.resolveMessage(where);if(msg){if(!(msg.channel instanceof _StructuresPMChannel2["default"])){content = msg.author + ", " + content;}return this.internal.sendMessage(msg,content,options).then(dataCallback(callback),errorCallback(callback));}var err=new Error("Destination not resolvable to a message!");callback(err);return Promise.reject(err);}; // def replyTTS
|
||||
Client.prototype.replyTTS = function replyTTS(where,content){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, msg*/{}:arguments[2];return this.reply(where,content,{tts:true}).then(dataCallback(callback),errorCallback(callback));}; // def deleteMessage
|
||||
Client.prototype.deleteMessage = function deleteMessage(msg){var options=arguments.length <= 1 || arguments[1] === undefined?{}:arguments[1];var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];if(typeof options === "function"){ // options is the callback
|
||||
callback = options;}return this.internal.deleteMessage(msg,options).then(dataCallback(callback),errorCallback(callback));}; //def updateMessage
|
||||
Client.prototype.updateMessage = function updateMessage(msg,content){var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, msg*/{}:arguments[3];if(typeof options === "function"){ // options is the callback
|
||||
callback = options;}return this.internal.updateMessage(msg,content,options).then(dataCallback(callback),errorCallback(callback));}; // def getChannelLogs
|
||||
Client.prototype.getChannelLogs = function getChannelLogs(where){var limit=arguments.length <= 1 || arguments[1] === undefined?500:arguments[1];var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, logs*/{}:arguments[3];if(typeof options === "function"){ // options is the callback
|
||||
callback = options;}return this.internal.getChannelLogs(where,limit,options).then(dataCallback(callback),errorCallback(callback));}; // def getBans
|
||||
Client.prototype.getBans = function getBans(where){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, bans*/{}:arguments[1];return this.internal.getBans(where).then(dataCallback(callback),errorCallback(callback));}; // def sendFile
|
||||
Client.prototype.sendFile = function sendFile(where,attachment){var name=arguments.length <= 2 || arguments[2] === undefined?"image.png":arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, m*/{}:arguments[3];return this.internal.sendFile(where,attachment,name).then(dataCallback(callback),errorCallback(callback));}; // def joinServer
|
||||
Client.prototype.joinServer = function joinServer(invite){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, srv*/{}:arguments[1];return this.internal.joinServer(invite).then(dataCallback(callback),errorCallback(callback));}; // def createServer
|
||||
Client.prototype.createServer = function createServer(name){var region=arguments.length <= 1 || arguments[1] === undefined?"london":arguments[1];var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, srv*/{}:arguments[2];return this.internal.createServer(name,region).then(dataCallback(callback),errorCallback(callback));}; // def leaveServer
|
||||
Client.prototype.leaveServer = function leaveServer(server){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.leaveServer(server).then(dataCallback(callback),errorCallback(callback));}; // def deleteServer
|
||||
Client.prototype.deleteServer = function deleteServer(server){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.leaveServer(server).then(dataCallback(callback),errorCallback(callback));}; // def createChannel
|
||||
Client.prototype.createChannel = function createChannel(server,name){var type=arguments.length <= 2 || arguments[2] === undefined?"text":arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, channel*/{}:arguments[3];if(typeof type === "function"){ // options is the callback
|
||||
callback = type;}return this.internal.createChannel(server,name,type).then(dataCallback(callback),errorCallback(callback));}; // def deleteChannel
|
||||
Client.prototype.deleteChannel = function deleteChannel(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.deleteChannel(channel).then(dataCallback(callback),errorCallback(callback));}; // def banMember
|
||||
Client.prototype.banMember = function banMember(user,server){var length=arguments.length <= 2 || arguments[2] === undefined?1:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, {}*/{}:arguments[3];if(typeof length === "function"){ // length is the callback
|
||||
callback = length;}return this.internal.banMember(user,server,length).then(dataCallback(callback),errorCallback(callback));}; // def unbanMember
|
||||
Client.prototype.unbanMember = function unbanMember(user,server){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.unbanMember(user,server).then(dataCallback(callback),errorCallback(callback));}; // def kickMember
|
||||
Client.prototype.kickMember = function kickMember(user,server){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.kickMember(user,server).then(dataCallback(callback),errorCallback(callback));}; // def createRole
|
||||
Client.prototype.createRole = function createRole(server){var data=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, role*/{}:arguments[2];if(typeof data === "function"){ // data is the callback
|
||||
callback = data;}return this.internal.createRole(server,data).then(dataCallback(callback),errorCallback(callback));}; // def updateRole
|
||||
Client.prototype.updateRole = function updateRole(role){var data=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, role*/{}:arguments[2];if(typeof data === "function"){ // data is the callback
|
||||
callback = data;}return this.internal.updateRole(role,data).then(dataCallback(callback),errorCallback(callback));}; // def deleteRole
|
||||
Client.prototype.deleteRole = function deleteRole(role){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.deleteRole(role).then(dataCallback(callback),errorCallback(callback));}; // def addMemberToRole
|
||||
Client.prototype.addMemberToRole = function addMemberToRole(member,role){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.addMemberToRole(member,role).then(dataCallback(callback),errorCallback(callback));}; // def addUserToRole
|
||||
Client.prototype.addUserToRole = function addUserToRole(member,role){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.addMemberToRole(member,role,callback);}; // def removeMemberFromRole
|
||||
Client.prototype.removeMemberFromRole = function removeMemberFromRole(member,role){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.removeMemberFromRole(member,role).then(dataCallback(callback),errorCallback(callback));}; // def removeUserFromRole
|
||||
Client.prototype.removeUserFromRole = function removeUserFromRole(member,role){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.removeMemberFromRole(member,role,callback);}; // def addMemberToRole
|
||||
Client.prototype.addMemberToRoles = function addMemberToRoles(member,roles){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.addMemberToRoles(member,roles).then(dataCallback(callback),errorCallback(callback));}; // def addUserToRole
|
||||
Client.prototype.addUserToRoles = function addUserToRoles(member,roles){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.addMemberToRoles(member,roles,callback);}; // def removeMemberFromRole
|
||||
Client.prototype.removeMemberFromRoles = function removeMemberFromRoles(member,roles){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.removeMemberFromRoles(member,roles).then(dataCallback(callback),errorCallback(callback));}; // def removeUserFromRole
|
||||
Client.prototype.removeUserFromRoles = function removeUserFromRoles(member,roles){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.removeMemberFromRoles(member,roles,callback);}; // def createInvite
|
||||
Client.prototype.createInvite = function createInvite(chanServ,options){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, invite*/{}:arguments[2];if(typeof options === "function"){ // options is the callback
|
||||
callback = options;}return this.internal.createInvite(chanServ,options).then(dataCallback(callback),errorCallback(callback));}; // def deleteInvite
|
||||
Client.prototype.deleteInvite = function deleteInvite(invite){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.deleteInvite(invite).then(dataCallback(callback),errorCallback(callback));}; // def overwritePermissions
|
||||
Client.prototype.overwritePermissions = function overwritePermissions(channel,role){var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, {}*/{}:arguments[3];return this.internal.overwritePermissions(channel,role,options).then(dataCallback(callback),errorCallback(callback));}; // def setStatus
|
||||
Client.prototype.setStatus = function setStatus(idleStatus,gameID){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];if(typeof gameID === "function"){ // gameID is the callback
|
||||
callback = gameID;}else if(typeof idleStatus === "function"){ // idleStatus is the callback
|
||||
callback = idleStatus;}return this.internal.setStatus(idleStatus,gameID).then(dataCallback(callback),errorCallback(callback));}; // def sendTyping
|
||||
Client.prototype.sendTyping = function sendTyping(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.sendTyping(channel).then(dataCallback(callback),errorCallback(callback));}; // def setTopic
|
||||
Client.prototype.setChannelTopic = function setChannelTopic(channel,topic){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelTopic(channel,topic).then(dataCallback(callback),errorCallback(callback));}; // def setChannelName
|
||||
Client.prototype.setChannelName = function setChannelName(channel,name){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelName(channel,name).then(dataCallback(callback),errorCallback(callback));}; // def setChannelNameAndTopic
|
||||
Client.prototype.setChannelNameAndTopic = function setChannelNameAndTopic(channel,name,topic){var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, {}*/{}:arguments[3];return this.internal.setChannelNameAndTopic(channel,name,topic).then(dataCallback(callback),errorCallback(callback));}; // def setChannelPosition
|
||||
Client.prototype.setChannelPosition = function setChannelPosition(channel,position){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelPosition(channel,position).then(dataCallback(callback),errorCallback(callback));}; // def updateChannel
|
||||
Client.prototype.updateChannel = function updateChannel(channel,data){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.updateChannel(channel,data).then(dataCallback(callback),errorCallback(callback));}; // def startTyping
|
||||
Client.prototype.startTyping = function startTyping(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.startTyping(channel).then(dataCallback(callback),errorCallback(callback));}; // def stopTyping
|
||||
Client.prototype.stopTyping = function stopTyping(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.stopTyping(channel).then(dataCallback(callback),errorCallback(callback));}; // def updateDetails
|
||||
Client.prototype.updateDetails = function updateDetails(details){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.updateDetails(details).then(dataCallback(callback),errorCallback(callback));}; // def setUsername
|
||||
Client.prototype.setUsername = function setUsername(name){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.setUsername(name).then(dataCallback(callback),errorCallback(callback));}; // def setAvatar
|
||||
Client.prototype.setAvatar = function setAvatar(avatar){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.setAvatar(avatar).then(dataCallback(callback),errorCallback(callback));}; // def joinVoiceChannel
|
||||
Client.prototype.joinVoiceChannel = function joinVoiceChannel(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, channel*/{}:arguments[1];return this.internal.joinVoiceChannel(channel).then(dataCallback(callback),errorCallback(callback));}; // def leaveVoiceChannel
|
||||
Client.prototype.leaveVoiceChannel = function leaveVoiceChannel(){var callback=arguments.length <= 0 || arguments[0] === undefined?function() /*err, {}*/{}:arguments[0];return this.internal.leaveVoiceChannel().then(dataCallback(callback),errorCallback(callback));}; // def awaitResponse
|
||||
Client.prototype.awaitResponse = function awaitResponse(msg){var toSend=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var _this2=this;var options=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, newMsg*/{}:arguments[3];var ret;if(toSend){if(typeof toSend === "function"){ // (msg, callback)
|
||||
callback = toSend;}else { // (msg, toSend, ...)
|
||||
if(options){if(typeof options === "function"){ //(msg, toSend, callback)
|
||||
callback = options;ret = this.sendMessage(msg,toSend);}else { //(msg, toSend, options, callback)
|
||||
ret = this.sendMessage(msg,toSend,options);}}else { // (msg, toSend) promise
|
||||
ret = this.sendMessage(msg,toSend);}}}if(!ret){ret = Promise.resolve();} // (msg) promise
|
||||
return ret.then(function(){return _this2.internal.awaitResponse(msg);}).then(dataCallback(callback),errorCallback(callback));};Client.prototype.setStatusIdle = function setStatusIdle(){var callback=arguments.length <= 0 || arguments[0] === undefined?function() /*err, {}*/{}:arguments[0];return this.internal.setStatus("idle").then(dataCallback(callback),errorCallback(callback));};Client.prototype.setStatusOnline = function setStatusOnline(){var callback=arguments.length <= 0 || arguments[0] === undefined?function() /*err, {}*/{}:arguments[0];return this.internal.setStatus("online").then(dataCallback(callback),errorCallback(callback));};Client.prototype.setStatusActive = function setStatusActive(callback){return this.setStatusOnline(callback);};Client.prototype.setStatusHere = function setStatusHere(callback){return this.setStatusOnline(callback);};Client.prototype.setStatusAvailable = function setStatusAvailable(callback){return this.setStatusOnline(callback);};Client.prototype.setStatusAway = function setStatusAway(callback){return this.setStatusIdle(callback);};Client.prototype.setPlayingGame = function setPlayingGame(game){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.setStatus(null,game,callback);};_createClass(Client,[{key:"users",get:function get(){return this.internal.users;}},{key:"channels",get:function get(){return this.internal.channels;}},{key:"servers",get:function get(){return this.internal.servers;}},{key:"privateChannels",get:function get(){return this.internal.private_channels;}},{key:"voiceConnection",get:function get(){return this.internal.voiceConnection;}},{key:"readyTime",get:function get(){return this.internal.readyTime;}},{key:"uptime",get:function get(){return this.internal.uptime;}},{key:"user",get:function get(){return this.internal.user;}},{key:"userAgent",get:function get(){return this.internal.userAgent;},set:function set(userAgent){this.internal.userAgent = userAgent;}}]);return Client;})(_events2["default"]);exports["default"] = Client;module.exports = exports["default"];
|
||||
@@ -1 +0,0 @@
|
||||
"use strict";exports.__esModule = true;exports["default"] = {IDLE:0,LOGGING_IN:1,LOGGED_IN:2,READY:3,DISCONNECTED:4};module.exports = exports["default"];
|
||||
@@ -1,75 +0,0 @@
|
||||
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _superagent=require("superagent");var _superagent2=_interopRequireDefault(_superagent);var _ws=require("ws");var _ws2=_interopRequireDefault(_ws);var _ConnectionState=require("./ConnectionState");var _ConnectionState2=_interopRequireDefault(_ConnectionState);var _querystring=require("querystring");var _querystring2=_interopRequireDefault(_querystring);var _Constants=require("../Constants");var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _ResolverResolver=require("./Resolver/Resolver");var _ResolverResolver2=_interopRequireDefault(_ResolverResolver);var _StructuresUser=require("../Structures/User");var _StructuresUser2=_interopRequireDefault(_StructuresUser);var _StructuresChannel=require("../Structures/Channel");var _StructuresChannel2=_interopRequireDefault(_StructuresChannel);var _StructuresTextChannel=require("../Structures/TextChannel");var _StructuresTextChannel2=_interopRequireDefault(_StructuresTextChannel);var _StructuresVoiceChannel=require("../Structures/VoiceChannel");var _StructuresVoiceChannel2=_interopRequireDefault(_StructuresVoiceChannel);var _StructuresPMChannel=require("../Structures/PMChannel");var _StructuresPMChannel2=_interopRequireDefault(_StructuresPMChannel);var _StructuresServer=require("../Structures/Server");var _StructuresServer2=_interopRequireDefault(_StructuresServer);var _StructuresMessage=require("../Structures/Message");var _StructuresMessage2=_interopRequireDefault(_StructuresMessage);var _StructuresRole=require("../Structures/Role");var _StructuresRole2=_interopRequireDefault(_StructuresRole);var _StructuresInvite=require("../Structures/Invite");var _StructuresInvite2=_interopRequireDefault(_StructuresInvite);var _VoiceVoiceConnection=require("../Voice/VoiceConnection");var _VoiceVoiceConnection2=_interopRequireDefault(_VoiceVoiceConnection);var _UtilTokenCacher=require("../Util/TokenCacher");var _UtilTokenCacher2=_interopRequireDefault(_UtilTokenCacher);var zlib;var libVersion=require('../../package.json').version;function waitFor(condition){var value=arguments.length <= 1 || arguments[1] === undefined?condition:arguments[1];var interval=arguments.length <= 2 || arguments[2] === undefined?20:arguments[2];return (function(){return new Promise(function(resolve){var int=setInterval(function(){var isDone=condition();if(isDone){if(condition === value){resolve(isDone);}else {resolve(value(isDone));}return clearInterval(int);}},interval);});})();}function delay(ms){return new Promise(function(resolve){return setTimeout(resolve,ms);});}var InternalClient=(function(){function InternalClient(discordClient){_classCallCheck(this,InternalClient);this.setup(discordClient);}InternalClient.prototype.apiRequest = function apiRequest(method,url,useAuth,data,file){var _this=this,_arguments=arguments;var ret=_superagent2["default"][method](url);if(useAuth){ret.set("authorization",this.token);}if(data){ret.send(data);}if(file){ret.attach("file",file.file,file.name);}ret.set('User-Agent',this.userAgentInfo.full);return new Promise(function(resolve,reject){ret.end(function(error,data){if(error){if(!_this.client.options.rate_limit_as_error && error.response && error.response.error && error.response.error.status && error.response.error.status === 429){if(data.headers["retry-after"] || data.headers["Retry-After"]){var toWait=data.headers["retry-after"] || data.headers["Retry-After"];toWait = parseInt(toWait);setTimeout(function(){_this.apiRequest.apply(_this,_arguments).then(resolve)["catch"](reject);},toWait);}else {return reject(error);}}else {return reject(error);}}else {resolve(data.body);}});});};InternalClient.prototype.setup = function setup(discordClient){discordClient = discordClient || this.client;this.client = discordClient;this.state = _ConnectionState2["default"].IDLE;this.websocket = null;this.userAgent = {url:'https://github.com/hydrabolt/discord.js',version:require('../../package.json').version};if(this.client.options.compress){zlib = require("zlib");} // creates 4 caches with discriminators based on ID
|
||||
this.users = new _UtilCache2["default"]();this.channels = new _UtilCache2["default"]();this.servers = new _UtilCache2["default"]();this.private_channels = new _UtilCache2["default"]();this.intervals = {typing:[],kai:null,misc:[]};this.voiceConnection = null;this.resolver = new _ResolverResolver2["default"](this);this.readyTime = null;this.messageAwaits = {};this.tokenCacher = new _UtilTokenCacher2["default"](this.client);this.tokenCacher.init(0);};InternalClient.prototype.cleanIntervals = function cleanIntervals(){for(var _iterator=this.intervals.typing.concat(this.intervals.misc).concat(this.intervals.kai),_isArray=Array.isArray(_iterator),_i=0,_iterator=_isArray?_iterator:_iterator[Symbol.iterator]();;) {var _ref;if(_isArray){if(_i >= _iterator.length)break;_ref = _iterator[_i++];}else {_i = _iterator.next();if(_i.done)break;_ref = _i.value;}var interval=_ref;if(interval){clearInterval(interval);}}};InternalClient.prototype.disconnected = function disconnected(){var forced=arguments.length <= 0 || arguments[0] === undefined?false:arguments[0];this.cleanIntervals();this.leaveVoiceChannel();if(this.client.options.revive && !forced){this.setup();this.login(this.email,this.password);}this.client.emit("disconnected");}; //def leaveVoiceChannel
|
||||
InternalClient.prototype.leaveVoiceChannel = function leaveVoiceChannel(){if(this.voiceConnection){this.voiceConnection.destroy();this.voiceConnection = null;}return Promise.resolve();}; //def awaitResponse
|
||||
InternalClient.prototype.awaitResponse = function awaitResponse(msg){var _this2=this;return new Promise(function(resolve,reject){msg = _this2.resolver.resolveMessage(msg);if(!msg){reject(new Error("message undefined"));return;}var awaitID=msg.channel.id + msg.author.id;if(!_this2.messageAwaits[awaitID]){_this2.messageAwaits[awaitID] = [];}_this2.messageAwaits[awaitID].push(resolve);});}; //def joinVoiceChannel
|
||||
InternalClient.prototype.joinVoiceChannel = function joinVoiceChannel(chann){var _this3=this;var channel=this.resolver.resolveVoiceChannel(chann);if(!channel){return Promise.reject(new Error("voice channel does not exist"));}return this.leaveVoiceChannel().then(function(){return new Promise(function(resolve,reject){var session,token,server=channel.server,endpoint;var check=function check(m){var data=JSON.parse(m);if(data.t === "VOICE_STATE_UPDATE"){session = data.d.session_id;}else if(data.t === "VOICE_SERVER_UPDATE"){token = data.d.token;endpoint = data.d.endpoint;var chan=_this3.voiceConnection = new _VoiceVoiceConnection2["default"](channel,_this3.client,session,token,server,endpoint);chan.on("ready",function(){return resolve(chan);});chan.on("error",reject);_this3.client.emit("debug","removed temporary voice websocket listeners");_this3.websocket.removeListener("message",check);}};_this3.websocket.on("message",check);_this3.sendWS({op:4,d:{"guild_id":server.id,"channel_id":channel.id,"self_mute":false,"self_deaf":false}});});});}; // def createServer
|
||||
InternalClient.prototype.createServer = function createServer(name){var _this4=this;var region=arguments.length <= 1 || arguments[1] === undefined?"london":arguments[1];name = this.resolver.resolveString(name);return this.apiRequest('post',_Constants.Endpoints.SERVERS,true,{name:name,region:region}).then(function(res){ // valid server, wait until it is cached
|
||||
return waitFor(function(){return _this4.servers.get("id",res.id);});});}; //def joinServer
|
||||
InternalClient.prototype.joinServer = function joinServer(invite){var _this5=this;invite = this.resolver.resolveInviteID(invite);if(!invite){return Promise.reject(new Error("Not a valid invite"));}return this.apiRequest("post",_Constants.Endpoints.INVITE(invite),true).then(function(res){ // valid server, wait until it is received via ws and cached
|
||||
return waitFor(function(){return _this5.servers.get("id",res.guild.id);});});}; //def leaveServer
|
||||
InternalClient.prototype.leaveServer = function leaveServer(srv){var _this6=this;var server=this.resolver.resolveServer(srv);if(!server){return Promise.reject(new Error("server did not resolve"));}return this.apiRequest("del",_Constants.Endpoints.SERVER(server.id),true).then(function(){ // remove channels of server then the server
|
||||
for(var _iterator2=server.channels,_isArray2=Array.isArray(_iterator2),_i2=0,_iterator2=_isArray2?_iterator2:_iterator2[Symbol.iterator]();;) {var _ref2;if(_isArray2){if(_i2 >= _iterator2.length)break;_ref2 = _iterator2[_i2++];}else {_i2 = _iterator2.next();if(_i2.done)break;_ref2 = _i2.value;}var chan=_ref2;_this6.channels.remove(chan);} // remove server
|
||||
_this6.servers.remove(server);});}; // def login
|
||||
InternalClient.prototype.login = function login(email,password){var _this7=this;var client=this.client;if(!this.tokenCacher.done){return new Promise(function(resolve,reject){setTimeout(function(){_this7.login(email,password).then(resolve)["catch"](reject);},20);});}else {var tk=this.tokenCacher.getToken(email,password);if(tk){this.client.emit("debug","bypassed direct API login, used cached token");this.state = _ConnectionState2["default"].LOGGED_IN;this.token = tk;this.email = email;this.password = password;return this.getGateway().then(function(url){_this7.createWS(url);return tk;});return Promise.resolve(tk);}}if(this.state !== _ConnectionState2["default"].DISCONNECTED && this.state !== _ConnectionState2["default"].IDLE){return Promise.reject(new Error("already logging in/logged in/ready!"));}this.state = _ConnectionState2["default"].LOGGING_IN;return this.apiRequest("post",_Constants.Endpoints.LOGIN,false,{email:email,password:password}).then(function(res){_this7.client.emit("debug","direct API login, cached token was unavailable");var token=res.token;_this7.tokenCacher.setToken(email,password,token);_this7.state = _ConnectionState2["default"].LOGGED_IN;_this7.token = token;_this7.email = email;_this7.password = password;return _this7.getGateway().then(function(url){_this7.createWS(url);return token;});},function(error){_this7.websocket = null;throw error;})["catch"](function(error){_this7.state = _ConnectionState2["default"].DISCONNECTED;client.emit("disconnected");throw error;});}; // def logout
|
||||
InternalClient.prototype.logout = function logout(){var _this8=this;if(this.state === _ConnectionState2["default"].DISCONNECTED || this.state === _ConnectionState2["default"].IDLE){return Promise.reject(new Error("Client is not logged in!"));}return this.apiRequest("post",_Constants.Endpoints.LOGOUT,true).then(function(){if(_this8.websocket){_this8.websocket.close();_this8.websocket = null;}_this8.token = null;_this8.email = null;_this8.password = null;_this8.state = _ConnectionState2["default"].DISCONNECTED;});}; // def startPM
|
||||
InternalClient.prototype.startPM = function startPM(resUser){var _this9=this;var user=this.resolver.resolveUser(resUser);if(!user){return Promise.reject(new Error("Unable to resolve resUser to a User"));} // start the PM
|
||||
return this.apiRequest("post",_Constants.Endpoints.USER_CHANNELS(user.id),true,{recipient_id:user.id}).then(function(res){return _this9.private_channels.add(new _StructuresPMChannel2["default"](res,_this9.client));});}; // def getGateway
|
||||
InternalClient.prototype.getGateway = function getGateway(){return this.apiRequest("get",_Constants.Endpoints.GATEWAY,true).then(function(res){return res.url;});}; // def sendMessage
|
||||
InternalClient.prototype.sendMessage = function sendMessage(where,_content){var _this10=this;var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];return this.resolver.resolveChannel(where).then(function(destination){ //var destination;
|
||||
var content=_this10.resolver.resolveString(_content);return _this10.apiRequest("post",_Constants.Endpoints.CHANNEL_MESSAGES(destination.id),true,{content:content,tts:options.tts}).then(function(res){return destination.messages.add(new _StructuresMessage2["default"](res,destination,_this10.client));});});}; // def deleteMessage
|
||||
InternalClient.prototype.deleteMessage = function deleteMessage(_message){var _this11=this;var options=arguments.length <= 1 || arguments[1] === undefined?{}:arguments[1];var message=this.resolver.resolveMessage(_message);if(!message){return Promise.reject(new Error("Supplied message did not resolve to a message!"));}var chain=options.wait?delay(options.wait):Promise.resolve();return chain.then(function(){return _this11.apiRequest("del",_Constants.Endpoints.CHANNEL_MESSAGE(message.channel.id,message.id),true);}).then(function(){return message.channel.messages.remove(message);});}; // def updateMessage
|
||||
InternalClient.prototype.updateMessage = function updateMessage(msg,_content){var _this12=this;var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];var message=this.resolver.resolveMessage(msg);if(!message){return Promise.reject(new Error("Supplied message did not resolve to a message!"));}var content=this.resolver.resolveString(_content);return this.apiRequest("patch",_Constants.Endpoints.CHANNEL_MESSAGE(message.channel.id,message.id),true,{content:content,tts:options.tts}).then(function(res){return message.channel.messages.update(message,new _StructuresMessage2["default"](res,message.channel,_this12.client));});}; // def sendFile
|
||||
InternalClient.prototype.sendFile = function sendFile(where,_file){var _this13=this;var name=arguments.length <= 2 || arguments[2] === undefined?"image.png":arguments[2];return this.resolver.resolveChannel(where).then(function(channel){return _this13.apiRequest("post",_Constants.Endpoints.CHANNEL_MESSAGES(channel.id),true,null,{name:name,file:_this13.resolver.resolveFile(_file)}).then(function(res){return channel.messages.add(new _StructuresMessage2["default"](res,channel,_this13.client));});});}; // def getChannelLogs
|
||||
InternalClient.prototype.getChannelLogs = function getChannelLogs(_channel){var _this14=this;var limit=arguments.length <= 1 || arguments[1] === undefined?500:arguments[1];var options=arguments.length <= 2 || arguments[2] === undefined?{}:arguments[2];return this.resolver.resolveChannel(_channel).then(function(channel){var qsObject={limit:limit};if(options.before){var res=_this14.resolver.resolveMessage(options.before);if(res){qsObject.before = res;}}if(options.after){var res=_this14.resolver.resolveMessage(options.after);if(res){qsObject.after = res;}}return _this14.apiRequest("get",_Constants.Endpoints.CHANNEL_MESSAGES(channel.id) + "?" + _querystring2["default"].stringify(qsObject),true).then(function(res){return res.map(function(msg){return channel.messages.add(new _StructuresMessage2["default"](msg,channel,_this14.client));});});});}; // def getBans
|
||||
InternalClient.prototype.getBans = function getBans(server){var _this15=this;server = this.resolver.resolveServer(server);return this.apiRequest("get",_Constants.Endpoints.SERVER_BANS(server.id),true).then(function(res){return res.map(function(ban){return _this15.users.add(new _StructuresUser2["default"](ban.user,_this15.client));});});}; // def createChannel
|
||||
InternalClient.prototype.createChannel = function createChannel(server,name){var _this16=this;var type=arguments.length <= 2 || arguments[2] === undefined?"text":arguments[2];server = this.resolver.resolveServer(server);return this.apiRequest("post",_Constants.Endpoints.SERVER_CHANNELS(server.id),true,{name:name,type:type}).then(function(res){var channel;if(res.type === "text"){channel = new _StructuresTextChannel2["default"](res,_this16.client,server);}else {channel = new _StructuresVoiceChannel2["default"](res,_this16.client,server);}return server.channels.add(_this16.channels.add(channel));});}; // def deleteChannel
|
||||
InternalClient.prototype.deleteChannel = function deleteChannel(_channel){var _this17=this;return this.resolver.resolveChannel(_channel).then(function(channel){return _this17.apiRequest("del",_Constants.Endpoints.CHANNEL(channel.id),true).then(function(){channel.server.channels.remove(channel);_this17.channels.remove(channel);});});}; // def banMember
|
||||
InternalClient.prototype.banMember = function banMember(user,server){var length=arguments.length <= 2 || arguments[2] === undefined?1:arguments[2];user = this.resolver.resolveUser(user);server = this.resolver.resolveServer(server);return this.apiRequest("put",_Constants.Endpoints.SERVER_BANS(server.id) + "/" + user.id + "?delete-message-days=" + length,true);}; // def unbanMember
|
||||
InternalClient.prototype.unbanMember = function unbanMember(user,server){server = this.resolver.resolveServer(server);user = this.resolver.resolveUser(user);return this.apiRequest("del",_Constants.Endpoints.SERVER_BANS(server.id) + "/" + user.id,true);}; // def kickMember
|
||||
InternalClient.prototype.kickMember = function kickMember(user,server){user = this.resolver.resolveUser(user);server = this.resolver.resolveServer(server);return this.apiRequest("del",_Constants.Endpoints.SERVER_MEMBERS(server.id) + "/" + user.id,true);}; // def createRole
|
||||
InternalClient.prototype.createRole = function createRole(server,data){var _this18=this;server = this.resolver.resolveServer(server);return this.apiRequest("post",_Constants.Endpoints.SERVER_ROLES(server.id),true).then(function(res){var role=server.roles.add(new _StructuresRole2["default"](res,server,_this18.client));if(data){return _this18.updateRole(role,data);}return role;});}; // def updateRole
|
||||
InternalClient.prototype.updateRole = function updateRole(role,data){var _this19=this;var server=this.resolver.resolveServer(role.server);var newData={color:data.color || role.color,hoist:data.hoist || role.hoist,name:data.name || role.name,permissions:role.permissions || 0};if(data.permissions){newData.permissions = 0;for(var _iterator3=data.permissions,_isArray3=Array.isArray(_iterator3),_i3=0,_iterator3=_isArray3?_iterator3:_iterator3[Symbol.iterator]();;) {var _ref3;if(_isArray3){if(_i3 >= _iterator3.length)break;_ref3 = _iterator3[_i3++];}else {_i3 = _iterator3.next();if(_i3.done)break;_ref3 = _i3.value;}var perm=_ref3;if(perm instanceof String || typeof perm === "string"){newData.permissions |= _Constants.Permissions[perm] || 0;}else {newData.permissions |= perm;}}}return this.apiRequest("patch",_Constants.Endpoints.SERVER_ROLES(server.id) + "/" + role.id,true,newData).then(function(res){return server.roles.update(role,new _StructuresRole2["default"](res,server,_this19.client));});}; // def deleteRole
|
||||
InternalClient.prototype.deleteRole = function deleteRole(role){return this.apiRequest("del",_Constants.Endpoints.SERVER_ROLES(role.server.id) + "/" + role.id,true);}; //def addMemberToRole
|
||||
InternalClient.prototype.addMemberToRole = function addMemberToRole(member,role){member = this.resolver.resolveUser(member);if(!member || !role){return Promise.reject(new Error("member/role not in server"));}if(!role.server.memberMap[member.id]){return Promise.reject(new Error("member not in server"));}var roleIDS=role.server.memberMap[member.id].roles.map(function(r){return r.id;}).concat(role.id);return this.apiRequest("patch",_Constants.Endpoints.SERVER_MEMBERS(role.server.id) + "/" + member.id,true,{roles:roleIDS});}; //def addMemberToRole
|
||||
InternalClient.prototype.addMemberToRoles = function addMemberToRoles(member,roles){member = this.resolver.resolveUser(member);if(!member){return Promise.reject(new Error("member not in server"));}if(!Array.isArray(roles) || roles.length === 0){return Promise.reject(new Error("invalid array of roles"));}var roleIDS=roles[0].server.memberMap[member.id].roles.map(function(r){return r.id;});if(roles.any(function(role){return !role.server.memberMap[member.id];})){return Promise.reject(new Error("Role does not exist on same server as member"));}return this.apiRequest("patch",_Constants.Endpoints.SERVER_MEMBERS(role.server.id) + "/" + member.id,true,{roles:roleIDS});}; //def removeMemberFromRole
|
||||
InternalClient.prototype.removeMemberFromRole = function removeMemberFromRole(member,role){member = this.resolver.resolveUser(member);if(!member || !role){return Promise.reject(new Error("member/role not in server"));}if(!role.server.memberMap[member.id]){return Promise.reject(new Error("member not in server"));}var roleIDS=role.server.memberMap[member.id].roles.map(function(r){return r.id;});for(var item in roleIDS) {if(roleIDS[item] === role.id){roleIDS.splice(item,1);break;}}return this.apiRequest("patch",_Constants.Endpoints.SERVER_MEMBERS(role.server.id) + "/" + member.id,true,{roles:roleIDS});}; //def removeMemberFromRoles
|
||||
InternalClient.prototype.removeMemberFromRoles = function removeMemberFromRoles(member,roles){member = this.resolver.resolveUser(member);if(!member){return Promise.reject(new Error("member not in server"));}if(!Array.isArray(roles) || roles.length === 0){return Promise.reject(new Error("invalid array of roles"));}var roleIDS=roles[0].server.memberMap[member.id].roles.map(function(r){return r.id;});for(var _iterator4=roles,_isArray4=Array.isArray(_iterator4),_i4=0,_iterator4=_isArray4?_iterator4:_iterator4[Symbol.iterator]();;) {var _ref4;if(_isArray4){if(_i4 >= _iterator4.length)break;_ref4 = _iterator4[_i4++];}else {_i4 = _iterator4.next();if(_i4.done)break;_ref4 = _i4.value;}var role=_ref4;if(!role.server.memberMap[member.id]){return Promise.reject(new Error("member not in server"));}for(var item in roleIDS) {if(roleIDS[item] === role.id){roleIDS.splice(item,1);break;}}}return this.apiRequest("patch",_Constants.Endpoints.SERVER_MEMBERS(role.server.id) + "/" + member.id,true,{roles:roleIDS});}; // def createInvite
|
||||
InternalClient.prototype.createInvite = function createInvite(chanServ,options){var _this20=this;if(chanServ instanceof _StructuresChannel2["default"]){ // do something
|
||||
}else if(chanServ instanceof _StructuresServer2["default"]){ // do something
|
||||
}else {chanServ = this.resolver.resolveServer(chanServ) || this.resolver.resolveChannel(chanServ);}if(!chanServ){throw new Error("couldn't resolve where");}if(!options){options = {validate:null};}else {options.max_age = options.maxAge || 0;options.max_uses = options.maxUses || 0;options.temporary = options.temporary || false;options.xkcdpass = options.xkcd || false;}var epoint;if(chanServ instanceof _StructuresChannel2["default"]){epoint = _Constants.Endpoints.CHANNEL_INVITES(chanServ.id);}else {epoint = _Constants.Endpoints.SERVER_INVITES(chanServ.id);}return this.apiRequest("post",epoint,true,options).then(function(res){return new _StructuresInvite2["default"](res,_this20.channels.get("id",res.channel.id),_this20.client);});}; //def deleteInvite
|
||||
InternalClient.prototype.deleteInvite = function deleteInvite(invite){invite = this.resolver.resolveInviteID(invite);if(!invite){throw new Error("Not a valid invite");}return this.apiRequest("del",_Constants.Endpoints.INVITE(invite),true);}; //def overwritePermissions
|
||||
InternalClient.prototype.overwritePermissions = function overwritePermissions(channel,role,updated){var _this21=this;return this.resolver.resolveChannel(channel).then(function(channel){var user;if(role instanceof _StructuresUser2["default"]){user = role;}var data={};data.allow = 0;data.deny = 0;updated.allow = updated.allow || [];updated.deny = updated.deny || [];if(role instanceof _StructuresRole2["default"]){data.id = role.id;data.type = "role";}else if(user){data.id = user.id;data.type = "member";}else {throw new Error("role incorrect");}for(var perm in updated) {if(updated[perm]){if(perm instanceof String || typeof perm === "string"){data.allow |= _Constants.Permissions[perm] || 0;}else {data.allow |= perm;}}else {if(perm instanceof String || typeof perm === "string"){data.deny |= _Constants.Permissions[perm] || 0;}else {data.deny |= perm;}}}return _this21.apiRequest("put",_Constants.Endpoints.CHANNEL_PERMISSIONS(channel.id) + "/" + data.id,true,data);});}; //def setStatus
|
||||
InternalClient.prototype.setStatus = function setStatus(idleStatus,game){if(idleStatus === "online" || idleStatus === "here" || idleStatus === "available"){this.idleStatus = null;}else if(this.idleStatus === "idle" || this.idleStatus === "away"){packet.d.idle_since = Date.now();}else {this.idleStatus = this.idleStatus || null; //undefineds
|
||||
}this.game = game === null?null:game || this.game;var packet={op:3,d:{idle_since:this.idleStatus,game:{name:this.game}}};this.sendWS(packet);return Promise.resolve();}; //def sendTyping
|
||||
InternalClient.prototype.sendTyping = function sendTyping(channel){var _this22=this;return this.resolver.resolveChannel(channel).then(function(channel){return _this22.apiRequest("post",_Constants.Endpoints.CHANNEL(channel.id) + "/typing",true);});}; //def startTyping
|
||||
InternalClient.prototype.startTyping = function startTyping(channel){var _this23=this;return this.resolver.resolveChannel(channel).then(function(channel){if(_this23.intervals.typing[channel.id]){ // typing interval already exists, leave it alone
|
||||
throw new Error("Already typing in that channel");}_this23.intervals.typing[channel.id] = setInterval(function(){return _this23.sendTyping(channel)["catch"](function(error){return _this23.emit("error",error);});},4000);return _this23.sendTyping(channel);});}; //def stopTyping
|
||||
InternalClient.prototype.stopTyping = function stopTyping(channel){var _this24=this;return this.resolver.resolveChannel(channel).then(function(channel){if(!_this24.intervals.typing[channel.id]){ // typing interval doesn"t exist
|
||||
throw new Error("Not typing in that channel");}clearInterval(_this24.intervals.typing[channel.id]);_this24.intervals.typing[channel.id] = false;});}; //def updateDetails
|
||||
InternalClient.prototype.updateDetails = function updateDetails(data){return this.apiRequest("patch",_Constants.Endpoints.ME,true,{avatar:this.resolver.resolveToBase64(data.avatar) || this.user.avatar,email:data.email || this.email,new_password:data.newPassword || null,password:data.password || this.password,username:data.username || this.user.username});}; //def setAvatar
|
||||
InternalClient.prototype.setAvatar = function setAvatar(avatar){return this.updateDetails({avatar:avatar});}; //def setUsername
|
||||
InternalClient.prototype.setUsername = function setUsername(username){return this.updateDetails({username:username});}; //def setTopic
|
||||
InternalClient.prototype.setChannelTopic = function setChannelTopic(chann){var _this25=this;var topic=arguments.length <= 1 || arguments[1] === undefined?"":arguments[1];return this.resolver.resolveChannel(chann).then(function(channel){return _this25.apiRequest("patch",_Constants.Endpoints.CHANNEL(channel.id),true,{name:channel.name,position:channel.position,topic:topic}).then(function(res){return channel.topic = res.topic;});});}; //def setChannelName
|
||||
InternalClient.prototype.setChannelName = function setChannelName(chann){var _this26=this;var name=arguments.length <= 1 || arguments[1] === undefined?"discordjs_is_the_best":arguments[1];return this.resolver.resolveChannel(chann).then(function(channel){return _this26.apiRequest("patch",_Constants.Endpoints.CHANNEL(channel.id),true,{name:name,position:channel.position,topic:channel.topic}).then(function(res){return channel.name = res.name;});});}; //def setChannelNameAndTopic
|
||||
InternalClient.prototype.setChannelNameAndTopic = function setChannelNameAndTopic(chann){var _this27=this;var name=arguments.length <= 1 || arguments[1] === undefined?"discordjs_is_the_best":arguments[1];var topic=arguments.length <= 2 || arguments[2] === undefined?"":arguments[2];return this.resolver.resolveChannel(chann).then(function(channel){return _this27.apiRequest("patch",_Constants.Endpoints.CHANNEL(channel.id),true,{name:name,position:channel.position,topic:topic}).then(function(res){channel.name = res.name;channel.topic = res.topic;});});}; //def setTopic
|
||||
InternalClient.prototype.setChannelPosition = function setChannelPosition(chann){var _this28=this;var position=arguments.length <= 1 || arguments[1] === undefined?0:arguments[1];return this.resolver.resolveChannel(chann).then(function(channel){return _this28.apiRequest("patch",_Constants.Endpoints.CHANNEL(channel.id),true,{name:channel.name,position:position,topic:channel.topic}).then(function(res){return channel.position = res.position;});});}; //def updateChannel
|
||||
InternalClient.prototype.updateChannel = function updateChannel(chann,data){return this.setChannelNameAndTopic(chann,data.name,data.topic);}; //def ack
|
||||
InternalClient.prototype.ack = function ack(msg){msg = this.resolver.resolveMessage(msg);if(!msg){Promise.reject(new Error("Message does not exist"));}return this.apiRequest("post",_Constants.Endpoints.CHANNEL_MESSAGE(msg.channel.id,msg.id) + "/ack",true);};InternalClient.prototype.sendWS = function sendWS(object){if(this.websocket){this.websocket.send(JSON.stringify(object));}};InternalClient.prototype.createWS = function createWS(url){var self=this;var client=self.client;if(this.websocket){return false;}this.websocket = new _ws2["default"](url);this.websocket.onopen = function(){self.sendWS({op:2,d:{token:self.token,v:3,compress:self.client.options.compress,properties:{"$os":"discord.js","$browser":"discord.js","$device":"discord.js","$referrer":"discord.js","$referring_domain":"discord.js"}}});};this.websocket.onclose = function(){self.websocket = null;self.state = _ConnectionState2["default"].DISCONNECTED;self.disconnected();};this.websocket.onerror = function(e){client.emit("error",e);};this.websocket.onmessage = function(e){if(e.data instanceof Buffer){if(!zlib)zlib = require("zlib");e.data = zlib.inflateSync(e.data).toString();}var packet,data;try{packet = JSON.parse(e.data);data = packet.d;}catch(e) {client.emit("error",e);return;}client.emit("raw",packet);switch(packet.t){case _Constants.PacketType.READY:var startTime=Date.now();self.intervals.kai = setInterval(function(){return self.sendWS({op:1,d:Date.now()});},data.heartbeat_interval);self.user = self.users.add(new _StructuresUser2["default"](data.user,client));data.guilds.forEach(function(server){self.servers.add(new _StructuresServer2["default"](server,client));});data.private_channels.forEach(function(pm){self.private_channels.add(new _StructuresPMChannel2["default"](pm,client));});self.state = _ConnectionState2["default"].READY;client.emit("ready");client.emit("debug","ready packet took " + (Date.now() - startTime) + "ms to process");client.emit("debug","ready with " + self.servers.length + " servers, " + self.channels.length + " channels and " + self.users.length + " users cached.");self.readyTime = Date.now();break;case _Constants.PacketType.MESSAGE_CREATE: // format: https://discordapi.readthedocs.org/en/latest/reference/channels/messages.html#message-format
|
||||
var channel=self.channels.get("id",data.channel_id) || self.private_channels.get("id",data.channel_id);if(channel){var msg=channel.messages.add(new _StructuresMessage2["default"](data,channel,client));if(self.messageAwaits[channel.id + msg.author.id]){self.messageAwaits[channel.id + msg.author.id].map(function(fn){return fn(msg);});self.messageAwaits[channel.id + msg.author.id] = null;client.emit("message",msg,true); //2nd param is isAwaitedMessage
|
||||
}else {client.emit("message",msg);}self.ack(msg);}else {client.emit("warn","message created but channel is not cached");}break;case _Constants.PacketType.MESSAGE_DELETE: // format https://discordapi.readthedocs.org/en/latest/reference/channels/messages.html#message-delete
|
||||
var channel=self.channels.get("id",data.channel_id) || self.private_channels.get("id",data.channel_id);if(channel){ // potentially blank
|
||||
var msg=channel.messages.get("id",data.id);client.emit("messageDeleted",msg,channel);if(msg){channel.messages.remove(msg);}}else {client.emit("warn","message was deleted but channel is not cached");}break;case _Constants.PacketType.MESSAGE_UPDATE: // format https://discordapi.readthedocs.org/en/latest/reference/channels/messages.html#message-format
|
||||
var channel=self.channels.get("id",data.channel_id) || self.private_channels.get("id",data.channel_id);if(channel){ // potentially blank
|
||||
var msg=channel.messages.get("id",data.id);if(msg){ // old message exists
|
||||
data.nonce = data.nonce || msg.nonce;data.attachments = data.attachments || msg.attachments;data.tts = data.tts || msg.tts;data.embeds = data.embeds || msg.embeds;data.timestamp = data.timestamp || msg.timestamp;data.mention_everyone = data.mention_everyone || msg.everyoneMentioned;data.content = data.content || msg.content;data.mentions = data.mentions || msg.mentions;data.author = data.author || msg.author;var nmsg=channel.messages.update(msg,new _StructuresMessage2["default"](data,channel,client));client.emit("messageUpdated",nmsg,msg);}}else {client.emit("warn","message was updated but channel is not cached");}break;case _Constants.PacketType.SERVER_CREATE:var server=self.servers.get("id",data.id);if(!server){server = new _StructuresServer2["default"](data,client);self.servers.add(server);client.emit("serverCreated",server);}break;case _Constants.PacketType.SERVER_DELETE:var server=self.servers.get("id",data.id);if(server){for(var _iterator5=server.channels,_isArray5=Array.isArray(_iterator5),_i5=0,_iterator5=_isArray5?_iterator5:_iterator5[Symbol.iterator]();;) {var _ref5;if(_isArray5){if(_i5 >= _iterator5.length)break;_ref5 = _iterator5[_i5++];}else {_i5 = _iterator5.next();if(_i5.done)break;_ref5 = _i5.value;}var channel=_ref5;self.channels.remove(channel);}self.servers.remove(server);client.emit("serverDeleted",server);}else {client.emit("warn","server was deleted but it was not in the cache");}break;case _Constants.PacketType.SERVER_UPDATE:var server=self.servers.get("id",data.id);if(server){ // server exists
|
||||
data.members = data.members || [];data.channels = data.channels || [];var newserver=new _StructuresServer2["default"](data,self);newserver.members = server.members;newserver.memberMap = server.memberMap;newserver.channels = server.channels;if(newserver.equalsStrict(server)){ // already the same don't do anything
|
||||
client.emit("debug","received server update but server already updated");}else {self.servers.update(server,newserver);client.emit("serverUpdated",server,newserver);}}else if(!server){client.emit("warn","server was updated but it was not in the cache");self.servers.add(new _StructuresServer2["default"](data,self));client.emit("serverCreated",server);}break;case _Constants.PacketType.CHANNEL_CREATE:var channel=self.channels.get("id",data.id);if(!channel){var server=self.servers.get("id",data.guild_id);if(server){var chan=null;if(data.type === "text"){chan = self.channels.add(new _StructuresTextChannel2["default"](data,client,server));}else {chan = self.channels.add(new _StructuresVoiceChannel2["default"](data,client,server));}client.emit("channelCreated",server.channels.add(chan));}else if(data.is_private){client.emit("channelCreated",self.private_channels.add(new _StructuresPMChannel2["default"](data,client)));}else {client.emit("warn","channel created but server does not exist");}}else {client.emit("warn","channel created but already in cache");}break;case _Constants.PacketType.CHANNEL_DELETE:var channel=self.channels.get("id",data.id);if(channel){if(channel.server) // accounts for PMs
|
||||
channel.server.channels.remove(channel);self.channels.remove(channel);client.emit("channelDeleted",channel);}else {client.emit("warn","channel deleted but already out of cache?");}break;case _Constants.PacketType.CHANNEL_UPDATE:var channel=self.channels.get("id",data.id) || self.private_channels.get("id",data.id);if(channel){if(channel instanceof _StructuresPMChannel2["default"]){ //PM CHANNEL
|
||||
client.emit("channelUpdated",channel,self.private_channels.update(channel,new _StructuresPMChannel2["default"](data,client)));}else {if(channel.server){if(channel.type === "text"){ //TEXT CHANNEL
|
||||
var chan=new _StructuresTextChannel2["default"](data,client,channel.server);chan.messages = channel.messages;channel.server.channels.update(channel,chan);self.channels.update(channel,chan);client.emit("channelUpdated",channel,chan);}else { //VOICE CHANNEL
|
||||
var chan=new _StructuresVoiceChannel2["default"](data,client,channel.server);channel.server.channels.update(channel,chan);self.channels.update(channel,chan);client.emit("channelUpdated",channel,chan);}}else {client.emit("warn","channel updated but server non-existant");}}}else {client.emit("warn","channel updated but not in cache");}break;case _Constants.PacketType.SERVER_ROLE_CREATE:var server=self.servers.get("id",data.guild_id);if(server){client.emit("serverRoleCreated",server.roles.add(new _StructuresRole2["default"](data.role,server,client)),server);}else {client.emit("warn","server role made but server not in cache");}break;case _Constants.PacketType.SERVER_ROLE_DELETE:var server=self.servers.get("id",data.guild_id);if(server){var role=server.roles.get("id",data.role_id);if(role){server.roles.remove(role);client.emit("serverRoleDeleted",role);}else {client.emit("warn","server role deleted but role not in cache");}}else {client.emit("warn","server role deleted but server not in cache");}break;case _Constants.PacketType.SERVER_ROLE_UPDATE:var server=self.servers.get("id",data.guild_id);if(server){var role=server.roles.get("id",data.role.id);if(role){var newRole=new _StructuresRole2["default"](data.role,server,client);server.roles.update(role,newRole);client.emit("serverRoleUpdated",role,newRole);}else {client.emit("warn","server role updated but role not in cache");}}else {client.emit("warn","server role updated but server not in cache");}break;case _Constants.PacketType.SERVER_MEMBER_ADD:var server=self.servers.get("id",data.guild_id);if(server){server.memberMap[data.user.id] = {roles:data.roles.map(function(pid){return server.roles.get("id",pid);}),mute:false,deaf:false,joinedAt:Date.parse(data.joined_at)};client.emit("serverNewMember",server,server.members.add(self.users.add(new _StructuresUser2["default"](data.user,client))));}else {client.emit("warn","server member added but server doesn't exist in cache");}break;case _Constants.PacketType.SERVER_MEMBER_REMOVE:var server=self.servers.get("id",data.guild_id);if(server){var user=self.users.get("id",data.user.id);if(user){server.memberMap[data.user.id] = null;server.members.remove(user);client.emit("serverMemberRemoved",server,user);}else {client.emit("warn","server member removed but user doesn't exist in cache");}}else {client.emit("warn","server member removed but server doesn't exist in cache");}break;case _Constants.PacketType.SERVER_MEMBER_UPDATE:var server=self.servers.get("id",data.guild_id);if(server){var user=self.users.get("id",data.user.id);if(user){server.memberMap[data.user.id].roles = data.roles.map(function(pid){return server.roles.get("id",pid);});server.memberMap[data.user.id].mute = data.mute;server.memberMap[data.user.id].deaf = data.deaf;client.emit("serverMemberUpdated",server,user);}else {client.emit("warn","server member removed but user doesn't exist in cache");}}else {client.emit("warn","server member updated but server doesn't exist in cache");}break;case _Constants.PacketType.PRESENCE_UPDATE:var user=self.users.get("id",data.user.id);if(user){data.user.username = data.user.username || user.username;data.user.id = data.user.id || user.id;data.user.avatar = data.user.avatar || user.avatar;data.user.discriminator = data.user.discriminator || user.discriminator;var presenceUser=new _StructuresUser2["default"](data.user,client);if(presenceUser.equals(user)){ // a real presence update
|
||||
user.status = data.status;user.gameID = data.game_id;client.emit("presence",user,data.status,data.game_id);}else { // a name change or avatar change
|
||||
client.emit("userUpdated",user,presenceUser);self.users.update(user,presenceUser);}}else {client.emit("warn","presence update but user not in cache");}break;case _Constants.PacketType.TYPING:var user=self.users.get("id",data.user_id);var channel=self.channels.get("id",data.channel_id) || self.private_channels.get("id",data.channel_id);if(user && channel){if(user.typing.since){user.typing.since = Date.now();user.typing.channel = channel;}else {user.typing.since = Date.now();user.typing.channel = channel;client.emit("userTypingStarted",user,channel);}setTimeout(function(){if(Date.now() - user.typing.since > 5500){ // they haven't typed since
|
||||
user.typing.since = null;user.typing.channel = null;client.emit("userTypingStopped",user,channel);}},6000);}else {client.emit("warn","user typing but user or channel not existant in cache");}break;case _Constants.PacketType.SERVER_BAN_ADD:var user=self.users.get("id",data.user.id);var server=self.servers.get("id",data.guild_id);if(user && server){client.emit("userBanned",user,server);}else {client.emit("warn","user banned but user/server not in cache.");}break;case _Constants.PacketType.SERVER_BAN_REMOVE:var user=self.users.get("id",data.user.id);var server=self.servers.get("id",data.guild_id);if(user && server){client.emit("userUnbanned",user,server);}else {client.emit("warn","user unbanned but user/server not in cache.");}break;case _Constants.PacketType.VOICE_STATE_UPDATE:var user=self.users.get("id",data.user_id);var server=self.servers.get("id",data.guild_id);if(user && server){if(data.channel_id){ // speaking
|
||||
var channel=self.channels.get("id",data.channel_id);if(channel){if(server.eventStartSpeaking(user,channel))client.emit("voiceJoin",user,channel);else client.emit("warn","voice state error occurred in adding");}else {client.emit("warn","voice state channel not in cache");}}else { // not speaking
|
||||
client.emit("voiceLeave",user,server.eventStopSpeaking(user));}}else {client.emit("warn","voice state update but user or server not in cache");}break;default:client.emit("unknown",packet);break;}};};_createClass(InternalClient,[{key:"uptime",get:function get(){return this.readyTime?Date.now() - this.readyTime:null;}},{key:"userAgent",set:function set(info){info.full = "DiscordBot (" + info.url + ", " + info.version + ")";this.userAgentInfo = info;},get:function get(){return this.userAgentInfo;}}]);return InternalClient;})();exports["default"] = InternalClient;module.exports = exports["default"];
|
||||
@@ -1,13 +0,0 @@
|
||||
"use strict"; /* global Buffer */exports.__esModule = true;function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _fs=require("fs");var _fs2=_interopRequireDefault(_fs);var _StructuresUser=require("../../Structures/User");var _StructuresUser2=_interopRequireDefault(_StructuresUser);var _StructuresChannel=require("../../Structures/Channel");var _StructuresChannel2=_interopRequireDefault(_StructuresChannel);var _StructuresTextChannel=require("../../Structures/TextChannel");var _StructuresTextChannel2=_interopRequireDefault(_StructuresTextChannel);var _StructuresVoiceChannel=require("../../Structures/VoiceChannel");var _StructuresVoiceChannel2=_interopRequireDefault(_StructuresVoiceChannel);var _StructuresServerChannel=require("../../Structures/ServerChannel");var _StructuresServerChannel2=_interopRequireDefault(_StructuresServerChannel);var _StructuresPMChannel=require("../../Structures/PMChannel");var _StructuresPMChannel2=_interopRequireDefault(_StructuresPMChannel);var _StructuresServer=require("../../Structures/Server");var _StructuresServer2=_interopRequireDefault(_StructuresServer);var _StructuresMessage=require("../../Structures/Message");var _StructuresMessage2=_interopRequireDefault(_StructuresMessage);var _StructuresInvite=require("../../Structures/Invite");var _StructuresInvite2=_interopRequireDefault(_StructuresInvite);var Resolver=(function(){function Resolver(internal){_classCallCheck(this,Resolver);this.internal = internal;}Resolver.prototype.resolveToBase64 = function resolveToBase64(resource){if(resource instanceof Buffer){resource = resource.toString("base64");resource = "data:image/jpg;base64," + resource;}return resource;};Resolver.prototype.resolveInviteID = function resolveInviteID(resource){if(resource instanceof _StructuresInvite2["default"]){return resource.id;}if(typeof resource === "string" || resource instanceof String){if(resource.indexOf("http") === 0){var split=resource.split("/");return split.pop();}return resource;}return null;};Resolver.prototype.resolveServer = function resolveServer(resource){if(resource instanceof _StructuresServer2["default"]){return resource;}if(resource instanceof _StructuresServerChannel2["default"]){return resource.server;}if(resource instanceof String || typeof resource === "string"){return this.internal.servers.get("id",resource);}if(resource instanceof _StructuresMessage2["default"]){if(resource.channel instanceof _StructuresTextChannel2["default"]){return resource.server;}}return null;};Resolver.prototype.resolveFile = function resolveFile(resource){if(typeof resource === "string" || resource instanceof String){return _fs2["default"].createReadStream(resource);}return resource;};Resolver.prototype.resolveMentions = function resolveMentions(resource){ // resource is a string
|
||||
var _mentions=[];var changed=resource;for(var _iterator=resource.match(/<@[^>]*>/g) || [],_isArray=Array.isArray(_iterator),_i=0,_iterator=_isArray?_iterator:_iterator[Symbol.iterator]();;) {var _ref;if(_isArray){if(_i >= _iterator.length)break;_ref = _iterator[_i++];}else {_i = _iterator.next();if(_i.done)break;_ref = _i.value;}var mention=_ref;var userID=mention.substring(2,mention.length - 1);_mentions.push(userID);changed = changed.replace(new RegExp(mention,"g"),"@" + this.internal.client.users.get("id",userID).username);}return [_mentions,changed];};Resolver.prototype.resolveString = function resolveString(resource){ // accepts Array, Channel, Server, User, Message, String and anything
|
||||
// toString()-able
|
||||
var final=resource;if(resource instanceof Array){final = resource.join("\n");}return final.toString();};Resolver.prototype.resolveUser = function resolveUser(resource){ /*
|
||||
accepts a Message, Channel, Server, String ID, User, PMChannel
|
||||
*/if(resource instanceof _StructuresUser2["default"]){return resource;}if(resource instanceof _StructuresMessage2["default"]){return resource.author;}if(resource instanceof _StructuresTextChannel2["default"]){var lmsg=resource.lastMessage;if(lmsg){return lmsg.author;}}if(resource instanceof _StructuresServer2["default"]){return resource.owner;}if(resource instanceof _StructuresPMChannel2["default"]){return resource.recipient;}if(resource instanceof String || typeof resource === "string"){return this.internal.users.get("id",resource);}return null;};Resolver.prototype.resolveMessage = function resolveMessage(resource){ // accepts a Message, PMChannel & TextChannel
|
||||
if(resource instanceof _StructuresTextChannel2["default"] || resource instanceof _StructuresPMChannel2["default"]){return resource.lastMessage;}if(resource instanceof _StructuresMessage2["default"]){return resource;}return null;};Resolver.prototype.resolveVoiceChannel = function resolveVoiceChannel(resource){ // resolveChannel will also work but this is more apt
|
||||
if(resource instanceof _StructuresVoiceChannel2["default"]){return resource;}return null;};Resolver.prototype.resolveChannel = function resolveChannel(resource){ /*
|
||||
accepts a Message, Channel, Server, String ID, User
|
||||
*/if(resource instanceof _StructuresMessage2["default"]){return Promise.resolve(resource.channel);}if(resource instanceof _StructuresChannel2["default"]){return Promise.resolve(resource);}if(resource instanceof _StructuresServer2["default"]){return Promise.resolve(resource.channels.get("id",resource.id));}if(resource instanceof String || typeof resource === "string"){return Promise.resolve(this.internal.channels.get("id",resource));}if(resource instanceof _StructuresUser2["default"]){ // see if a PM exists
|
||||
var chatFound=this.internal.private_channels.find(function(pmchat){return pmchat.recipient.equals(resource);});if(chatFound){ // a PM already exists!
|
||||
return Promise.resolve(chatFound);} // PM does not exist :\
|
||||
return this.internal.startPM(resource);}var error=new Error("Could not resolve channel");error.resource = resource;return Promise.reject(error);};return Resolver;})();exports["default"] = Resolver;module.exports = exports["default"];
|
||||
@@ -1,7 +0,0 @@
|
||||
"use strict";exports.__esModule = true;var API="https://discordapp.com/api";exports.API = API;var Endpoints={ // general endpoints
|
||||
LOGIN:API + "/auth/login",LOGOUT:API + "/auth/logout",ME:API + "/users/@me",GATEWAY:API + "/gateway",USER_CHANNELS:function USER_CHANNELS(userID){return API + "/users/" + userID + "/channels";},AVATAR:function AVATAR(userID,avatar){return API + "/users/" + userID + "/avatars/" + avatar + ".jpg";},INVITE:function INVITE(id){return API + "/invite/" + id;}, // servers
|
||||
SERVERS:API + "/guilds",SERVER:function SERVER(serverID){return Endpoints.SERVERS + "/" + serverID;},SERVER_ICON:function SERVER_ICON(serverID,hash){return Endpoints.SERVER(serverID) + "/icons/" + hash + ".jpg";},SERVER_PRUNE:function SERVER_PRUNE(serverID){return Endpoints.SERVER(serverID) + "/prune";},SERVER_EMBED:function SERVER_EMBED(serverID){return Endpoints.SERVER(serverID) + "/embed";},SERVER_INVITES:function SERVER_INVITES(serverID){return Endpoints.SERVER(serverID) + "/invites";},SERVER_ROLES:function SERVER_ROLES(serverID){return Endpoints.SERVER(serverID) + "/roles";},SERVER_BANS:function SERVER_BANS(serverID){return Endpoints.SERVER(serverID) + "/bans";},SERVER_INTEGRATIONS:function SERVER_INTEGRATIONS(serverID){return Endpoints.SERVER(serverID) + "/integrations";},SERVER_MEMBERS:function SERVER_MEMBERS(serverID){return Endpoints.SERVER(serverID) + "/members";},SERVER_CHANNELS:function SERVER_CHANNELS(serverID){return Endpoints.SERVER(serverID) + "/channels";}, // channels
|
||||
CHANNELS:API + "/channels",CHANNEL:function CHANNEL(channelID){return Endpoints.CHANNELS + "/" + channelID;},CHANNEL_MESSAGES:function CHANNEL_MESSAGES(channelID){return Endpoints.CHANNEL(channelID) + "/messages";},CHANNEL_INVITES:function CHANNEL_INVITES(channelID){return Endpoints.CHANNEL(channelID) + "/invites";},CHANNEL_TYPING:function CHANNEL_TYPING(channelID){return Endpoints.CHANNEL(channelID) + "/typing";},CHANNEL_PERMISSIONS:function CHANNEL_PERMISSIONS(channelID){return Endpoints.CHANNEL(channelID) + "/permissions";},CHANNEL_MESSAGE:function CHANNEL_MESSAGE(channelID,messageID){return Endpoints.CHANNEL_MESSAGES(channelID) + "/" + messageID;}};exports.Endpoints = Endpoints;var Permissions={ // general
|
||||
createInstantInvite:1 << 0,kickMembers:1 << 1,banMembers:1 << 2,manageRoles:1 << 3,managePermissions:1 << 3,manageChannels:1 << 4,manageChannel:1 << 4,manageServer:1 << 5, // text
|
||||
readMessages:1 << 10,sendMessages:1 << 11,sendTTSMessages:1 << 12,manageMessages:1 << 13,embedLinks:1 << 14,attachFiles:1 << 15,readMessageHistory:1 << 16,mentionEveryone:1 << 17, // voice
|
||||
voiceConnect:1 << 20,voiceSpeak:1 << 21,voiceMuteMembers:1 << 22,voiceDeafenMembers:1 << 23,voiceMoveMembers:1 << 24,voiceUseVAD:1 << 25};exports.Permissions = Permissions;var PacketType={READY:"READY",MESSAGE_CREATE:"MESSAGE_CREATE",MESSAGE_UPDATE:"MESSAGE_UPDATE",MESSAGE_DELETE:"MESSAGE_DELETE",SERVER_CREATE:"GUILD_CREATE",SERVER_DELETE:"GUILD_DELETE",SERVER_UPDATE:"GUILD_UPDATE",CHANNEL_CREATE:"CHANNEL_CREATE",CHANNEL_DELETE:"CHANNEL_DELETE",CHANNEL_UPDATE:"CHANNEL_UPDATE",SERVER_ROLE_CREATE:"GUILD_ROLE_CREATE",SERVER_ROLE_DELETE:"GUILD_ROLE_DELETE",SERVER_ROLE_UPDATE:"GUILD_ROLE_UPDATE",SERVER_MEMBER_ADD:"GUILD_MEMBER_ADD",SERVER_MEMBER_REMOVE:"GUILD_MEMBER_REMOVE",SERVER_MEMBER_UPDATE:"GUILD_MEMBER_UPDATE",PRESENCE_UPDATE:"PRESENCE_UPDATE",TYPING:"TYPING_START",SERVER_BAN_ADD:"GUILD_BAN_ADD",SERVER_BAN_REMOVE:"GUILD_BAN_REMOVE",VOICE_STATE_UPDATE:"VOICE_STATE_UPDATE"};exports.PacketType = PacketType;
|
||||
@@ -1 +0,0 @@
|
||||
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _UtilEquality=require("../Util/Equality");var _UtilEquality2=_interopRequireDefault(_UtilEquality);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var Channel=(function(_Equality){_inherits(Channel,_Equality);function Channel(data,client){_classCallCheck(this,Channel);_Equality.call(this);this.id = data.id;this.client = client;}Channel.prototype["delete"] = function _delete(){return this.client.deleteChannel.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};_createClass(Channel,[{key:"isPrivate",get:function get(){return !this.server;}}]);return Channel;})(_UtilEquality2["default"]);exports["default"] = Channel;module.exports = exports["default"];
|
||||
@@ -1,7 +0,0 @@
|
||||
"use strict";exports.__esModule = true;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _Constants=require("../Constants");var ChannelPermissions=(function(){function ChannelPermissions(permissions){_classCallCheck(this,ChannelPermissions);this.permissions = permissions;}ChannelPermissions.prototype.serialise = function serialise(explicit){var _this=this;var hp=function hp(perm){return _this.hasPermission(perm,explicit);};return { // general
|
||||
createInstantInvite:hp(_Constants.Permissions.createInstantInvite),kickMembers:hp(_Constants.Permissions.kickMembers),banMembers:hp(_Constants.Permissions.banMembers),managePermissions:hp(_Constants.Permissions.managePermissions),manageChannel:hp(_Constants.Permissions.manageChannel),manageServer:hp(_Constants.Permissions.manageServer), // text
|
||||
readMessages:hp(_Constants.Permissions.readMessages),sendMessages:hp(_Constants.Permissions.sendMessages),sendTTSMessages:hp(_Constants.Permissions.sendTTSMessages),manageMessages:hp(_Constants.Permissions.manageMessages),embedLinks:hp(_Constants.Permissions.embedLinks),attachFiles:hp(_Constants.Permissions.attachFiles),readMessageHistory:hp(_Constants.Permissions.readMessageHistory),mentionEveryone:hp(_Constants.Permissions.mentionEveryone), // voice
|
||||
voiceConnect:hp(_Constants.Permissions.voiceConnect),voiceSpeak:hp(_Constants.Permissions.voiceSpeak),voiceMuteMembers:hp(_Constants.Permissions.voiceMuteMembers),voiceDeafenMembers:hp(_Constants.Permissions.voiceDeafenMembers),voiceMoveMembers:hp(_Constants.Permissions.voiceMoveMembers),voiceUseVAD:hp(_Constants.Permissions.voiceUseVAD)};};ChannelPermissions.prototype.serialize = function serialize(){ // ;n;
|
||||
return this.serialise();};ChannelPermissions.prototype.hasPermission = function hasPermission(perm){var explicit=arguments.length <= 1 || arguments[1] === undefined?false:arguments[1];if(perm instanceof String || typeof perm === "string"){perm = _Constants.Permissions[perm];}if(!perm){return false;}if(!explicit){ // implicit permissions allowed
|
||||
if(!!(this.permissions & _Constants.Permissions.manageRoles)){ // manageRoles allowed, they have all permissions
|
||||
return true;}}return !!(this.permissions & perm);};return ChannelPermissions;})();exports["default"] = ChannelPermissions;module.exports = exports["default"];
|
||||
@@ -1 +0,0 @@
|
||||
"use strict";exports.__esModule = true;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var Invite=(function(){function Invite(data,chan,client){_classCallCheck(this,Invite);this.maxAge = data.max_age;this.code = data.code;this.server = chan.server;this.channel = chan;this.revoked = data.revoked;this.createdAt = Date.parse(data.created_at);this.temporary = data.temporary;this.uses = data.uses;this.maxUses = data.uses;this.inviter = client.internal.users.get("id",data.inviter.id);this.xkcd = data.xkcdpass;}Invite.prototype.toString = function toString(){return "https://discord.gg/" + this.code;};Invite.prototype["delete"] = function _delete(){return this.client.deleteInvite.apply(this.client,reg(this,arguments));};Invite.prototype.join = function join(){return this.client.joinServer.apply(this.client,reg(this,arguments));};return Invite;})();exports["default"] = Invite;module.exports = exports["default"];
|
||||
@@ -1,4 +0,0 @@
|
||||
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var _UtilEquality=require("../Util/Equality");var _UtilEquality2=_interopRequireDefault(_UtilEquality);var Message=(function(_Equality){_inherits(Message,_Equality);function Message(data,channel,client){var _this=this;_classCallCheck(this,Message);_Equality.call(this);this.channel = channel;this.client = client;this.nonce = data.nonce;this.attachments = data.attachments;this.tts = data.tts;this.embeds = data.embeds;this.timestamp = Date.parse(data.timestamp);this.everyoneMentioned = data.mention_everyone;this.id = data.id;if(data.edited_timestamp)this.editedTimestamp = Date.parse(data.edited_timestamp);if(data.author instanceof _User2["default"])this.author = data.author;else this.author = client.internal.users.add(new _User2["default"](data.author,client));this.content = data.content;this.mentions = new _UtilCache2["default"]();data.mentions.forEach(function(mention){ // this is .add and not .get because it allows the bot to cache
|
||||
// users from messages from logs who may have left the server and were
|
||||
// not previously cached.
|
||||
if(mention instanceof _User2["default"])_this.mentions.push(mention);else _this.mentions.add(client.internal.users.add(new _User2["default"](mention,client)));});}Message.prototype.isMentioned = function isMentioned(user){user = this.client.internal.resolver.resolveUser(user);if(user){return this.mentions.has(user);}else {return false;}};Message.prototype.toString = function toString(){return this.content;};Message.prototype["delete"] = function _delete(){return this.client.deleteMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.update = function update(){return this.client.updateMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.edit = function edit(){return this.client.updateMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.reply = function reply(){return this.client.reply.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.replyTTS = function replyTTS(){return this.client.replyTTS.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};_createClass(Message,[{key:"sender",get:function get(){return this.author;}}]);return Message;})(_UtilEquality2["default"]);exports["default"] = Message;module.exports = exports["default"];
|
||||
@@ -1 +0,0 @@
|
||||
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _Channel2=require("./Channel");var _Channel3=_interopRequireDefault(_Channel2);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var PMChannel=(function(_Channel){_inherits(PMChannel,_Channel);function PMChannel(data,client){_classCallCheck(this,PMChannel);_Channel.call(this,data,client);this.type = data.type || "text";this.lastMessageId = data.last_message_id;this.messages = new _UtilCache2["default"]("id",1000);this.recipient = this.client.internal.users.add(new _User2["default"](data.recipient,this.client));} /* warning! may return null */PMChannel.prototype.toString = function toString(){return this.recipient.toString();};PMChannel.prototype.sendMessage = function sendMessage(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.send = function send(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.sendTTSMessage = function sendTTSMessage(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.sendTTS = function sendTTS(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.sendFile = function sendFile(){return this.client.sendFile.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.startTyping = function startTyping(){return this.client.startTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.stopTyping = function stopTyping(){return this.client.stopTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.getLogs = function getLogs(){return this.client.getChannelLogs.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};_createClass(PMChannel,[{key:"lastMessage",get:function get(){return this.messages.get("id",this.lastMessageID);}}]);return PMChannel;})(_Channel3["default"]);exports["default"] = PMChannel;module.exports = exports["default"];
|
||||
@@ -1,6 +0,0 @@
|
||||
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _Constants=require("../Constants");var PermissionOverwrite=(function(){function PermissionOverwrite(data){_classCallCheck(this,PermissionOverwrite);this.id = data.id;this.type = data.type; // member or role
|
||||
this.deny = data.deny;this.allow = data.allow;} // returns an array of allowed permissions
|
||||
PermissionOverwrite.prototype.setAllowed = function setAllowed(allowedArray){var _this=this;allowedArray.forEach(function(permission){if(permission instanceof String || typeof permission === "string"){permission = _Constants.Permissions[permission];}if(permission){_this.allow |= 1 << permission;}});};PermissionOverwrite.prototype.setDenied = function setDenied(deniedArray){var _this2=this;deniedArray.forEach(function(permission){if(permission instanceof String || typeof permission === "string"){permission = _Constants.Permissions[permission];}if(permission){_this2.deny |= 1 << permission;}});};_createClass(PermissionOverwrite,[{key:"allowed",get:function get(){var allowed=[];for(var permName in _Constants.Permissions) {if(permName === "manageRoles" || permName === "manageChannels"){ // these permissions do not exist in overwrites.
|
||||
continue;}if(!!(this.allow & _Constants.Permissions[permName])){allowed.push(permName);}}return allowed;} // returns an array of denied permissions
|
||||
},{key:"denied",get:function get(){var denied=[];for(var permName in _Constants.Permissions) {if(permName === "manageRoles" || permName === "manageChannels"){ // these permissions do not exist in overwrites.
|
||||
continue;}if(!!(this.deny & _Constants.Permissions[permName])){denied.push(permName);}}return denied;}}]);return PermissionOverwrite;})();exports["default"] = PermissionOverwrite;module.exports = exports["default"];
|
||||
@@ -1,23 +0,0 @@
|
||||
"use strict";exports.__esModule = true;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _Constants=require("../Constants");var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser"); /*
|
||||
|
||||
example data
|
||||
|
||||
{ position: -1,
|
||||
permissions: 36953089,
|
||||
name: '@everyone',
|
||||
managed: false,
|
||||
id: '110007368451915776',
|
||||
hoist: false,
|
||||
color: 0 }
|
||||
*/var DefaultRole=[_Constants.Permissions.createInstantInvite,_Constants.Permissions.readMessages,_Constants.Permissions.readMessageHistory,_Constants.Permissions.sendMessages,_Constants.Permissions.sendTTSMessages,_Constants.Permissions.embedLinks,_Constants.Permissions.attachFiles,_Constants.Permissions.readMessageHistory,_Constants.Permissions.mentionEveryone,_Constants.Permissions.voiceConnect,_Constants.Permissions.voiceSpeak,_Constants.Permissions.voiceUseVAD].reduce(function(previous,current){return previous | current;},0);var Role=(function(){function Role(data,server,client){_classCallCheck(this,Role);this.position = data.position || -1;this.permissions = data.permissions || (data.name === "@everyone"?DefaultRole:0);this.name = data.name || "@everyone";this.managed = data.managed || false;this.id = data.id;this.hoist = data.hoist || false;this.color = data.color || 0;this.server = server;this.client = client;}Role.prototype.serialise = function serialise(explicit){var _this=this;var hp=function hp(perm){return _this.hasPermission(perm,explicit);};return { // general
|
||||
createInstantInvite:hp(_Constants.Permissions.createInstantInvite),kickMembers:hp(_Constants.Permissions.kickMembers),banMembers:hp(_Constants.Permissions.banMembers),manageRoles:hp(_Constants.Permissions.manageRoles),manageChannels:hp(_Constants.Permissions.manageChannels),manageServer:hp(_Constants.Permissions.manageServer), // text
|
||||
readMessages:hp(_Constants.Permissions.readMessages),sendMessages:hp(_Constants.Permissions.sendMessages),sendTTSMessages:hp(_Constants.Permissions.sendTTSMessages),manageMessages:hp(_Constants.Permissions.manageMessages),embedLinks:hp(_Constants.Permissions.embedLinks),attachFiles:hp(_Constants.Permissions.attachFiles),readMessageHistory:hp(_Constants.Permissions.readMessageHistory),mentionEveryone:hp(_Constants.Permissions.mentionEveryone), // voice
|
||||
voiceConnect:hp(_Constants.Permissions.voiceConnect),voiceSpeak:hp(_Constants.Permissions.voiceSpeak),voiceMuteMembers:hp(_Constants.Permissions.voiceMuteMembers),voiceDeafenMembers:hp(_Constants.Permissions.voiceDeafenMembers),voiceMoveMembers:hp(_Constants.Permissions.voiceMoveMembers),voiceUseVAD:hp(_Constants.Permissions.voiceUseVAD)};};Role.prototype.serialize = function serialize(){ // ;n;
|
||||
return this.serialise();};Role.prototype.hasPermission = function hasPermission(perm){var explicit=arguments.length <= 1 || arguments[1] === undefined?false:arguments[1];if(perm instanceof String || typeof perm === "string"){perm = _Constants.Permissions[perm];}if(!perm){return false;}if(!explicit){ // implicit permissions allowed
|
||||
if(!!(this.permissions & _Constants.Permissions.manageRoles)){ // manageRoles allowed, they have all permissions
|
||||
return true;}} // e.g.
|
||||
// !!(36953089 & Permissions.manageRoles) = not allowed to manage roles
|
||||
// !!(36953089 & (1 << 21)) = voice speak allowed
|
||||
return !!(this.permissions & perm);};Role.prototype.setPermission = function setPermission(permission,value){if(permission instanceof String || typeof permission === "string"){permission = _Constants.Permissions[permission];}if(permission){ // valid permission
|
||||
if(value){this.permissions |= permission;}else {this.permissions &= ~permission;}}};Role.prototype.setPermissions = function setPermissions(obj){var _this2=this;obj.forEach(function(value,permission){if(permission instanceof String || typeof permission === "string"){permission = _Constants.Permissions[permission];}if(permission){ // valid permission
|
||||
_this2.setPermission(permission,value);}});};Role.prototype.colorAsHex = function colorAsHex(){var val=this.color.toString();while(val.length < 6) {val = "0" + val;}return "#" + val;};Role.prototype["delete"] = function _delete(){return this.client.deleteRole.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Role.prototype.edit = function edit(){return this.client.updateRole.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Role.prototype.update = function update(){return this.client.updateRole.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Role.prototype.addMember = function addMember(member,callback){return this.client.addMemberToRole.apply(this.client,[member,this,callback]);};Role.prototype.addUser = function addUser(member,callback){return this.client.addUserToRole.apply(this.client,[member,this,callback]);};Role.prototype.removeMember = function removeMember(member,callback){return this.client.removeMemberFromRole.apply(this.client,[member,this,callback]);};Role.prototype.removeUser = function removeUser(member,callback){return this.client.removeUserFromRole.apply(this.client,[member,this,callback]);};return Role;})();exports["default"] = Role;module.exports = exports["default"];
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
"use strict";exports.__esModule = true;function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _Channel2=require("./Channel");var _Channel3=_interopRequireDefault(_Channel2);var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _PermissionOverwrite=require("./PermissionOverwrite");var _PermissionOverwrite2=_interopRequireDefault(_PermissionOverwrite);var _ChannelPermissions=require("./ChannelPermissions");var _ChannelPermissions2=_interopRequireDefault(_ChannelPermissions);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var ServerChannel=(function(_Channel){_inherits(ServerChannel,_Channel);function ServerChannel(data,client,server){var _this=this;_classCallCheck(this,ServerChannel);_Channel.call(this,data,client);this.name = data.name;this.type = data.type;this.position = data.position;this.permissionOverwrites = new _UtilCache2["default"]();this.server = server;data.permission_overwrites.forEach(function(permission){_this.permissionOverwrites.add(new _PermissionOverwrite2["default"](permission));});}ServerChannel.prototype.permissionsOf = function permissionsOf(user){user = this.client.internal.resolver.resolveUser(user);if(user){if(this.server.owner.equals(user)){return new _ChannelPermissions2["default"](4294967295);}var everyoneRole=this.server.roles.get("name","@everyone");var userRoles=[everyoneRole].concat(this.server.rolesOf(user) || []);var userRolesID=userRoles.map(function(v){return v.id;});var roleOverwrites=[],memberOverwrites=[];this.permissionOverwrites.forEach(function(overwrite){if(overwrite.type === "member" && overwrite.id === user.id){memberOverwrites.push(overwrite);}else if(overwrite.type === "role" && overwrite.id in userRolesID){roleOverwrites.push(overwrite);}});var permissions=0;for(var _iterator=userRoles,_isArray=Array.isArray(_iterator),_i=0,_iterator=_isArray?_iterator:_iterator[Symbol.iterator]();;) {var _ref;if(_isArray){if(_i >= _iterator.length)break;_ref = _iterator[_i++];}else {_i = _iterator.next();if(_i.done)break;_ref = _i.value;}var serverRole=_ref;permissions |= serverRole.permissions;}for(var _iterator2=roleOverwrites.concat(memberOverwrites),_isArray2=Array.isArray(_iterator2),_i2=0,_iterator2=_isArray2?_iterator2:_iterator2[Symbol.iterator]();;) {var _ref2;if(_isArray2){if(_i2 >= _iterator2.length)break;_ref2 = _iterator2[_i2++];}else {_i2 = _iterator2.next();if(_i2.done)break;_ref2 = _i2.value;}var overwrite=_ref2;permissions = permissions & ~overwrite.deny;permissions = permissions | overwrite.allow;}return new _ChannelPermissions2["default"](permissions);}else {return null;}};ServerChannel.prototype.permsOf = function permsOf(user){return this.permissionsOf(user);};ServerChannel.prototype.mention = function mention(){return "<#" + this.id + ">";};ServerChannel.prototype.toString = function toString(){return this.mention();};ServerChannel.prototype.setName = function setName(){return this.client.setChannelName.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};ServerChannel.prototype.setPosition = function setPosition(){return this.client.setChannelPosition.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};return ServerChannel;})(_Channel3["default"]);exports["default"] = ServerChannel;module.exports = exports["default"];
|
||||
@@ -1 +0,0 @@
|
||||
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _ServerChannel2=require("./ServerChannel");var _ServerChannel3=_interopRequireDefault(_ServerChannel2);var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var TextChannel=(function(_ServerChannel){_inherits(TextChannel,_ServerChannel);function TextChannel(data,client,server){_classCallCheck(this,TextChannel);_ServerChannel.call(this,data,client,server);this.topic = data.topic;this.lastMessageID = data.last_message_id;this.messages = new _UtilCache2["default"]("id",client.options.maximumMessages);} /* warning! may return null */TextChannel.prototype.setTopic = function setTopic(){return this.client.setChannelTopic.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.setNameAndTopic = function setNameAndTopic(){return this.client.setChannelNameAndTopic.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.update = function update(){return this.client.updateChannel.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.sendMessage = function sendMessage(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.send = function send(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.sendTTSMessage = function sendTTSMessage(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.sendTTS = function sendTTS(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.sendFile = function sendFile(){return this.client.sendFile.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.getLogs = function getLogs(){return this.client.getChannelLogs.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.startTyping = function startTyping(){return this.client.startTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.stopTyping = function stopTyping(){return this.client.stopTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};_createClass(TextChannel,[{key:"lastMessage",get:function get(){return this.messages.get("id",this.lastMessageID);}}]);return TextChannel;})(_ServerChannel3["default"]);exports["default"] = TextChannel;module.exports = exports["default"];
|
||||
@@ -1 +0,0 @@
|
||||
"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _UtilEquality=require("../Util/Equality");var _UtilEquality2=_interopRequireDefault(_UtilEquality);var _Constants=require("../Constants");var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var User=(function(_Equality){_inherits(User,_Equality);function User(data,client){_classCallCheck(this,User);_Equality.call(this);this.client = client;this.username = data.username;this.discriminator = data.discriminator;this.id = data.id;this.avatar = data.avatar;this.status = data.status || "offline";this.gameID = data.game_id || null;this.typing = {since:null,channel:null};this.voiceChannel = null;}User.prototype.mention = function mention(){return "<@" + this.id + ">";};User.prototype.toString = function toString(){return this.mention();};User.prototype.equalsStrict = function equalsStrict(obj){if(obj instanceof User)return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar && this.status === obj.status && this.gameID === obj.gameID;else return false;};User.prototype.equals = function equals(obj){if(obj instanceof User)return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar;else return false;};User.prototype.sendMessage = function sendMessage(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.send = function send(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.sendTTSMessage = function sendTTSMessage(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.sendTTS = function sendTTS(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.sendFile = function sendFile(){return this.client.sendFile.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.startTyping = function startTyping(){return this.client.startTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.stopTyping = function stopTyping(){return this.client.stopTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.addTo = function addTo(role,callback){return this.client.addMemberToRole.apply(this.client,[this,role,callback]);};User.prototype.removeFrom = function removeFrom(role,callback){return this.client.removeMemberFromRole.apply(this.client,[this,role,callback]);};User.prototype.getLogs = function getLogs(){return this.client.getChannelLogs.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};_createClass(User,[{key:"avatarURL",get:function get(){if(!this.avatar){return null;}else {return _Constants.Endpoints.AVATAR(this.id,this.avatar);}}},{key:"name",get:function get(){return this.username;}}]);return User;})(_UtilEquality2["default"]);exports["default"] = User;module.exports = exports["default"];
|
||||
@@ -1 +0,0 @@
|
||||
"use strict";exports.__esModule = true;function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _ServerChannel2=require("./ServerChannel");var _ServerChannel3=_interopRequireDefault(_ServerChannel2);var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var VoiceChannel=(function(_ServerChannel){_inherits(VoiceChannel,_ServerChannel);function VoiceChannel(data,client,server){_classCallCheck(this,VoiceChannel);_ServerChannel.call(this,data,client,server);this.members = new _UtilCache2["default"]();}VoiceChannel.prototype.join = function join(){var callback=arguments.length <= 0 || arguments[0] === undefined?function(){}:arguments[0];return this.client.joinVoiceChannel.apply(this.client,[this,callback]);};return VoiceChannel;})(_ServerChannel3["default"]);exports["default"] = VoiceChannel;module.exports = exports["default"];
|
||||
@@ -1 +0,0 @@
|
||||
"use strict";exports.__esModule = true;exports.reg = reg;function reg(c,a){return [c].concat(Array.prototype.slice.call(a));}
|
||||
@@ -1 +0,0 @@
|
||||
"use strict";exports.__esModule = true;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var discrimS=Symbol();var discrimCacheS=Symbol();var Cache=(function(_Array){_inherits(Cache,_Array);function Cache(discrim,limit){_classCallCheck(this,Cache);_Array.call(this);this[discrimS] = discrim || "id";this[discrimCacheS] = {};}Cache.prototype.get = function get(key,value){if(key === this[discrimS])return this[discrimCacheS][value] || null;for(var _iterator=this,_isArray=Array.isArray(_iterator),_i=0,_iterator=_isArray?_iterator:_iterator[Symbol.iterator]();;) {var _ref;if(_isArray){if(_i >= _iterator.length)break;_ref = _iterator[_i++];}else {_i = _iterator.next();if(_i.done)break;_ref = _i.value;}var item=_ref;if(item[key] == value){return item;}}return null;};Cache.prototype.has = function has(object){return !!this.get(this[discrimS],object[this[discrimS]]);};Cache.prototype.getAll = function getAll(key,value){var found=new Cache(this[discrimS]);this.forEach(function(val,index,array){if(val.hasOwnProperty(key) && val[key] == value){found.push(val);return;}});return found;};Cache.prototype.add = function add(data){var cacheKey=this[discrimS] === "id"?data.id:data[this[discrimS]];if(this[discrimCacheS][cacheKey]){return this[discrimCacheS][cacheKey];}if(this.limit && this.length >= this.limit){this.splice(0,1);}this.push(data);this[discrimCacheS][cacheKey] = data;return data;};Cache.prototype.update = function update(old,data){var item=this.get(this[discrimS],old[this[discrimS]]);if(item){var index=this.indexOf(item);Object.assign(this[index],data);this[discrimCacheS][data[this[discrimS]]] = this[index];return this[index];}else {return false;}};Cache.prototype.random = function random(){return this[Math.floor(Math.random() * this.length)];};Cache.prototype.remove = function remove(data){delete this[discrimCacheS][data[this[discrimS]]];var index=this.indexOf(data);if(~index){this.splice(index,1);}else {var item=this.get(this[discrimS],data[this[discrimS]]);if(item){this.splice(this.indexOf(item),1);}}return false;};return Cache;})(Array);exports["default"] = Cache;module.exports = exports["default"];
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
The Equality Class is just used to show
|
||||
that a Class has an ID that can be used to
|
||||
check for equality.
|
||||
|
||||
Never use == or === when comparing
|
||||
objects in discord.js, they will be different
|
||||
instances sometimes.
|
||||
|
||||
Instead, use objectThatExtendsEquality.equals()
|
||||
*/"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var Equality=(function(){function Equality(){_classCallCheck(this,Equality);}Equality.prototype.equals = function equals(object){return object && object[this.eqDiscriminator] === this[this.eqDiscriminator];};Equality.prototype.equalsStrict = function equalsStrict(object){ // override per class type
|
||||
return;};_createClass(Equality,[{key:"eqDiscriminator",get:function get(){return "id";}}]);return Equality;})();exports["default"] = Equality;module.exports = exports["default"];
|
||||
@@ -1,8 +0,0 @@
|
||||
"use strict"; /* global process */exports.__esModule = true;function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _fsExtra=require("fs-extra");var _fsExtra2=_interopRequireDefault(_fsExtra);var _events=require("events");var _events2=_interopRequireDefault(_events);var _crypto=require("crypto");var _crypto2=_interopRequireDefault(_crypto);var savePaths=[process.env.APPDATA || (process.platform == "darwin"?process.env.HOME + "Library/Preference":"/var/local"),process.env[process.platform == "win32"?"USERPROFILE":"HOME"],process.cwd()];var algo="aes-256-ctr";function secureEmail(email,password){return new Buffer(_crypto2["default"].createHash("sha256").update(email + password,"utf8").digest()).toString("hex");}var TokenCacher=(function(_EventEmitter){_inherits(TokenCacher,_EventEmitter);function TokenCacher(client,options){_classCallCheck(this,TokenCacher);_EventEmitter.call(this);this.client = client;this.savePath = null;this.error = false;this.done = false;this.data = {};}TokenCacher.prototype.setToken = function setToken(){var email=arguments.length <= 0 || arguments[0] === undefined?"":arguments[0];var password=arguments.length <= 1 || arguments[1] === undefined?"":arguments[1];var token=arguments.length <= 2 || arguments[2] === undefined?"":arguments[2];email = secureEmail(email,password);var cipher=_crypto2["default"].createCipher(algo,password);var crypted=cipher.update("valid" + token,"utf8","hex");crypted += cipher.final("hex");this.data[email] = crypted;this.save();};TokenCacher.prototype.save = function save(){_fsExtra2["default"].writeJson(this.savePath,this.data);};TokenCacher.prototype.getToken = function getToken(){var email=arguments.length <= 0 || arguments[0] === undefined?"":arguments[0];var password=arguments.length <= 1 || arguments[1] === undefined?"":arguments[1];email = secureEmail(email,password);if(this.data[email]){try{var decipher=_crypto2["default"].createDecipher(algo,password);var dec=decipher.update(this.data[email],"hex","utf8");dec += decipher.final("utf8");return dec.indexOf("valid") === 0?dec.substr(5):false;}catch(e) { // not a valid token
|
||||
return null;}}else {return null;}};TokenCacher.prototype.init = function init(ind){var _this=this;var self=this;var savePath=savePaths[ind];_fsExtra2["default"].ensureDir(savePath,function(err){if(err){error(err);}else { //good to go
|
||||
_fsExtra2["default"].ensureFile(savePath + "/.discordjs/tokens.json",function(err){if(err){error(err);}else { //file exists
|
||||
_fsExtra2["default"].readFile(savePath + "/.discordjs/tokens.json",function(err,data){if(err){error(err);}else { // can read file, is it valid JSON?
|
||||
try{_this.data = JSON.parse(data); // good to go!
|
||||
_this.savePath = savePath + "/.discordjs/tokens.json";_this.emit("ready");_this.done = true;}catch(e) { // not valid JSON, make it valid and then write
|
||||
_fsExtra2["default"].writeJson(savePath + "/.discordjs/tokens.json",{},function(err){if(err){error(err);}else { // good to go!
|
||||
_this.savePath = savePath + "/.discordjs/tokens.json";_this.emit("ready");_this.done = true;}});}}});}});}});function error(e){ind++;if(!savePaths[ind]){self.emit("error");self.error = e;self.done = true;}else {self.init(ind);}}};return TokenCacher;})(_events2["default"]);exports["default"] = TokenCacher;module.exports = exports["default"];
|
||||
@@ -1,3 +0,0 @@
|
||||
"use strict";exports.__esModule = true;function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _child_process=require("child_process");var _child_process2=_interopRequireDefault(_child_process);var opus;try{opus = require("node-opus");}catch(e) { // no opus!
|
||||
}var AudioEncoder=(function(){function AudioEncoder(){_classCallCheck(this,AudioEncoder);if(opus){this.opus = new opus.OpusEncoder(48000,2);}this.choice = false;this.sanityCheckPassed = undefined;}AudioEncoder.prototype.sanityCheck = function sanityCheck(){var _opus=this.opus;var encodeZeroes=function encodeZeroes(){try{var zeroes=new Buffer(1920);zeroes.fill(0);return _opus.encode(zeroes,1920).readUIntBE(0,3);}catch(err) {return false;}};if(this.sanityCheckPassed === undefined)this.sanityCheckPassed = encodeZeroes() === 16056318;return this.sanityCheckPassed;};AudioEncoder.prototype.opusBuffer = function opusBuffer(buffer){return this.opus.encode(buffer,1920);};AudioEncoder.prototype.getCommand = function getCommand(force){if(this.choice && force)return choice;var choices=["avconv","ffmpeg"];for(var _iterator=choices,_isArray=Array.isArray(_iterator),_i=0,_iterator=_isArray?_iterator:_iterator[Symbol.iterator]();;) {var _ref;if(_isArray){if(_i >= _iterator.length)break;_ref = _iterator[_i++];}else {_i = _iterator.next();if(_i.done)break;_ref = _i.value;}var choice=_ref;var p=_child_process2["default"].spawnSync(choice);if(!p.error){this.choice = choice;return choice;}}return "help";};AudioEncoder.prototype.encodeStream = function encodeStream(stream,options){var self=this;return new Promise(function(resolve,reject){var enc=_child_process2["default"].spawn(self.getCommand(),['-loglevel','0','-i','-','-f','s16le','-ar','48000','-ac',2,'pipe:1','-af','volume=' + (options.volume || 1)],{stdio:['pipe','pipe','ignore']});stream.pipe(enc.stdin);enc.stdout.once("readable",function(){resolve({proc:enc,stream:enc.stdout,instream:stream,channels:2});});enc.stdout.on("end",function(){reject("end");});enc.stdout.on("close",function(){reject("close");});});};AudioEncoder.prototype.encodeFile = function encodeFile(file,options){var self=this;return new Promise(function(resolve,reject){var enc=_child_process2["default"].spawn(self.getCommand(),['-loglevel','0','-i',file,'-f','s16le','-ar','48000','-ac',2,'pipe:1','-af','"volume=' + (options.volume || 1) + '"'],{stdio:['pipe','pipe','ignore']});enc.stdout.once("readable",function(){resolve({proc:enc,stream:enc.stdout,channels:2});});enc.stdout.on("end",function(){reject("end");});enc.stdout.on("close",function(){reject("close");});});};AudioEncoder.prototype.encodeArbitraryFFmpeg = function encodeArbitraryFFmpeg(ffmpegOptions){var self=this;return new Promise(function(resolve,reject){ // add options discord.js needs
|
||||
var options=ffmpegOptions.concat(['-loglevel','0','-f','s16le','-ar','48000','-ac',2,'pipe:1']);var enc=_child_process2["default"].spawn(self.getCommand(),options,{stdio:['pipe','pipe','ignore']});enc.stdout.once("readable",function(){resolve({proc:enc,stream:enc.stdout,channels:2});});enc.stdout.on("end",function(){reject("end");});enc.stdout.on("close",function(){reject("close");});});};return AudioEncoder;})();exports["default"] = AudioEncoder;module.exports = exports["default"];
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user