@fluxerjs/core 1.1.9 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1149 -997
- package/dist/index.d.ts +1149 -997
- package/dist/index.js +2586 -2608
- package/dist/index.mjs +2721 -264
- package/package.json +8 -8
- package/dist/Channel-2WNJ445K.mjs +0 -17
- package/dist/Channel-3TAZVAC5.mjs +0 -21
- package/dist/Channel-4WVFDOCG.mjs +0 -22
- package/dist/Channel-ADRBK5JN.mjs +0 -19
- package/dist/Channel-AMX4IOLY.mjs +0 -20
- package/dist/Channel-BEZOW4VC.mjs +0 -17
- package/dist/Channel-BLJMK4T5.mjs +0 -19
- package/dist/Channel-DPLLHL7Y.mjs +0 -19
- package/dist/Channel-DTJWTA4N.mjs +0 -20
- package/dist/Channel-ELXWZIY4.mjs +0 -20
- package/dist/Channel-EYNPKHH2.mjs +0 -20
- package/dist/Channel-EZAKOCLZ.mjs +0 -19
- package/dist/Channel-EZSBZJTJ.mjs +0 -20
- package/dist/Channel-HBKXUNL5.mjs +0 -22
- package/dist/Channel-HK7VT35N.mjs +0 -22
- package/dist/Channel-HM2UY4DN.mjs +0 -17
- package/dist/Channel-ICWNKXBR.mjs +0 -19
- package/dist/Channel-IESEJJGP.mjs +0 -22
- package/dist/Channel-IGCIDQB3.mjs +0 -19
- package/dist/Channel-IKL3SJXN.mjs +0 -17
- package/dist/Channel-JFQXR7SZ.mjs +0 -22
- package/dist/Channel-KILNV5V3.mjs +0 -17
- package/dist/Channel-KOTARBSF.mjs +0 -17
- package/dist/Channel-L6UE2MAF.mjs +0 -22
- package/dist/Channel-LPAK4B5K.mjs +0 -20
- package/dist/Channel-LXEGJ3BH.mjs +0 -20
- package/dist/Channel-MGABB7NZ.mjs +0 -19
- package/dist/Channel-MS2XLT5H.mjs +0 -19
- package/dist/Channel-MXKULRP2.mjs +0 -19
- package/dist/Channel-NBJUUPIA.mjs +0 -22
- package/dist/Channel-NFVAR3VH.mjs +0 -19
- package/dist/Channel-NKQB7NPD.mjs +0 -20
- package/dist/Channel-ON7O3D3M.mjs +0 -17
- package/dist/Channel-OSOB6ELO.mjs +0 -19
- package/dist/Channel-PCUCLDOG.mjs +0 -22
- package/dist/Channel-QEJBBSOB.mjs +0 -20
- package/dist/Channel-RB4X65FA.mjs +0 -19
- package/dist/Channel-SM7NMKEO.mjs +0 -19
- package/dist/Channel-TOAQGSRX.mjs +0 -17
- package/dist/Channel-UHN4IOM5.mjs +0 -19
- package/dist/Channel-UNCURQZU.mjs +0 -19
- package/dist/Channel-VENHOL7S.mjs +0 -17
- package/dist/Channel-VFCLGG5D.mjs +0 -22
- package/dist/Channel-WDHLDQJC.mjs +0 -22
- package/dist/Channel-WJZZSNML.mjs +0 -21
- package/dist/Channel-XUJNTC3R.mjs +0 -21
- package/dist/Channel-YB3LWDHZ.mjs +0 -22
- package/dist/Channel-YVGPVOVB.mjs +0 -17
- package/dist/Channel-ZABU3K5W.mjs +0 -19
- package/dist/Channel-ZNYZSC7R.mjs +0 -20
- package/dist/ClientUser-2OHUFUV5.mjs +0 -9
- package/dist/ClientUser-35IVTH2S.mjs +0 -8
- package/dist/ClientUser-4MC4EFLT.mjs +0 -8
- package/dist/ClientUser-4TYNCHEP.mjs +0 -7
- package/dist/ClientUser-576UGSIO.mjs +0 -8
- package/dist/ClientUser-5DS73MJV.mjs +0 -8
- package/dist/ClientUser-5KQNQHUB.mjs +0 -8
- package/dist/ClientUser-5NZXMF6I.mjs +0 -8
- package/dist/ClientUser-6HBAPU6H.mjs +0 -8
- package/dist/ClientUser-76LLHLHL.mjs +0 -8
- package/dist/ClientUser-7CQO74QQ.mjs +0 -8
- package/dist/ClientUser-A73AHVOW.mjs +0 -8
- package/dist/ClientUser-AJLODDUV.mjs +0 -8
- package/dist/ClientUser-ALGC4FNY.mjs +0 -8
- package/dist/ClientUser-BKDGVNAY.mjs +0 -8
- package/dist/ClientUser-CDU2QEMV.mjs +0 -8
- package/dist/ClientUser-D3ZNDAJU.mjs +0 -8
- package/dist/ClientUser-DJO2FS7P.mjs +0 -8
- package/dist/ClientUser-GBD34QB5.mjs +0 -9
- package/dist/ClientUser-GISPHEM6.mjs +0 -8
- package/dist/ClientUser-ISZ3MTSZ.mjs +0 -8
- package/dist/ClientUser-J6HQVSDJ.mjs +0 -9
- package/dist/ClientUser-JCRVGIJL.mjs +0 -8
- package/dist/ClientUser-JG4EX6F4.mjs +0 -8
- package/dist/ClientUser-K2T5J3YS.mjs +0 -8
- package/dist/ClientUser-KWOQRQPD.mjs +0 -8
- package/dist/ClientUser-LBK6K4YD.mjs +0 -8
- package/dist/ClientUser-LLL6WX35.mjs +0 -8
- package/dist/ClientUser-MOMS7WLQ.mjs +0 -8
- package/dist/ClientUser-N7ZXYAQ3.mjs +0 -8
- package/dist/ClientUser-OGDA7D77.mjs +0 -8
- package/dist/ClientUser-PXAAKR2P.mjs +0 -8
- package/dist/ClientUser-QBJLDW5Y.mjs +0 -8
- package/dist/ClientUser-QQXLZ5WP.mjs +0 -8
- package/dist/ClientUser-RDGNVUVQ.mjs +0 -8
- package/dist/ClientUser-RNDKHQ3Z.mjs +0 -9
- package/dist/ClientUser-RXOB6K6C.mjs +0 -8
- package/dist/ClientUser-TN2LZ6NT.mjs +0 -8
- package/dist/ClientUser-TRA2WERQ.mjs +0 -8
- package/dist/ClientUser-U5TR5GIT.mjs +0 -8
- package/dist/ClientUser-UKG5K744.mjs +0 -8
- package/dist/ClientUser-V43WRWTN.mjs +0 -8
- package/dist/ClientUser-VZ2JS6RD.mjs +0 -8
- package/dist/ClientUser-WFID4IXD.mjs +0 -8
- package/dist/ClientUser-WWXUMO5O.mjs +0 -8
- package/dist/ClientUser-XX2PE3TB.mjs +0 -8
- package/dist/ClientUser-YEZNAK3W.mjs +0 -8
- package/dist/ClientUser-YQXVRO2A.mjs +0 -8
- package/dist/ClientUser-ZDE7A36W.mjs +0 -8
- package/dist/Guild-2LUH7U7B.mjs +0 -10
- package/dist/Guild-2OVJTJYO.mjs +0 -10
- package/dist/Guild-2P77HBQM.mjs +0 -11
- package/dist/Guild-36EGAAEW.mjs +0 -8
- package/dist/Guild-3ETPHHF5.mjs +0 -12
- package/dist/Guild-3PLQFT2I.mjs +0 -12
- package/dist/Guild-5UBZNIGD.mjs +0 -9
- package/dist/Guild-63VQBPKF.mjs +0 -11
- package/dist/Guild-AA7WOQRM.mjs +0 -12
- package/dist/Guild-AJNEG7LH.mjs +0 -10
- package/dist/Guild-ARMAVVJK.mjs +0 -10
- package/dist/Guild-AYHGH54T.mjs +0 -10
- package/dist/Guild-BRYNE2LO.mjs +0 -11
- package/dist/Guild-CA3W6DOD.mjs +0 -8
- package/dist/Guild-EATTLGFJ.mjs +0 -11
- package/dist/Guild-F6JU3UR6.mjs +0 -11
- package/dist/Guild-FE3A7REJ.mjs +0 -9
- package/dist/Guild-FMBCTAV4.mjs +0 -12
- package/dist/Guild-FSGTZATW.mjs +0 -12
- package/dist/Guild-FSIEY6C5.mjs +0 -11
- package/dist/Guild-FTMIT5T5.mjs +0 -10
- package/dist/Guild-GIXJJBFM.mjs +0 -9
- package/dist/Guild-GOQZ7XP4.mjs +0 -8
- package/dist/Guild-H7AUG7DI.mjs +0 -10
- package/dist/Guild-I4O63HEY.mjs +0 -12
- package/dist/Guild-IRBC63IR.mjs +0 -12
- package/dist/Guild-ITSZV3DE.mjs +0 -9
- package/dist/Guild-K5AJM2C7.mjs +0 -12
- package/dist/Guild-KKIQCGCV.mjs +0 -11
- package/dist/Guild-L6OWKAO6.mjs +0 -11
- package/dist/Guild-MDW7KF33.mjs +0 -12
- package/dist/Guild-NAD5F5DP.mjs +0 -12
- package/dist/Guild-NHNQ5TIA.mjs +0 -8
- package/dist/Guild-NNMSFIA6.mjs +0 -12
- package/dist/Guild-OKTDQS5K.mjs +0 -12
- package/dist/Guild-PO5D3NEA.mjs +0 -10
- package/dist/Guild-PS2BCXNB.mjs +0 -11
- package/dist/Guild-RPQGTXB7.mjs +0 -12
- package/dist/Guild-RSNXYHFM.mjs +0 -10
- package/dist/Guild-RXGLAN54.mjs +0 -12
- package/dist/Guild-S3AOK72T.mjs +0 -9
- package/dist/Guild-S3YWFZTC.mjs +0 -11
- package/dist/Guild-S436SLOP.mjs +0 -9
- package/dist/Guild-TM6YGJWB.mjs +0 -10
- package/dist/Guild-TZOCAXXV.mjs +0 -9
- package/dist/Guild-WAFXK2EX.mjs +0 -9
- package/dist/Guild-WGZEW2AP.mjs +0 -10
- package/dist/Guild-WNPS7DBT.mjs +0 -11
- package/dist/Guild-WQA4CPDE.mjs +0 -10
- package/dist/Guild-XPOMHZZG.mjs +0 -9
- package/dist/Guild-ZOFF5LFR.mjs +0 -8
- package/dist/GuildBan-7CXLTPKY.mjs +0 -7
- package/dist/GuildBan-M4PA3HAA.mjs +0 -7
- package/dist/GuildEmoji-LP55RVIV.mjs +0 -7
- package/dist/GuildEmoji-OCXBPS6I.mjs +0 -8
- package/dist/GuildEmoji-SOGQ4C32.mjs +0 -8
- package/dist/GuildMember-3PC5QAU4.mjs +0 -8
- package/dist/GuildMember-43B5E5CH.mjs +0 -9
- package/dist/GuildMember-B7IFPCWC.mjs +0 -9
- package/dist/GuildMember-BJJNCL6W.mjs +0 -8
- package/dist/GuildMember-DW2N6ITI.mjs +0 -7
- package/dist/GuildMember-E72JU6JE.mjs +0 -9
- package/dist/GuildMember-F5FZJOHD.mjs +0 -9
- package/dist/GuildMember-FSGDPKUU.mjs +0 -9
- package/dist/GuildMember-FX2JAWES.mjs +0 -8
- package/dist/GuildMember-GS72FCQD.mjs +0 -9
- package/dist/GuildMember-H7CP2HMW.mjs +0 -9
- package/dist/GuildMember-K5FLBNHV.mjs +0 -8
- package/dist/GuildMember-L35WIMIH.mjs +0 -9
- package/dist/GuildMember-OXTGJ3MF.mjs +0 -9
- package/dist/GuildMember-RGVPVUAG.mjs +0 -9
- package/dist/GuildMember-RZWZ3OCG.mjs +0 -7
- package/dist/GuildMember-UBNHZBCO.mjs +0 -8
- package/dist/GuildMember-UU26WJGN.mjs +0 -8
- package/dist/GuildMember-XF7K2R45.mjs +0 -9
- package/dist/GuildMember-YWXA2FVO.mjs +0 -8
- package/dist/GuildSticker-3QYT6ZIY.mjs +0 -8
- package/dist/GuildSticker-B7AZADJR.mjs +0 -8
- package/dist/GuildSticker-STHUU6RM.mjs +0 -7
- package/dist/Invite-4WSFNMH4.mjs +0 -7
- package/dist/Invite-UM5BU5A6.mjs +0 -7
- package/dist/Message-23Z3RPCZ.mjs +0 -9
- package/dist/Message-2MPW7ZWA.mjs +0 -7
- package/dist/Message-33APPS76.mjs +0 -9
- package/dist/Message-3XJH5D7I.mjs +0 -7
- package/dist/Message-43PACCS7.mjs +0 -8
- package/dist/Message-5RFJTHNU.mjs +0 -7
- package/dist/Message-6IYEYSV6.mjs +0 -7
- package/dist/Message-6RSAGIRP.mjs +0 -8
- package/dist/Message-6YRGUZSW.mjs +0 -9
- package/dist/Message-AKOXO3LZ.mjs +0 -7
- package/dist/Message-C4A23STA.mjs +0 -9
- package/dist/Message-DXBXIQIJ.mjs +0 -9
- package/dist/Message-E3WU3J2Q.mjs +0 -8
- package/dist/Message-EMJ3JUVX.mjs +0 -8
- package/dist/Message-F3K5GNIB.mjs +0 -8
- package/dist/Message-F4SCFNF5.mjs +0 -8
- package/dist/Message-G4KR7O2J.mjs +0 -7
- package/dist/Message-O4CXWR57.mjs +0 -7
- package/dist/Message-OFIVTTAZ.mjs +0 -9
- package/dist/Message-ONWLVMU7.mjs +0 -8
- package/dist/Message-OXTQHFCF.mjs +0 -8
- package/dist/Message-PZUU7ZFR.mjs +0 -9
- package/dist/Message-QNWAPT55.mjs +0 -9
- package/dist/Message-QSDAA2HG.mjs +0 -9
- package/dist/Message-QXPHQOVC.mjs +0 -8
- package/dist/Message-R7GZYIQQ.mjs +0 -8
- package/dist/Message-SHUOVKB5.mjs +0 -7
- package/dist/Message-U3UPCS7C.mjs +0 -7
- package/dist/Message-W624MHJF.mjs +0 -8
- package/dist/Message-XB5WNMHL.mjs +0 -9
- package/dist/Message-ZCS7IGJX.mjs +0 -8
- package/dist/Message-ZL2PJPQA.mjs +0 -8
- package/dist/MessageReaction-AYSOCOMX.mjs +0 -8
- package/dist/MessageReaction-FSX3HHRZ.mjs +0 -7
- package/dist/MessageReaction-GNM5YJ4V.mjs +0 -8
- package/dist/MessageReaction-ME5KGEG4.mjs +0 -8
- package/dist/MessageReaction-MFK2N3AD.mjs +0 -8
- package/dist/MessageReaction-MUBQ6GIN.mjs +0 -8
- package/dist/MessageReaction-NIAHV3EM.mjs +0 -8
- package/dist/MessageReaction-PZ53DNAW.mjs +0 -8
- package/dist/MessageReaction-TQFIS53C.mjs +0 -8
- package/dist/MessageReaction-V4UZ7OXE.mjs +0 -7
- package/dist/MessageReaction-XRPYZDSC.mjs +0 -7
- package/dist/Role-5MWSGL66.mjs +0 -7
- package/dist/Role-DWZ2YDFB.mjs +0 -7
- package/dist/Role-J7ENREP6.mjs +0 -7
- package/dist/Role-N2ZEMRUQ.mjs +0 -7
- package/dist/Role-SERSJFJC.mjs +0 -7
- package/dist/Role-SVLWIAMN.mjs +0 -7
- package/dist/Webhook-2MQESB7Z.mjs +0 -7
- package/dist/Webhook-2RHBXH7R.mjs +0 -7
- package/dist/Webhook-32VJD4AL.mjs +0 -7
- package/dist/Webhook-6BCEHBZ6.mjs +0 -8
- package/dist/Webhook-A5KZ4S4N.mjs +0 -10
- package/dist/Webhook-AG6QFM2I.mjs +0 -7
- package/dist/Webhook-EARQN5EG.mjs +0 -10
- package/dist/Webhook-GB77DXAF.mjs +0 -10
- package/dist/Webhook-H4IMADRQ.mjs +0 -10
- package/dist/Webhook-H7VKDOJX.mjs +0 -7
- package/dist/Webhook-IHLGW7NL.mjs +0 -8
- package/dist/Webhook-IWPKKMWD.mjs +0 -10
- package/dist/Webhook-L2D43K5N.mjs +0 -7
- package/dist/Webhook-LEYRYH23.mjs +0 -7
- package/dist/Webhook-NPIXOCEH.mjs +0 -10
- package/dist/Webhook-NUQCJAWZ.mjs +0 -7
- package/dist/Webhook-OXXVFNNU.mjs +0 -9
- package/dist/Webhook-RWDDYW2Q.mjs +0 -10
- package/dist/Webhook-SNLT45PN.mjs +0 -7
- package/dist/Webhook-TGAZZRQQ.mjs +0 -7
- package/dist/Webhook-WIF6OGPA.mjs +0 -10
- package/dist/Webhook-YL3NNZDI.mjs +0 -8
- package/dist/Webhook-ZL7A4766.mjs +0 -10
- package/dist/chunk-2245SAIA.mjs +0 -147
- package/dist/chunk-226TVUXE.mjs +0 -136
- package/dist/chunk-23KVLHIZ.mjs +0 -147
- package/dist/chunk-24E6OQID.mjs +0 -193
- package/dist/chunk-25Q2GMSK.mjs +0 -137
- package/dist/chunk-26GCIGHL.mjs +0 -52
- package/dist/chunk-2CIZJCEO.mjs +0 -132
- package/dist/chunk-2FIZRRSO.mjs +0 -88
- package/dist/chunk-2GXOBRSF.mjs +0 -184
- package/dist/chunk-2HH5NZT3.mjs +0 -137
- package/dist/chunk-2QU3TS4S.mjs +0 -496
- package/dist/chunk-2ZSMLDEI.mjs +0 -114
- package/dist/chunk-367NAOYQ.mjs +0 -127
- package/dist/chunk-3BJ4OOCQ.mjs +0 -86
- package/dist/chunk-3CNUPFDI.mjs +0 -59
- package/dist/chunk-3KOM5WYW.mjs +0 -502
- package/dist/chunk-3UJYRWDI.mjs +0 -132
- package/dist/chunk-4DBGMFOQ.mjs +0 -14
- package/dist/chunk-4F765HVV.mjs +0 -137
- package/dist/chunk-4OEOU7G7.mjs +0 -319
- package/dist/chunk-4OQ4XACY.mjs +0 -190
- package/dist/chunk-4PLHVYRY.mjs +0 -579
- package/dist/chunk-4QKSUNTV.mjs +0 -263
- package/dist/chunk-4S42USSG.mjs +0 -137
- package/dist/chunk-4SWR3ZEZ.mjs +0 -579
- package/dist/chunk-4XJIM6SC.mjs +0 -315
- package/dist/chunk-52L544OS.mjs +0 -259
- package/dist/chunk-53Y37KRG.mjs +0 -111
- package/dist/chunk-5APVDWQU.mjs +0 -184
- package/dist/chunk-5HQRX3KJ.mjs +0 -70
- package/dist/chunk-5I54OXBG.mjs +0 -111
- package/dist/chunk-5JEDVRKU.mjs +0 -193
- package/dist/chunk-5MPQG6OV.mjs +0 -120
- package/dist/chunk-5QRROWJS.mjs +0 -56
- package/dist/chunk-5RCTNYPY.mjs +0 -151
- package/dist/chunk-5VIV7EPG.mjs +0 -180
- package/dist/chunk-62S4AB2S.mjs +0 -54
- package/dist/chunk-6C3LYAUX.mjs +0 -496
- package/dist/chunk-6CEFV56Z.mjs +0 -142
- package/dist/chunk-6CEMF2LO.mjs +0 -14
- package/dist/chunk-6EBNOON4.mjs +0 -86
- package/dist/chunk-6GF5H3JH.mjs +0 -137
- package/dist/chunk-6IGR45JC.mjs +0 -137
- package/dist/chunk-6LREQZXU.mjs +0 -259
- package/dist/chunk-6S3BDHBI.mjs +0 -28
- package/dist/chunk-6VWXGTX2.mjs +0 -585
- package/dist/chunk-72OY7B3D.mjs +0 -72
- package/dist/chunk-737R7BFN.mjs +0 -112
- package/dist/chunk-7EPDZMZS.mjs +0 -264
- package/dist/chunk-7FYM4D2E.mjs +0 -50
- package/dist/chunk-7GZN6JXT.mjs +0 -50
- package/dist/chunk-7H3TKJUT.mjs +0 -53
- package/dist/chunk-7K35BCCD.mjs +0 -263
- package/dist/chunk-7SIS5CUA.mjs +0 -14
- package/dist/chunk-ABGLEIZG.mjs +0 -191
- package/dist/chunk-AC7PFILS.mjs +0 -107
- package/dist/chunk-AH7KYH2Z.mjs +0 -50
- package/dist/chunk-AI5E6LS5.mjs +0 -361
- package/dist/chunk-AK6Q62VE.mjs +0 -109
- package/dist/chunk-AKJZBSCE.mjs +0 -155
- package/dist/chunk-B6F5LWNS.mjs +0 -64
- package/dist/chunk-BAZBIWMG.mjs +0 -209
- package/dist/chunk-BF7OCTE6.mjs +0 -142
- package/dist/chunk-BFSGXVZ7.mjs +0 -148
- package/dist/chunk-BGJSL6JI.mjs +0 -14
- package/dist/chunk-BI2MRKB7.mjs +0 -150
- package/dist/chunk-BKPVGBOT.mjs +0 -8
- package/dist/chunk-BMAFJS7T.mjs +0 -575
- package/dist/chunk-BRIU4HGS.mjs +0 -579
- package/dist/chunk-BUEXP5SZ.mjs +0 -70
- package/dist/chunk-BUIHWKTK.mjs +0 -132
- package/dist/chunk-BYTAODAO.mjs +0 -70
- package/dist/chunk-CEABHTAF.mjs +0 -43
- package/dist/chunk-CJLJBBFO.mjs +0 -54
- package/dist/chunk-CJVQNARM.mjs +0 -145
- package/dist/chunk-CNCPVNXS.mjs +0 -160
- package/dist/chunk-CNXK6SYW.mjs +0 -220
- package/dist/chunk-CQ5ZVTLX.mjs +0 -71
- package/dist/chunk-CQ7MDBHD.mjs +0 -199
- package/dist/chunk-CREI4MOS.mjs +0 -406
- package/dist/chunk-DJBCSVZX.mjs +0 -102
- package/dist/chunk-DJQXAQLR.mjs +0 -496
- package/dist/chunk-DLROMCIJ.mjs +0 -50
- package/dist/chunk-DLVBAJTE.mjs +0 -52
- package/dist/chunk-DNDCNIN2.mjs +0 -263
- package/dist/chunk-DO7MLFT6.mjs +0 -579
- package/dist/chunk-DPZHAYCK.mjs +0 -71
- package/dist/chunk-DQ4TNBPG.mjs +0 -63
- package/dist/chunk-DSPSRPHF.mjs +0 -200
- package/dist/chunk-DUQAD7F6.mjs +0 -173
- package/dist/chunk-E27LKSSS.mjs +0 -142
- package/dist/chunk-E6SU3TR5.mjs +0 -64
- package/dist/chunk-E75ZVY3I.mjs +0 -14
- package/dist/chunk-EC4ES5VH.mjs +0 -171
- package/dist/chunk-EF32ILJL.mjs +0 -102
- package/dist/chunk-EI2LRVWJ.mjs +0 -207
- package/dist/chunk-EUKEYW72.mjs +0 -496
- package/dist/chunk-F2EEQP5O.mjs +0 -86
- package/dist/chunk-F3JU2ZCE.mjs +0 -575
- package/dist/chunk-FGFWZMUQ.mjs +0 -64
- package/dist/chunk-FH6ICLNP.mjs +0 -142
- package/dist/chunk-FHFXUKFP.mjs +0 -147
- package/dist/chunk-FJS5FBXO.mjs +0 -233
- package/dist/chunk-FK5X6HFL.mjs +0 -111
- package/dist/chunk-FNFID6QB.mjs +0 -45
- package/dist/chunk-FRVZ7D6D.mjs +0 -293
- package/dist/chunk-FSXTONUR.mjs +0 -147
- package/dist/chunk-FVZY7IZ4.mjs +0 -575
- package/dist/chunk-G2YVDCRB.mjs +0 -137
- package/dist/chunk-G4L7WAJS.mjs +0 -64
- package/dist/chunk-G6F6VL4O.mjs +0 -54
- package/dist/chunk-GCIJYVRC.mjs +0 -86
- package/dist/chunk-GEPISSKR.mjs +0 -263
- package/dist/chunk-GFUJVQ7L.mjs +0 -64
- package/dist/chunk-GIIJQKAV.mjs +0 -164
- package/dist/chunk-GUNWHOQO.mjs +0 -42
- package/dist/chunk-GWSLXZES.mjs +0 -263
- package/dist/chunk-H5KYMLLB.mjs +0 -14
- package/dist/chunk-HAUQAFOF.mjs +0 -97
- package/dist/chunk-HBF5QEDH.mjs +0 -42
- package/dist/chunk-HQMYRYMY.mjs +0 -6
- package/dist/chunk-I2MHQEEZ.mjs +0 -575
- package/dist/chunk-IE3V5VLN.mjs +0 -64
- package/dist/chunk-IHXSHE2Z.mjs +0 -56
- package/dist/chunk-IPHFDI2L.mjs +0 -68
- package/dist/chunk-J3EIGOXQ.mjs +0 -72
- package/dist/chunk-JHNKZIHY.mjs +0 -137
- package/dist/chunk-JJHZBWZM.mjs +0 -118
- package/dist/chunk-JOUNLDB6.mjs +0 -225
- package/dist/chunk-JS55BGBM.mjs +0 -157
- package/dist/chunk-JTL3CVFU.mjs +0 -114
- package/dist/chunk-JVEOQFUX.mjs +0 -52
- package/dist/chunk-JW4BRX5E.mjs +0 -140
- package/dist/chunk-K2ZJWUV6.mjs +0 -86
- package/dist/chunk-K6NLD6SB.mjs +0 -64
- package/dist/chunk-KALJBR6Z.mjs +0 -142
- package/dist/chunk-KBXXX7L4.mjs +0 -209
- package/dist/chunk-KHE3G7SG.mjs +0 -184
- package/dist/chunk-KOTF4TTZ.mjs +0 -403
- package/dist/chunk-KQNLUUBZ.mjs +0 -137
- package/dist/chunk-KQXR3GN2.mjs +0 -140
- package/dist/chunk-KR26CBFE.mjs +0 -58
- package/dist/chunk-KUMLJGXY.mjs +0 -58
- package/dist/chunk-KWA5TKXS.mjs +0 -574
- package/dist/chunk-KXI2IOJM.mjs +0 -97
- package/dist/chunk-KXJLNURI.mjs +0 -153
- package/dist/chunk-KXY2PTDQ.mjs +0 -263
- package/dist/chunk-L25ON7WB.mjs +0 -52
- package/dist/chunk-LBBIQOSH.mjs +0 -53
- package/dist/chunk-LD7ATCWW.mjs +0 -97
- package/dist/chunk-LDR7MZLX.mjs +0 -227
- package/dist/chunk-LRMB4VBU.mjs +0 -112
- package/dist/chunk-LTO3TVUW.mjs +0 -71
- package/dist/chunk-LU2SNC5G.mjs +0 -392
- package/dist/chunk-LVMFPATK.mjs +0 -54
- package/dist/chunk-MILMGDQ2.mjs +0 -15
- package/dist/chunk-MKEHOFA2.mjs +0 -43
- package/dist/chunk-MSMABD52.mjs +0 -72
- package/dist/chunk-MTGPR7WY.mjs +0 -142
- package/dist/chunk-MTMKXMB3.mjs +0 -496
- package/dist/chunk-MWRADLNP.mjs +0 -86
- package/dist/chunk-N65TF5SP.mjs +0 -184
- package/dist/chunk-NCBAWY7A.mjs +0 -139
- package/dist/chunk-ND223BOF.mjs +0 -256
- package/dist/chunk-NGJKJ4R2.mjs +0 -184
- package/dist/chunk-NISGA2YZ.mjs +0 -55
- package/dist/chunk-NM6PHRGO.mjs +0 -263
- package/dist/chunk-NMMHN5LB.mjs +0 -579
- package/dist/chunk-NNKU4OZY.mjs +0 -147
- package/dist/chunk-NNZUZLG3.mjs +0 -416
- package/dist/chunk-NOLYW3V4.mjs +0 -140
- package/dist/chunk-NYEWIYVQ.mjs +0 -86
- package/dist/chunk-NZJJ7FRK.mjs +0 -339
- package/dist/chunk-O77KTDMH.mjs +0 -44
- package/dist/chunk-OALSL7C2.mjs +0 -212
- package/dist/chunk-OGJSTE4A.mjs +0 -86
- package/dist/chunk-OHIHIQAS.mjs +0 -102
- package/dist/chunk-OJJADMUB.mjs +0 -71
- package/dist/chunk-OMFDQURC.mjs +0 -84
- package/dist/chunk-ORRPH43K.mjs +0 -127
- package/dist/chunk-OXO3HVCT.mjs +0 -124
- package/dist/chunk-P4IRDGB4.mjs +0 -43
- package/dist/chunk-PD42OYFT.mjs +0 -150
- package/dist/chunk-PJ62NB7Z.mjs +0 -319
- package/dist/chunk-PL26CDZN.mjs +0 -97
- package/dist/chunk-PM2IUGNR.mjs +0 -29
- package/dist/chunk-PO5JZQVN.mjs +0 -111
- package/dist/chunk-PQR6WIIY.mjs +0 -348
- package/dist/chunk-PS6PZL5W.mjs +0 -86
- package/dist/chunk-PTBV5DCB.mjs +0 -97
- package/dist/chunk-PU73YRKJ.mjs +0 -27
- package/dist/chunk-PXZCOEZ6.mjs +0 -184
- package/dist/chunk-PYYXC7US.mjs +0 -76
- package/dist/chunk-Q4W4ODBP.mjs +0 -319
- package/dist/chunk-QAJ4C5RT.mjs +0 -263
- package/dist/chunk-QDCFQF6J.mjs +0 -36
- package/dist/chunk-QDNFJVVE.mjs +0 -70
- package/dist/chunk-QEXIYXXU.mjs +0 -62
- package/dist/chunk-QG7OB5MD.mjs +0 -86
- package/dist/chunk-QM7TE5C3.mjs +0 -97
- package/dist/chunk-QRQG2BI2.mjs +0 -67
- package/dist/chunk-QXJNV5EJ.mjs +0 -110
- package/dist/chunk-QYAZXDXI.mjs +0 -142
- package/dist/chunk-RCP27MRC.mjs +0 -33
- package/dist/chunk-RGLEJWLU.mjs +0 -173
- package/dist/chunk-RIXU6NZ2.mjs +0 -122
- package/dist/chunk-RNDHAIPS.mjs +0 -64
- package/dist/chunk-RTSLRXJC.mjs +0 -122
- package/dist/chunk-RWFKZ3DF.mjs +0 -413
- package/dist/chunk-RWZ3ORIM.mjs +0 -136
- package/dist/chunk-RXHJYGSJ.mjs +0 -53
- package/dist/chunk-S25KNTHZ.mjs +0 -137
- package/dist/chunk-SCOVKXZ7.mjs +0 -223
- package/dist/chunk-SGIJ36LI.mjs +0 -259
- package/dist/chunk-SHYMRCLT.mjs +0 -221
- package/dist/chunk-SQVCCSNN.mjs +0 -41
- package/dist/chunk-SU26BEIK.mjs +0 -86
- package/dist/chunk-SW6KNICI.mjs +0 -52
- package/dist/chunk-SY6DVJKB.mjs +0 -184
- package/dist/chunk-T23OBCRC.mjs +0 -295
- package/dist/chunk-T2NSVWBH.mjs +0 -77
- package/dist/chunk-T3PPEX64.mjs +0 -164
- package/dist/chunk-TDQUAKUL.mjs +0 -64
- package/dist/chunk-TE5IC7IP.mjs +0 -36
- package/dist/chunk-TKASBGF7.mjs +0 -62
- package/dist/chunk-TMDZALIN.mjs +0 -110
- package/dist/chunk-TU4VVM34.mjs +0 -23
- package/dist/chunk-U2WETRQJ.mjs +0 -86
- package/dist/chunk-U3RZV7XO.mjs +0 -58
- package/dist/chunk-USHLLE7C.mjs +0 -137
- package/dist/chunk-UU6LVKA3.mjs +0 -112
- package/dist/chunk-UXIF75BV.mjs +0 -36
- package/dist/chunk-UXODHQZH.mjs +0 -41
- package/dist/chunk-V37YOE4P.mjs +0 -184
- package/dist/chunk-V6QVJWJR.mjs +0 -86
- package/dist/chunk-V6T5VMWD.mjs +0 -26
- package/dist/chunk-V72EJZDX.mjs +0 -137
- package/dist/chunk-V7LPVPGH.mjs +0 -305
- package/dist/chunk-VESIRBN4.mjs +0 -263
- package/dist/chunk-VGKL2ALO.mjs +0 -184
- package/dist/chunk-VJDH54HJ.mjs +0 -56
- package/dist/chunk-VPZEDAAB.mjs +0 -184
- package/dist/chunk-VQHHSD7C.mjs +0 -97
- package/dist/chunk-VZPN7FNH.mjs +0 -308
- package/dist/chunk-WB5BPM5Q.mjs +0 -55
- package/dist/chunk-WFONGZGK.mjs +0 -42
- package/dist/chunk-WKZ2ZIPO.mjs +0 -112
- package/dist/chunk-WVRHFGGB.mjs +0 -97
- package/dist/chunk-WYSHH4LR.mjs +0 -141
- package/dist/chunk-WZVY7DA6.mjs +0 -44
- package/dist/chunk-X3GPLJGD.mjs +0 -152
- package/dist/chunk-X6K3ZD62.mjs +0 -53
- package/dist/chunk-X77DFNE3.mjs +0 -136
- package/dist/chunk-XNS4O6QJ.mjs +0 -7
- package/dist/chunk-XRLFLKHG.mjs +0 -14
- package/dist/chunk-XTDZQD4A.mjs +0 -110
- package/dist/chunk-XTFNK6PX.mjs +0 -220
- package/dist/chunk-XXCBJJZE.mjs +0 -88
- package/dist/chunk-Y3PX242G.mjs +0 -225
- package/dist/chunk-Y57QWXS4.mjs +0 -122
- package/dist/chunk-YKP7JHV2.mjs +0 -102
- package/dist/chunk-YRCBBEPB.mjs +0 -142
- package/dist/chunk-YSKZR66G.mjs +0 -102
- package/dist/chunk-YUDOACNS.mjs +0 -184
- package/dist/chunk-YVNZMBZ6.mjs +0 -501
- package/dist/chunk-YWE5AILJ.mjs +0 -137
- package/dist/chunk-YYER5QOG.mjs +0 -44
- package/dist/chunk-Z6LVSACJ.mjs +0 -86
- package/dist/chunk-ZFLKX6WD.mjs +0 -97
- package/dist/chunk-ZGMM6IPQ.mjs +0 -79
- package/dist/chunk-ZHNFS3MK.mjs +0 -56
- package/dist/chunk-ZHRQQZ4X.mjs +0 -102
- package/dist/chunk-ZJCAKCMN.mjs +0 -89
- package/dist/chunk-ZKKBIQBA.mjs +0 -413
- package/dist/chunk-ZMIMAMO2.mjs +0 -14
- package/dist/chunk-ZR53XY37.mjs +0 -499
- package/dist/chunk-ZR6MFTT7.mjs +0 -142
- package/dist/chunk-ZVFZIZM2.mjs +0 -150
package/dist/index.mjs
CHANGED
|
@@ -1,191 +1,2436 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GuildEmoji
|
|
3
|
-
} from "./chunk-IHXSHE2Z.mjs";
|
|
4
|
-
import {
|
|
5
|
-
GuildSticker
|
|
6
|
-
} from "./chunk-KR26CBFE.mjs";
|
|
7
|
-
import {
|
|
8
|
-
Guild,
|
|
9
|
-
GuildMemberManager
|
|
10
|
-
} from "./chunk-4SWR3ZEZ.mjs";
|
|
11
|
-
import {
|
|
12
|
-
MessageReaction
|
|
13
|
-
} from "./chunk-TDQUAKUL.mjs";
|
|
14
|
-
import {
|
|
15
|
-
ClientUser,
|
|
16
|
-
User
|
|
17
|
-
} from "./chunk-JW4BRX5E.mjs";
|
|
18
|
-
import {
|
|
19
|
-
Message,
|
|
20
|
-
ReactionCollector
|
|
21
|
-
} from "./chunk-4OEOU7G7.mjs";
|
|
22
|
-
import {
|
|
23
|
-
Webhook
|
|
24
|
-
} from "./chunk-FHFXUKFP.mjs";
|
|
25
|
-
import {
|
|
26
|
-
Invite
|
|
27
|
-
} from "./chunk-QEXIYXXU.mjs";
|
|
28
|
-
import {
|
|
29
|
-
CategoryChannel,
|
|
30
|
-
Channel,
|
|
31
|
-
DMChannel,
|
|
32
|
-
GuildChannel,
|
|
33
|
-
LinkChannel,
|
|
34
|
-
MessageCollector,
|
|
35
|
-
MessageManager,
|
|
36
|
-
TextChannel,
|
|
37
|
-
VoiceChannel
|
|
38
|
-
} from "./chunk-DJQXAQLR.mjs";
|
|
39
|
-
import {
|
|
40
|
-
ErrorCodes,
|
|
41
|
-
FluxerError
|
|
42
|
-
} from "./chunk-6S3BDHBI.mjs";
|
|
43
|
-
import {
|
|
44
|
-
Events
|
|
45
|
-
} from "./chunk-AH7KYH2Z.mjs";
|
|
46
|
-
import {
|
|
47
|
-
buildSendBody,
|
|
48
|
-
resolveMessageFiles
|
|
49
|
-
} from "./chunk-VJDH54HJ.mjs";
|
|
50
|
-
import {
|
|
51
|
-
GuildMember
|
|
52
|
-
} from "./chunk-24E6OQID.mjs";
|
|
53
|
-
import {
|
|
54
|
-
cdnAvatarURL,
|
|
55
|
-
cdnBannerURL,
|
|
56
|
-
cdnDefaultAvatarURL,
|
|
57
|
-
cdnDisplayAvatarURL,
|
|
58
|
-
cdnMemberAvatarURL,
|
|
59
|
-
cdnMemberBannerURL
|
|
60
|
-
} from "./chunk-G6F6VL4O.mjs";
|
|
61
|
-
import {
|
|
62
|
-
CDN_URL,
|
|
63
|
-
STATIC_CDN_URL
|
|
64
|
-
} from "./chunk-BKPVGBOT.mjs";
|
|
65
|
-
import {
|
|
66
|
-
Role
|
|
67
|
-
} from "./chunk-2ZSMLDEI.mjs";
|
|
68
|
-
import {
|
|
69
|
-
GuildBan
|
|
70
|
-
} from "./chunk-UXIF75BV.mjs";
|
|
71
|
-
import {
|
|
72
|
-
Base
|
|
73
|
-
} from "./chunk-XNS4O6QJ.mjs";
|
|
74
|
-
|
|
75
1
|
// src/client/Client.ts
|
|
76
|
-
import { EventEmitter } from "events";
|
|
2
|
+
import { EventEmitter as EventEmitter3 } from "events";
|
|
77
3
|
import { REST } from "@fluxerjs/rest";
|
|
78
4
|
import { WebSocketManager } from "@fluxerjs/ws";
|
|
79
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Routes as Routes20
|
|
7
|
+
} from "@fluxerjs/types";
|
|
80
8
|
|
|
81
9
|
// src/client/ChannelManager.ts
|
|
10
|
+
import { Collection as Collection4 } from "@fluxerjs/collection";
|
|
11
|
+
import { Routes as Routes6 } from "@fluxerjs/types";
|
|
12
|
+
import { emitDeprecationWarning as emitDeprecationWarning2 } from "@fluxerjs/util";
|
|
13
|
+
import { FluxerAPIError as FluxerAPIError2, RateLimitError as RateLimitError2 } from "@fluxerjs/rest";
|
|
14
|
+
|
|
15
|
+
// src/errors/FluxerError.ts
|
|
16
|
+
var FluxerError = class _FluxerError extends Error {
|
|
17
|
+
code;
|
|
18
|
+
constructor(message, options) {
|
|
19
|
+
super(message, options?.cause ? { cause: options.cause } : void 0);
|
|
20
|
+
this.name = "FluxerError";
|
|
21
|
+
this.code = options?.code;
|
|
22
|
+
Object.setPrototypeOf(this, _FluxerError.prototype);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// src/errors/ErrorCodes.ts
|
|
27
|
+
var ErrorCodes = {
|
|
28
|
+
ClientNotReady: "CLIENT_NOT_READY",
|
|
29
|
+
InvalidToken: "INVALID_TOKEN",
|
|
30
|
+
AlreadyLoggedIn: "ALREADY_LOGGED_IN",
|
|
31
|
+
ChannelNotFound: "CHANNEL_NOT_FOUND",
|
|
32
|
+
MessageNotFound: "MESSAGE_NOT_FOUND",
|
|
33
|
+
GuildNotFound: "GUILD_NOT_FOUND",
|
|
34
|
+
MemberNotFound: "MEMBER_NOT_FOUND",
|
|
35
|
+
RoleNotFound: "ROLE_NOT_FOUND",
|
|
36
|
+
EmojiNotInGuild: "EMOJI_NOT_IN_GUILD",
|
|
37
|
+
EmojiNotFound: "EMOJI_NOT_FOUND"
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/util/messageUtils.ts
|
|
41
|
+
import { EmbedBuilder } from "@fluxerjs/builders";
|
|
42
|
+
var FILE_FETCH_TIMEOUT_MS = 3e4;
|
|
43
|
+
async function resolveMessageFiles(files) {
|
|
44
|
+
const result = [];
|
|
45
|
+
for (let i = 0; i < files.length; i++) {
|
|
46
|
+
const f = files[i];
|
|
47
|
+
const filename = f.filename ?? f.name;
|
|
48
|
+
if ("url" in f && f.url) {
|
|
49
|
+
if (!URL.canParse(f.url)) {
|
|
50
|
+
throw new Error(`Invalid file URL at index ${i}: ${f.url}`);
|
|
51
|
+
}
|
|
52
|
+
const res = await fetch(f.url, {
|
|
53
|
+
signal: AbortSignal.timeout(FILE_FETCH_TIMEOUT_MS)
|
|
54
|
+
});
|
|
55
|
+
if (!res.ok) {
|
|
56
|
+
throw new Error(`Failed to fetch file from ${f.url}: ${res.status} ${res.statusText}`);
|
|
57
|
+
}
|
|
58
|
+
const data = await res.arrayBuffer();
|
|
59
|
+
result.push({ name: f.name, data, filename });
|
|
60
|
+
} else if ("data" in f && f.data != null) {
|
|
61
|
+
result.push({ name: f.name, data: f.data, filename });
|
|
62
|
+
} else {
|
|
63
|
+
throw new Error(`File at index ${i} must have either "data" or "url"`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
function buildSendBody(options) {
|
|
69
|
+
const body = typeof options === "string" ? { content: options } : options;
|
|
70
|
+
const result = {};
|
|
71
|
+
if (body.content !== void 0) result.content = body.content;
|
|
72
|
+
if (body.embeds?.length) {
|
|
73
|
+
result.embeds = body.embeds.map((e) => e instanceof EmbedBuilder ? e.toJSON() : e);
|
|
74
|
+
}
|
|
75
|
+
if (body.files?.length && body.attachments) {
|
|
76
|
+
result.attachments = body.attachments.map((a) => ({
|
|
77
|
+
id: a.id,
|
|
78
|
+
filename: a.filename,
|
|
79
|
+
...a.title != null && { title: a.title },
|
|
80
|
+
...a.description != null && { description: a.description },
|
|
81
|
+
...a.flags != null && { flags: a.flags }
|
|
82
|
+
}));
|
|
83
|
+
} else if (body.files?.length) {
|
|
84
|
+
result.attachments = body.files.map((f, i) => ({
|
|
85
|
+
id: i,
|
|
86
|
+
filename: f.filename ?? f.name
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/client/MessageManager.ts
|
|
93
|
+
import { Routes as Routes2 } from "@fluxerjs/types";
|
|
94
|
+
import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
|
|
95
|
+
|
|
96
|
+
// src/structures/Base.ts
|
|
97
|
+
var Base = class {
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// src/structures/Message.ts
|
|
101
|
+
import { Collection as Collection2 } from "@fluxerjs/collection";
|
|
102
|
+
import { MessageType, Routes } from "@fluxerjs/types";
|
|
103
|
+
import { EmbedBuilder as EmbedBuilder2 } from "@fluxerjs/builders";
|
|
104
|
+
|
|
105
|
+
// src/util/ReactionCollector.ts
|
|
106
|
+
import { EventEmitter } from "events";
|
|
82
107
|
import { Collection } from "@fluxerjs/collection";
|
|
83
|
-
|
|
108
|
+
|
|
109
|
+
// src/util/Events.ts
|
|
110
|
+
var Events = {
|
|
111
|
+
Ready: "ready",
|
|
112
|
+
MessageCreate: "messageCreate",
|
|
113
|
+
MessageUpdate: "messageUpdate",
|
|
114
|
+
MessageDelete: "messageDelete",
|
|
115
|
+
MessageDeleteBulk: "messageDeleteBulk",
|
|
116
|
+
MessageReactionAdd: "messageReactionAdd",
|
|
117
|
+
MessageReactionRemove: "messageReactionRemove",
|
|
118
|
+
MessageReactionRemoveAll: "messageReactionRemoveAll",
|
|
119
|
+
MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
|
|
120
|
+
InteractionCreate: "interactionCreate",
|
|
121
|
+
GuildCreate: "guildCreate",
|
|
122
|
+
GuildUpdate: "guildUpdate",
|
|
123
|
+
GuildDelete: "guildDelete",
|
|
124
|
+
GuildBanAdd: "guildBanAdd",
|
|
125
|
+
GuildBanRemove: "guildBanRemove",
|
|
126
|
+
GuildEmojisUpdate: "guildEmojisUpdate",
|
|
127
|
+
GuildStickersUpdate: "guildStickersUpdate",
|
|
128
|
+
GuildIntegrationsUpdate: "guildIntegrationsUpdate",
|
|
129
|
+
GuildMemberAdd: "guildMemberAdd",
|
|
130
|
+
GuildMemberUpdate: "guildMemberUpdate",
|
|
131
|
+
GuildMemberRemove: "guildMemberRemove",
|
|
132
|
+
GuildRoleCreate: "guildRoleCreate",
|
|
133
|
+
GuildRoleUpdate: "guildRoleUpdate",
|
|
134
|
+
GuildRoleDelete: "guildRoleDelete",
|
|
135
|
+
GuildScheduledEventCreate: "guildScheduledEventCreate",
|
|
136
|
+
GuildScheduledEventUpdate: "guildScheduledEventUpdate",
|
|
137
|
+
GuildScheduledEventDelete: "guildScheduledEventDelete",
|
|
138
|
+
ChannelCreate: "channelCreate",
|
|
139
|
+
ChannelUpdate: "channelUpdate",
|
|
140
|
+
ChannelDelete: "channelDelete",
|
|
141
|
+
ChannelPinsUpdate: "channelPinsUpdate",
|
|
142
|
+
InviteCreate: "inviteCreate",
|
|
143
|
+
InviteDelete: "inviteDelete",
|
|
144
|
+
TypingStart: "typingStart",
|
|
145
|
+
UserUpdate: "userUpdate",
|
|
146
|
+
PresenceUpdate: "presenceUpdate",
|
|
147
|
+
VoiceStateUpdate: "voiceStateUpdate",
|
|
148
|
+
VoiceServerUpdate: "voiceServerUpdate",
|
|
149
|
+
VoiceStatesSync: "voiceStatesSync",
|
|
150
|
+
WebhooksUpdate: "webhooksUpdate",
|
|
151
|
+
Resumed: "resumed",
|
|
152
|
+
Error: "error",
|
|
153
|
+
Debug: "debug"
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// src/util/ReactionCollector.ts
|
|
157
|
+
var ReactionCollector = class extends EventEmitter {
|
|
158
|
+
client;
|
|
159
|
+
messageId;
|
|
160
|
+
channelId;
|
|
161
|
+
options;
|
|
162
|
+
collected = new Collection();
|
|
163
|
+
_timeout = null;
|
|
164
|
+
_ended = false;
|
|
165
|
+
_listener;
|
|
166
|
+
constructor(client, messageId, channelId, options = {}) {
|
|
167
|
+
super();
|
|
168
|
+
this.client = client;
|
|
169
|
+
this.messageId = messageId;
|
|
170
|
+
this.channelId = channelId;
|
|
171
|
+
this.options = {
|
|
172
|
+
filter: options.filter ?? (() => true),
|
|
173
|
+
time: options.time ?? 0,
|
|
174
|
+
max: options.max ?? 0
|
|
175
|
+
};
|
|
176
|
+
this._listener = (reaction, user, _msgId, chId, _emoji, userId) => {
|
|
177
|
+
if (this._ended || reaction.messageId !== this.messageId || chId !== this.channelId) return;
|
|
178
|
+
if (!this.options.filter(reaction, user)) return;
|
|
179
|
+
const key = `${userId}:${reaction.emoji.id ?? reaction.emoji.name}`;
|
|
180
|
+
this.collected.set(key, { reaction, user });
|
|
181
|
+
this.emit("collect", reaction, user);
|
|
182
|
+
if (this.options.max > 0 && this.collected.size >= this.options.max) {
|
|
183
|
+
this.stop("limit");
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
this.client.on(Events.MessageReactionAdd, this._listener);
|
|
187
|
+
if (this.options.time > 0) {
|
|
188
|
+
this._timeout = setTimeout(() => this.stop("time"), this.options.time);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
stop(reason = "user") {
|
|
192
|
+
if (this._ended) return;
|
|
193
|
+
this._ended = true;
|
|
194
|
+
this.client.off(Events.MessageReactionAdd, this._listener);
|
|
195
|
+
if (this._timeout) {
|
|
196
|
+
clearTimeout(this._timeout);
|
|
197
|
+
this._timeout = null;
|
|
198
|
+
}
|
|
199
|
+
this.emit("end", this.collected, reason);
|
|
200
|
+
}
|
|
201
|
+
on(event, listener) {
|
|
202
|
+
return super.on(event, listener);
|
|
203
|
+
}
|
|
204
|
+
emit(event, ...args) {
|
|
205
|
+
return super.emit(event, ...args);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// src/structures/Message.ts
|
|
210
|
+
var Message = class _Message extends Base {
|
|
211
|
+
client;
|
|
212
|
+
id;
|
|
213
|
+
channelId;
|
|
214
|
+
guildId;
|
|
215
|
+
author;
|
|
216
|
+
content;
|
|
217
|
+
createdAt;
|
|
218
|
+
editedAt;
|
|
219
|
+
pinned;
|
|
220
|
+
attachments;
|
|
221
|
+
type;
|
|
222
|
+
flags;
|
|
223
|
+
mentionEveryone;
|
|
224
|
+
tts;
|
|
225
|
+
embeds;
|
|
226
|
+
stickers;
|
|
227
|
+
reactions;
|
|
228
|
+
messageReference;
|
|
229
|
+
messageSnapshots;
|
|
230
|
+
call;
|
|
231
|
+
referencedMessage;
|
|
232
|
+
/** Webhook ID if this message was sent via webhook. Null otherwise. */
|
|
233
|
+
webhookId;
|
|
234
|
+
/** Users mentioned in this message. */
|
|
235
|
+
mentions;
|
|
236
|
+
/** Role IDs mentioned in this message. */
|
|
237
|
+
mentionRoles;
|
|
238
|
+
/** Client-side nonce for acknowledgment. Null if not provided. */
|
|
239
|
+
nonce;
|
|
240
|
+
/** Channel where this message was sent. Resolved from cache; null if not cached (e.g. DM channel not in cache). */
|
|
241
|
+
get channel() {
|
|
242
|
+
return this.client.channels.get(this.channelId) ?? null;
|
|
243
|
+
}
|
|
244
|
+
/** Guild where this message was sent. Resolved from cache; null for DMs or if not cached. */
|
|
245
|
+
get guild() {
|
|
246
|
+
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Resolve the channel (from cache or API). Use when you need the channel and it may not be cached.
|
|
250
|
+
* @returns The channel
|
|
251
|
+
* @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
|
|
252
|
+
*/
|
|
253
|
+
async resolveChannel() {
|
|
254
|
+
return this.client.channels.resolve(this.channelId);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Resolve the guild (from cache or API). Returns null for DMs.
|
|
258
|
+
* @returns The guild, or null if this is a DM or guild not found
|
|
259
|
+
*/
|
|
260
|
+
async resolveGuild() {
|
|
261
|
+
return this.guildId ? this.client.guilds.resolve(this.guildId) : null;
|
|
262
|
+
}
|
|
263
|
+
/** @param data - API message from POST/PATCH /channels/{id}/messages or gateway MESSAGE_CREATE */
|
|
264
|
+
constructor(client, data) {
|
|
265
|
+
super();
|
|
266
|
+
this.client = client;
|
|
267
|
+
this.id = data.id;
|
|
268
|
+
this.channelId = data.channel_id;
|
|
269
|
+
this.guildId = data.guild_id ?? null;
|
|
270
|
+
this.author = client.getOrCreateUser(data.author);
|
|
271
|
+
this.content = data.content;
|
|
272
|
+
this.createdAt = new Date(data.timestamp);
|
|
273
|
+
this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
|
|
274
|
+
this.pinned = data.pinned;
|
|
275
|
+
this.attachments = new Collection2();
|
|
276
|
+
for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
|
|
277
|
+
this.type = data.type ?? MessageType.Default;
|
|
278
|
+
this.flags = data.flags ?? 0;
|
|
279
|
+
this.mentionEveryone = data.mention_everyone ?? false;
|
|
280
|
+
this.tts = data.tts ?? false;
|
|
281
|
+
this.embeds = data.embeds ?? [];
|
|
282
|
+
this.stickers = data.stickers ?? [];
|
|
283
|
+
this.reactions = data.reactions ?? [];
|
|
284
|
+
this.messageReference = data.message_reference ?? null;
|
|
285
|
+
this.messageSnapshots = data.message_snapshots ?? [];
|
|
286
|
+
this.call = data.call ?? null;
|
|
287
|
+
this.referencedMessage = data.referenced_message ? new _Message(client, data.referenced_message) : null;
|
|
288
|
+
this.webhookId = data.webhook_id ?? null;
|
|
289
|
+
this.mentions = (data.mentions ?? []).map((u) => client.getOrCreateUser(u));
|
|
290
|
+
this.mentionRoles = data.mention_roles ?? [];
|
|
291
|
+
this.nonce = data.nonce ?? null;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Send a message to this channel without replying. Use when you want a standalone message.
|
|
295
|
+
* @param options - Text content or object with content, embeds, and/or files
|
|
296
|
+
* @example
|
|
297
|
+
* await message.send('Pong!');
|
|
298
|
+
* await message.send({ embeds: [embed] }); // EmbedBuilder auto-converted
|
|
299
|
+
* await message.send({ content: 'File', files: [{ name: 'data.txt', data }] });
|
|
300
|
+
*/
|
|
301
|
+
async send(options) {
|
|
302
|
+
const opts = typeof options === "string" ? { content: options } : options;
|
|
303
|
+
const body = buildSendBody(options);
|
|
304
|
+
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
305
|
+
const postOptions = files?.length ? { body, files } : { body };
|
|
306
|
+
const data = await this.client.rest.post(Routes.channelMessages(this.channelId), postOptions);
|
|
307
|
+
return new _Message(this.client, data);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Send a message to a specific channel. Use for logging, forwarding, or sending to another channel in the guild.
|
|
311
|
+
* @param channelId - Snowflake of the target channel (e.g. log channel ID)
|
|
312
|
+
* @param options - Text content or object with content and/or embeds
|
|
313
|
+
* @example
|
|
314
|
+
* await message.sendTo(logChannelId, 'User ' + message.author.username + ' said: ' + message.content);
|
|
315
|
+
* await message.sendTo(announceChannelId, { embeds: [embed] });
|
|
316
|
+
*/
|
|
317
|
+
async sendTo(channelId, options) {
|
|
318
|
+
return this.client.channels.send(channelId, options);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Reply to this message (shows as a reply in the client).
|
|
322
|
+
* @param options - Text content or object with content, embeds, and/or files
|
|
323
|
+
* @example
|
|
324
|
+
* await message.reply('Pong!');
|
|
325
|
+
* await message.reply({ embeds: [embed] });
|
|
326
|
+
*/
|
|
327
|
+
async reply(options) {
|
|
328
|
+
const opts = typeof options === "string" ? { content: options } : options;
|
|
329
|
+
const base = buildSendBody(options);
|
|
330
|
+
const body = {
|
|
331
|
+
...base,
|
|
332
|
+
message_reference: {
|
|
333
|
+
channel_id: this.channelId,
|
|
334
|
+
message_id: this.id,
|
|
335
|
+
guild_id: this.guildId ?? void 0
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
339
|
+
const postOptions = files?.length ? { body, files } : { body };
|
|
340
|
+
const data = await this.client.rest.post(Routes.channelMessages(this.channelId), postOptions);
|
|
341
|
+
return new _Message(this.client, data);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Edit this message. Only the author (or admins) can edit.
|
|
345
|
+
* @param options - New content and/or embeds
|
|
346
|
+
*/
|
|
347
|
+
async edit(options) {
|
|
348
|
+
const body = {};
|
|
349
|
+
if (options.content !== void 0) body.content = options.content;
|
|
350
|
+
if (options.embeds?.length) {
|
|
351
|
+
body.embeds = options.embeds.map((e) => e instanceof EmbedBuilder2 ? e.toJSON() : e);
|
|
352
|
+
}
|
|
353
|
+
const data = await this.client.rest.patch(Routes.channelMessage(this.channelId, this.id), {
|
|
354
|
+
body
|
|
355
|
+
});
|
|
356
|
+
return new _Message(this.client, data);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Create a reaction collector for this message.
|
|
360
|
+
* Collects reactions matching the filter until time expires or max is reached.
|
|
361
|
+
* @param options - Filter, time (ms), and max count
|
|
362
|
+
* @example
|
|
363
|
+
* const collector = message.createReactionCollector({ filter: (r, u) => u.id === userId, time: 10000 });
|
|
364
|
+
* collector.on('collect', (reaction, user) => console.log(user.username, 'reacted with', reaction.emoji.name));
|
|
365
|
+
* collector.on('end', (collected, reason) => { ... });
|
|
366
|
+
*/
|
|
367
|
+
createReactionCollector(options) {
|
|
368
|
+
return new ReactionCollector(this.client, this.id, this.channelId, options);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Re-fetch this message from the API to get the latest content, embeds, reactions, etc.
|
|
372
|
+
* Use when you have a stale Message (e.g. from an old event or cache) and need fresh data.
|
|
373
|
+
* @returns The updated message
|
|
374
|
+
* @throws FluxerError with MESSAGE_NOT_FOUND if the message was deleted or does not exist
|
|
375
|
+
* @example
|
|
376
|
+
* const updated = await message.fetch();
|
|
377
|
+
* console.log('Latest content:', updated.content);
|
|
378
|
+
*/
|
|
379
|
+
async fetch() {
|
|
380
|
+
return this.client.channels.fetchMessage(this.channelId, this.id);
|
|
381
|
+
}
|
|
382
|
+
/** Delete this message. */
|
|
383
|
+
async delete() {
|
|
384
|
+
await this.client.rest.delete(Routes.channelMessage(this.channelId, this.id));
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Delete a specific attachment from this message.
|
|
388
|
+
* DELETE /channels/{id}/messages/{id}/attachments/{attachmentId}.
|
|
389
|
+
*/
|
|
390
|
+
async deleteAttachment(attachmentId) {
|
|
391
|
+
await this.client.rest.delete(
|
|
392
|
+
Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
|
|
393
|
+
{ auth: true }
|
|
394
|
+
);
|
|
395
|
+
this.attachments.delete(attachmentId);
|
|
396
|
+
}
|
|
397
|
+
/** Pin this message to the channel. Requires Manage Messages permission. */
|
|
398
|
+
async pin() {
|
|
399
|
+
await this.client.rest.put(Routes.channelPinMessage(this.channelId, this.id));
|
|
400
|
+
this.pinned = true;
|
|
401
|
+
}
|
|
402
|
+
/** Unpin this message from the channel. Requires Manage Messages permission. */
|
|
403
|
+
async unpin() {
|
|
404
|
+
await this.client.rest.delete(Routes.channelPinMessage(this.channelId, this.id));
|
|
405
|
+
this.pinned = false;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Format emoji for reaction API: unicode string or "name:id" for custom.
|
|
409
|
+
* For string resolution (e.g. :name:), use client.resolveEmoji; Message methods resolve automatically when guildId is available.
|
|
410
|
+
*/
|
|
411
|
+
static formatEmoji(emoji) {
|
|
412
|
+
if (typeof emoji === "string") return emoji;
|
|
413
|
+
return `${emoji.name}:${emoji.id}`;
|
|
414
|
+
}
|
|
415
|
+
resolveEmojiForReaction(emoji) {
|
|
416
|
+
return this.client.resolveEmoji(emoji, this.guildId);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Add a reaction to this message (as the bot).
|
|
420
|
+
* @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`
|
|
421
|
+
*/
|
|
422
|
+
async react(emoji) {
|
|
423
|
+
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
424
|
+
const route = `${Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/@me`;
|
|
425
|
+
await this.client.rest.put(route);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Remove the bot's reaction, or a specific user's reaction if userId is provided.
|
|
429
|
+
* @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`
|
|
430
|
+
* @param userId - If provided, removes that user's reaction (requires moderator permissions)
|
|
431
|
+
*/
|
|
432
|
+
async removeReaction(emoji, userId) {
|
|
433
|
+
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
434
|
+
const route = `${Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/${userId ?? "@me"}`;
|
|
435
|
+
await this.client.rest.delete(route);
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Remove all reactions from this message.
|
|
439
|
+
* Requires moderator permissions.
|
|
440
|
+
*/
|
|
441
|
+
async removeAllReactions() {
|
|
442
|
+
await this.client.rest.delete(Routes.channelMessageReactions(this.channelId, this.id));
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Remove all reactions of a specific emoji from this message.
|
|
446
|
+
* @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`. Requires moderator permissions.
|
|
447
|
+
*/
|
|
448
|
+
async removeReactionEmoji(emoji) {
|
|
449
|
+
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
450
|
+
await this.client.rest.delete(Routes.channelMessageReaction(this.channelId, this.id, emojiStr));
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Fetch users who reacted with the given emoji.
|
|
454
|
+
* @param emoji - Unicode emoji or custom `{ name, id }`
|
|
455
|
+
* @param options - limit (1–100), after (user ID for pagination)
|
|
456
|
+
* @returns Array of User objects
|
|
457
|
+
*/
|
|
458
|
+
async fetchReactionUsers(emoji, options) {
|
|
459
|
+
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
460
|
+
const params = new URLSearchParams();
|
|
461
|
+
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
462
|
+
if (options?.after) params.set("after", options.after);
|
|
463
|
+
const qs = params.toString();
|
|
464
|
+
const route = Routes.channelMessageReaction(this.channelId, this.id, emojiStr) + (qs ? `?${qs}` : "");
|
|
465
|
+
const data = await this.client.rest.get(route);
|
|
466
|
+
const list = Array.isArray(data) ? data : data?.users ?? [];
|
|
467
|
+
return list.map((u) => this.client.getOrCreateUser(u));
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
// src/client/MessageManager.ts
|
|
472
|
+
var MessageManager = class {
|
|
473
|
+
constructor(client, channelId) {
|
|
474
|
+
this.client = client;
|
|
475
|
+
this.channelId = channelId;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Fetch a message by ID from this channel.
|
|
479
|
+
* @param messageId - Snowflake of the message
|
|
480
|
+
* @returns The message
|
|
481
|
+
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
482
|
+
*/
|
|
483
|
+
async fetch(messageId) {
|
|
484
|
+
try {
|
|
485
|
+
const data = await this.client.rest.get(
|
|
486
|
+
Routes2.channelMessage(this.channelId, messageId)
|
|
487
|
+
);
|
|
488
|
+
return new Message(this.client, data);
|
|
489
|
+
} catch (err) {
|
|
490
|
+
if (err instanceof RateLimitError) throw err;
|
|
491
|
+
if (err instanceof FluxerAPIError && err.statusCode === 404) {
|
|
492
|
+
throw new FluxerError(`Message ${messageId} not found in channel ${this.channelId}`, {
|
|
493
|
+
code: ErrorCodes.MessageNotFound,
|
|
494
|
+
cause: err
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
// src/util/MessageCollector.ts
|
|
503
|
+
import { EventEmitter as EventEmitter2 } from "events";
|
|
504
|
+
import { Collection as Collection3 } from "@fluxerjs/collection";
|
|
505
|
+
var MessageCollector = class extends EventEmitter2 {
|
|
506
|
+
client;
|
|
507
|
+
channelId;
|
|
508
|
+
options;
|
|
509
|
+
collected = new Collection3();
|
|
510
|
+
_timeout = null;
|
|
511
|
+
_ended = false;
|
|
512
|
+
_listener;
|
|
513
|
+
constructor(client, channelId, options = {}) {
|
|
514
|
+
super();
|
|
515
|
+
this.client = client;
|
|
516
|
+
this.channelId = channelId;
|
|
517
|
+
this.options = {
|
|
518
|
+
filter: options.filter ?? (() => true),
|
|
519
|
+
time: options.time ?? 0,
|
|
520
|
+
max: options.max ?? 0
|
|
521
|
+
};
|
|
522
|
+
this._listener = (message) => {
|
|
523
|
+
if (this._ended || message.channelId !== this.channelId) return;
|
|
524
|
+
if (!this.options.filter(message)) return;
|
|
525
|
+
this.collected.set(message.id, message);
|
|
526
|
+
this.emit("collect", message);
|
|
527
|
+
if (this.options.max > 0 && this.collected.size >= this.options.max) {
|
|
528
|
+
this.stop("limit");
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
this.client.on(Events.MessageCreate, this._listener);
|
|
532
|
+
if (this.options.time > 0) {
|
|
533
|
+
this._timeout = setTimeout(() => this.stop("time"), this.options.time);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
stop(reason = "user") {
|
|
537
|
+
if (this._ended) return;
|
|
538
|
+
this._ended = true;
|
|
539
|
+
this.client.off(Events.MessageCreate, this._listener);
|
|
540
|
+
if (this._timeout) {
|
|
541
|
+
clearTimeout(this._timeout);
|
|
542
|
+
this._timeout = null;
|
|
543
|
+
}
|
|
544
|
+
this.emit("end", this.collected, reason);
|
|
545
|
+
}
|
|
546
|
+
on(event, listener) {
|
|
547
|
+
return super.on(event, listener);
|
|
548
|
+
}
|
|
549
|
+
emit(event, ...args) {
|
|
550
|
+
return super.emit(event, ...args);
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
// src/structures/Channel.ts
|
|
555
|
+
import { ChannelType, Routes as Routes5 } from "@fluxerjs/types";
|
|
84
556
|
import { emitDeprecationWarning } from "@fluxerjs/util";
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
557
|
+
|
|
558
|
+
// src/structures/Webhook.ts
|
|
559
|
+
import { Routes as Routes3 } from "@fluxerjs/types";
|
|
560
|
+
|
|
561
|
+
// src/util/Constants.ts
|
|
562
|
+
var CDN_URL = "https://fluxerusercontent.com";
|
|
563
|
+
var STATIC_CDN_URL = "https://fluxerstatic.com";
|
|
564
|
+
|
|
565
|
+
// src/util/cdn.ts
|
|
566
|
+
function getExtension(hash, options) {
|
|
567
|
+
const ext = options?.extension ?? "png";
|
|
568
|
+
if (hash?.startsWith("a_")) return "gif";
|
|
569
|
+
return ext;
|
|
570
|
+
}
|
|
571
|
+
function appendSize(options) {
|
|
572
|
+
return options?.size ? `?size=${options.size}` : "";
|
|
573
|
+
}
|
|
574
|
+
function cdnAvatarURL(userId, avatarHash, options) {
|
|
575
|
+
if (!avatarHash) return null;
|
|
576
|
+
const ext = getExtension(avatarHash, options);
|
|
577
|
+
const size = appendSize(options);
|
|
578
|
+
return `${CDN_URL}/avatars/${userId}/${avatarHash}.${ext}${size}`;
|
|
579
|
+
}
|
|
580
|
+
function cdnDisplayAvatarURL(userId, avatarHash, options) {
|
|
581
|
+
return cdnAvatarURL(userId, avatarHash, options) ?? cdnDefaultAvatarURL(userId);
|
|
582
|
+
}
|
|
583
|
+
function cdnBannerURL(resourceId, bannerHash, options) {
|
|
584
|
+
if (!bannerHash) return null;
|
|
585
|
+
const ext = getExtension(bannerHash, options);
|
|
586
|
+
const size = appendSize(options);
|
|
587
|
+
return `${CDN_URL}/banners/${resourceId}/${bannerHash}.${ext}${size}`;
|
|
588
|
+
}
|
|
589
|
+
function cdnMemberAvatarURL(guildId, userId, avatarHash, options) {
|
|
590
|
+
if (!avatarHash) return null;
|
|
591
|
+
const ext = getExtension(avatarHash, options);
|
|
592
|
+
const size = appendSize(options);
|
|
593
|
+
return `${CDN_URL}/guilds/${guildId}/users/${userId}/avatars/${avatarHash}.${ext}${size}`;
|
|
594
|
+
}
|
|
595
|
+
function cdnMemberBannerURL(guildId, userId, bannerHash, options) {
|
|
596
|
+
if (!bannerHash) return null;
|
|
597
|
+
const ext = getExtension(bannerHash, options);
|
|
598
|
+
const size = appendSize(options);
|
|
599
|
+
return `${CDN_URL}/guilds/${guildId}/users/${userId}/banners/${bannerHash}.${ext}${size}`;
|
|
600
|
+
}
|
|
601
|
+
function cdnDefaultAvatarURL(userIdOrIndex) {
|
|
602
|
+
const index = typeof userIdOrIndex === "string" ? Number(BigInt(userIdOrIndex) % 6n) : Math.abs(Math.floor(userIdOrIndex) % 6);
|
|
603
|
+
return `${STATIC_CDN_URL}/avatars/${index}.png`;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// src/structures/Webhook.ts
|
|
607
|
+
var Webhook = class _Webhook extends Base {
|
|
608
|
+
client;
|
|
609
|
+
id;
|
|
610
|
+
guildId;
|
|
611
|
+
channelId;
|
|
612
|
+
name;
|
|
613
|
+
avatar;
|
|
614
|
+
/** Present only when webhook was created via createWebhook(); not returned when fetching. */
|
|
615
|
+
token;
|
|
616
|
+
/** User who created the webhook. */
|
|
617
|
+
user;
|
|
618
|
+
/** @param data - API webhook from POST /channels/{id}/webhooks (has token) or GET /webhooks/{id} (no token) */
|
|
619
|
+
constructor(client, data) {
|
|
620
|
+
super();
|
|
621
|
+
this.client = client;
|
|
622
|
+
this.id = data.id;
|
|
623
|
+
this.guildId = data.guild_id;
|
|
624
|
+
this.channelId = data.channel_id;
|
|
625
|
+
this.name = data.name ?? "Unknown";
|
|
626
|
+
this.avatar = data.avatar ?? null;
|
|
627
|
+
this.token = data.token ?? null;
|
|
628
|
+
this.user = client.getOrCreateUser(data.user);
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Get the URL for this webhook's avatar.
|
|
632
|
+
* Returns null if the webhook has no custom avatar.
|
|
633
|
+
*/
|
|
634
|
+
avatarURL(options) {
|
|
635
|
+
return cdnAvatarURL(this.id, this.avatar, options);
|
|
636
|
+
}
|
|
637
|
+
/** Delete this webhook. Requires bot token with Manage Webhooks permission. */
|
|
638
|
+
async delete() {
|
|
639
|
+
await this.client.rest.delete(Routes3.webhook(this.id), { auth: true });
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Edit this webhook. With token: name and avatar only. Without token (bot auth): name, avatar, and channel_id.
|
|
643
|
+
* @param options - Fields to update (name, avatar, channel_id when using bot auth)
|
|
644
|
+
* @returns This webhook instance with updated fields
|
|
645
|
+
*/
|
|
646
|
+
async edit(options) {
|
|
647
|
+
const body = {};
|
|
648
|
+
if (options.name !== void 0) body.name = options.name;
|
|
649
|
+
if (options.avatar !== void 0) body.avatar = options.avatar;
|
|
650
|
+
if ("channel_id" in options && options.channel_id !== void 0 && !this.token) {
|
|
651
|
+
body.channel_id = options.channel_id;
|
|
652
|
+
}
|
|
653
|
+
if (this.token) {
|
|
654
|
+
const data2 = await this.client.rest.patch(Routes3.webhookExecute(this.id, this.token), {
|
|
655
|
+
body,
|
|
656
|
+
auth: false
|
|
657
|
+
});
|
|
658
|
+
const w2 = data2;
|
|
659
|
+
this.name = w2.name ?? this.name;
|
|
660
|
+
this.avatar = w2.avatar ?? null;
|
|
661
|
+
return this;
|
|
662
|
+
}
|
|
663
|
+
const data = await this.client.rest.patch(Routes3.webhook(this.id), {
|
|
664
|
+
body,
|
|
665
|
+
auth: true
|
|
666
|
+
});
|
|
667
|
+
const w = data;
|
|
668
|
+
this.name = w.name ?? this.name;
|
|
669
|
+
this.avatar = w.avatar ?? null;
|
|
670
|
+
this.channelId = w.channel_id ?? this.channelId;
|
|
671
|
+
return this;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Send a message via this webhook. Requires the webhook token (only present when created, not when fetched).
|
|
675
|
+
* @param options - Text content or object with content, embeds, username, avatar_url, tts, files, attachments
|
|
676
|
+
* @param wait - If true, waits for the API and returns the created Message; otherwise returns void (204)
|
|
677
|
+
* @throws Error if token is not available
|
|
678
|
+
* @example
|
|
679
|
+
* await webhook.send('Hello!');
|
|
680
|
+
* await webhook.send({ embeds: [embed] });
|
|
681
|
+
* await webhook.send({ content: 'File attached', files: [{ name: 'data.txt', data: buffer }] });
|
|
682
|
+
* const msg = await webhook.send({ content: 'Hi' }, true);
|
|
683
|
+
*/
|
|
684
|
+
async send(options, wait) {
|
|
685
|
+
if (!this.token) {
|
|
686
|
+
throw new Error(
|
|
687
|
+
"Webhook token is required to send. The token is only returned when creating a webhook; fetched webhooks cannot send."
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
const opts = typeof options === "string" ? { content: options } : options;
|
|
691
|
+
const body = buildSendBody(options);
|
|
692
|
+
if (opts.username !== void 0) body.username = opts.username;
|
|
693
|
+
if (opts.avatar_url !== void 0) body.avatar_url = opts.avatar_url;
|
|
694
|
+
if (opts.tts !== void 0) body.tts = opts.tts;
|
|
695
|
+
const route = Routes3.webhookExecute(this.id, this.token) + (wait ? "?wait=true" : "");
|
|
696
|
+
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
697
|
+
const postOptions = files?.length ? { body, files, auth: false } : { body, auth: false };
|
|
698
|
+
const data = await this.client.rest.post(route, postOptions);
|
|
699
|
+
if (wait && data) {
|
|
700
|
+
return new Message(this.client, data);
|
|
701
|
+
}
|
|
702
|
+
return void 0;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Fetch a webhook by ID using bot auth.
|
|
706
|
+
* @param client - The client instance
|
|
707
|
+
* @param webhookId - The webhook ID
|
|
708
|
+
* @returns Webhook without token (cannot send)
|
|
709
|
+
*/
|
|
710
|
+
static async fetch(client, webhookId) {
|
|
711
|
+
const data = await client.rest.get(Routes3.webhook(webhookId));
|
|
712
|
+
return new _Webhook(client, data);
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Create a Webhook instance from an ID and token (e.g. from a stored webhook URL).
|
|
716
|
+
* @param client - The client instance
|
|
717
|
+
* @param webhookId - The webhook ID
|
|
718
|
+
* @param token - The webhook token (from createWebhook or stored)
|
|
719
|
+
* @param options - Optional channelId, guildId, name for display
|
|
720
|
+
*/
|
|
721
|
+
static fromToken(client, webhookId, token, options) {
|
|
722
|
+
return new _Webhook(client, {
|
|
723
|
+
id: webhookId,
|
|
724
|
+
guild_id: options?.guildId ?? "",
|
|
725
|
+
channel_id: options?.channelId ?? "",
|
|
726
|
+
name: options?.name ?? "Webhook",
|
|
727
|
+
avatar: null,
|
|
728
|
+
token,
|
|
729
|
+
user: { id: "", username: "webhook", discriminator: "0" }
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
// src/structures/Invite.ts
|
|
735
|
+
import { Routes as Routes4 } from "@fluxerjs/types";
|
|
736
|
+
var Invite = class extends Base {
|
|
737
|
+
client;
|
|
738
|
+
code;
|
|
739
|
+
type;
|
|
740
|
+
guild;
|
|
741
|
+
channel;
|
|
742
|
+
inviter;
|
|
743
|
+
memberCount;
|
|
744
|
+
presenceCount;
|
|
745
|
+
expiresAt;
|
|
746
|
+
temporary;
|
|
747
|
+
createdAt;
|
|
748
|
+
uses;
|
|
749
|
+
maxUses;
|
|
750
|
+
maxAge;
|
|
751
|
+
/** @param data - API invite from GET /invites/{code}, channel/guild invite list, or gateway INVITE_CREATE */
|
|
752
|
+
constructor(client, data) {
|
|
88
753
|
super();
|
|
89
754
|
this.client = client;
|
|
755
|
+
this.code = data.code;
|
|
756
|
+
this.type = data.type;
|
|
757
|
+
this.guild = data.guild;
|
|
758
|
+
this.channel = data.channel;
|
|
759
|
+
this.inviter = data.inviter ? client.getOrCreateUser(data.inviter) : null;
|
|
760
|
+
this.memberCount = data.member_count ?? null;
|
|
761
|
+
this.presenceCount = data.presence_count ?? null;
|
|
762
|
+
this.expiresAt = data.expires_at ?? null;
|
|
763
|
+
this.temporary = data.temporary ?? null;
|
|
764
|
+
this.createdAt = data.created_at ?? null;
|
|
765
|
+
this.uses = data.uses ?? null;
|
|
766
|
+
this.maxUses = data.max_uses ?? null;
|
|
767
|
+
this.maxAge = data.max_age ?? null;
|
|
768
|
+
}
|
|
769
|
+
/** Full invite URL (https://fluxer.gg/{code} or instance-specific). */
|
|
770
|
+
get url() {
|
|
771
|
+
return `https://fluxer.gg/${this.code}`;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Resolve the guild from cache if available.
|
|
775
|
+
* @returns The guild, or null if not cached
|
|
776
|
+
*/
|
|
777
|
+
getGuild() {
|
|
778
|
+
return this.guild?.id ? this.client.guilds.get(this.guild.id) ?? null : null;
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Delete this invite.
|
|
782
|
+
* Requires Manage Guild or Create Instant Invite permission.
|
|
783
|
+
*/
|
|
784
|
+
async delete() {
|
|
785
|
+
await this.client.rest.delete(Routes4.invite(this.code), { auth: true });
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
// src/structures/Channel.ts
|
|
790
|
+
var Channel = class _Channel extends Base {
|
|
791
|
+
/** Whether this channel has a send method (TextChannel, DMChannel). */
|
|
792
|
+
isSendable() {
|
|
793
|
+
return "send" in this;
|
|
794
|
+
}
|
|
795
|
+
/** Whether this channel is a DM or Group DM. */
|
|
796
|
+
isDM() {
|
|
797
|
+
return this.type === ChannelType.DM || this.type === ChannelType.GroupDM;
|
|
798
|
+
}
|
|
799
|
+
/** Whether this channel is voice-based (VoiceChannel). */
|
|
800
|
+
isVoice() {
|
|
801
|
+
return "bitrate" in this;
|
|
802
|
+
}
|
|
803
|
+
/** Create a DM channel from API data (type DM or GroupDM). */
|
|
804
|
+
static createDM(client, data) {
|
|
805
|
+
return new DMChannel(client, data);
|
|
806
|
+
}
|
|
807
|
+
client;
|
|
808
|
+
id;
|
|
809
|
+
type;
|
|
810
|
+
/** Channel name. Guild channels and Group DMs have names; 1:1 DMs are typically null. */
|
|
811
|
+
name;
|
|
812
|
+
/** Channel icon hash (Group DMs). Null if none. */
|
|
813
|
+
icon;
|
|
814
|
+
/** ISO timestamp when the last message was pinned. Null if never pinned. */
|
|
815
|
+
lastPinTimestamp;
|
|
816
|
+
/** @param data - API channel from GET /channels/{id} or GET /guilds/{id}/channels */
|
|
817
|
+
constructor(client, data) {
|
|
818
|
+
super();
|
|
819
|
+
this.client = client;
|
|
820
|
+
this.id = data.id;
|
|
821
|
+
this.type = data.type;
|
|
822
|
+
this.name = data.name ?? null;
|
|
823
|
+
this.icon = data.icon ?? null;
|
|
824
|
+
this.lastPinTimestamp = data.last_pin_timestamp ?? null;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Create the appropriate channel subclass from API data.
|
|
828
|
+
* @param client - The client instance
|
|
829
|
+
* @param data - Channel data from the API
|
|
830
|
+
*/
|
|
831
|
+
static from(client, data) {
|
|
832
|
+
const type = data.type ?? 0;
|
|
833
|
+
if (type === ChannelType.GuildText) return new TextChannel(client, data);
|
|
834
|
+
if (type === ChannelType.GuildCategory) return new CategoryChannel(client, data);
|
|
835
|
+
if (type === ChannelType.GuildVoice) return new VoiceChannel(client, data);
|
|
836
|
+
if (type === ChannelType.GuildLink || type === ChannelType.GuildLinkExtended)
|
|
837
|
+
return new LinkChannel(client, data);
|
|
838
|
+
return new GuildChannel(client, data);
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Create a channel from API data, including DM and GroupDM.
|
|
842
|
+
* Used by ChannelManager.fetch() for GET /channels/{id}.
|
|
843
|
+
*/
|
|
844
|
+
static fromOrCreate(client, data) {
|
|
845
|
+
const type = data.type ?? 0;
|
|
846
|
+
if (type === ChannelType.DM || type === ChannelType.GroupDM)
|
|
847
|
+
return _Channel.createDM(client, data);
|
|
848
|
+
return _Channel.from(client, data);
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Bulk delete messages. Requires Manage Messages permission.
|
|
852
|
+
* @param messageIds - Array of message IDs to delete (2–100)
|
|
853
|
+
*/
|
|
854
|
+
async bulkDeleteMessages(messageIds) {
|
|
855
|
+
await this.client.rest.post(Routes5.channelBulkDelete(this.id), {
|
|
856
|
+
body: { message_ids: messageIds },
|
|
857
|
+
auth: true
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Send a typing indicator to the channel. Lasts ~10 seconds.
|
|
862
|
+
*/
|
|
863
|
+
async sendTyping() {
|
|
864
|
+
await this.client.rest.post(Routes5.channelTyping(this.id), { auth: true });
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
var GuildChannel = class extends Channel {
|
|
868
|
+
guildId;
|
|
869
|
+
name;
|
|
870
|
+
position;
|
|
871
|
+
parentId;
|
|
872
|
+
/** Permission overwrites for roles and members. */
|
|
873
|
+
permissionOverwrites;
|
|
874
|
+
constructor(client, data) {
|
|
875
|
+
super(client, data);
|
|
876
|
+
this.guildId = data.guild_id ?? "";
|
|
877
|
+
this.name = data.name ?? null;
|
|
878
|
+
this.position = data.position;
|
|
879
|
+
this.parentId = data.parent_id ?? null;
|
|
880
|
+
this.permissionOverwrites = data.permission_overwrites ?? [];
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Create a webhook in this channel.
|
|
884
|
+
* @param options - Webhook name and optional avatar URL
|
|
885
|
+
* @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
|
|
886
|
+
*/
|
|
887
|
+
async createWebhook(options) {
|
|
888
|
+
const data = await this.client.rest.post(Routes5.channelWebhooks(this.id), {
|
|
889
|
+
body: options,
|
|
890
|
+
auth: true
|
|
891
|
+
});
|
|
892
|
+
return new Webhook(this.client, data);
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* Fetch all webhooks in this channel.
|
|
896
|
+
* @returns Webhooks (includes token when listing from channel; can send via send())
|
|
897
|
+
*/
|
|
898
|
+
async fetchWebhooks() {
|
|
899
|
+
const data = await this.client.rest.get(Routes5.channelWebhooks(this.id));
|
|
900
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
901
|
+
return list.map((w) => new Webhook(this.client, w));
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Create an invite for this channel.
|
|
905
|
+
* @param options - max_uses (0–100), max_age (0–604800 seconds), unique, temporary
|
|
906
|
+
* Requires Create Instant Invite permission.
|
|
907
|
+
*/
|
|
908
|
+
async createInvite(options) {
|
|
909
|
+
const body = {};
|
|
910
|
+
if (options?.max_uses != null) body.max_uses = options.max_uses;
|
|
911
|
+
if (options?.max_age != null) body.max_age = options.max_age;
|
|
912
|
+
if (options?.unique != null) body.unique = options.unique;
|
|
913
|
+
if (options?.temporary != null) body.temporary = options.temporary;
|
|
914
|
+
const data = await this.client.rest.post(Routes5.channelInvites(this.id), {
|
|
915
|
+
body: Object.keys(body).length ? body : void 0,
|
|
916
|
+
auth: true
|
|
917
|
+
});
|
|
918
|
+
return new Invite(this.client, data);
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Fetch invites for this channel.
|
|
922
|
+
* Requires Manage Channel permission.
|
|
923
|
+
*/
|
|
924
|
+
async fetchInvites() {
|
|
925
|
+
const data = await this.client.rest.get(Routes5.channelInvites(this.id));
|
|
926
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
927
|
+
return list.map((i) => new Invite(this.client, i));
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Set or update a permission overwrite. PUT /channels/{id}/permissions/{overwriteId}.
|
|
931
|
+
* @param overwriteId - Role or member ID
|
|
932
|
+
* @param options - type (0=role, 1=member), allow, deny (permission bitfields)
|
|
933
|
+
*/
|
|
934
|
+
async editPermission(overwriteId, options) {
|
|
935
|
+
await this.client.rest.put(Routes5.channelPermission(this.id, overwriteId), {
|
|
936
|
+
body: options,
|
|
937
|
+
auth: true
|
|
938
|
+
});
|
|
939
|
+
const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
|
|
940
|
+
const entry = {
|
|
941
|
+
id: overwriteId,
|
|
942
|
+
type: options.type,
|
|
943
|
+
allow: options.allow ?? "0",
|
|
944
|
+
deny: options.deny ?? "0"
|
|
945
|
+
};
|
|
946
|
+
if (idx >= 0) this.permissionOverwrites[idx] = entry;
|
|
947
|
+
else this.permissionOverwrites.push(entry);
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Remove a permission overwrite. DELETE /channels/{id}/permissions/{overwriteId}.
|
|
951
|
+
*/
|
|
952
|
+
async deletePermission(overwriteId) {
|
|
953
|
+
await this.client.rest.delete(Routes5.channelPermission(this.id, overwriteId), { auth: true });
|
|
954
|
+
const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
|
|
955
|
+
if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Edit this channel. PATCH /channels/{id}.
|
|
959
|
+
* Requires Manage Channel permission.
|
|
960
|
+
*/
|
|
961
|
+
async edit(options) {
|
|
962
|
+
const data = await this.client.rest.patch(Routes5.channel(this.id), {
|
|
963
|
+
body: options,
|
|
964
|
+
auth: true
|
|
965
|
+
});
|
|
966
|
+
this.name = data.name ?? this.name;
|
|
967
|
+
this.parentId = data.parent_id ?? this.parentId;
|
|
968
|
+
this.permissionOverwrites = data.permission_overwrites ?? this.permissionOverwrites;
|
|
969
|
+
const self = this;
|
|
970
|
+
if ("topic" in self && "topic" in data) self.topic = data.topic ?? null;
|
|
971
|
+
if ("nsfw" in self && "nsfw" in data) self.nsfw = data.nsfw ?? false;
|
|
972
|
+
if ("rate_limit_per_user" in data) self.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
973
|
+
if ("bitrate" in self && "bitrate" in data) self.bitrate = data.bitrate ?? null;
|
|
974
|
+
if ("user_limit" in data) self.userLimit = data.user_limit ?? null;
|
|
975
|
+
if ("rtc_region" in data) self.rtcRegion = data.rtc_region ?? null;
|
|
976
|
+
return this;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Delete this channel. Requires Manage Channel permission.
|
|
980
|
+
* @param options - silent: if true, does not send a system message (default false)
|
|
981
|
+
*/
|
|
982
|
+
async delete(options) {
|
|
983
|
+
const url = Routes5.channel(this.id) + (options?.silent ? "?silent=true" : "");
|
|
984
|
+
await this.client.rest.delete(url, { auth: true });
|
|
985
|
+
this.client.channels.delete(this.id);
|
|
986
|
+
const guild = this.client.guilds.get(this.guildId);
|
|
987
|
+
if (guild) guild.channels.delete(this.id);
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
var TextChannel = class extends GuildChannel {
|
|
991
|
+
topic;
|
|
992
|
+
nsfw;
|
|
993
|
+
rateLimitPerUser;
|
|
994
|
+
lastMessageId;
|
|
995
|
+
constructor(client, data) {
|
|
996
|
+
super(client, data);
|
|
997
|
+
this.topic = data.topic ?? null;
|
|
998
|
+
this.nsfw = data.nsfw ?? false;
|
|
999
|
+
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
1000
|
+
this.lastMessageId = data.last_message_id ?? null;
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Send a message to this channel.
|
|
1004
|
+
* @param options - Text content or object with content, embeds, and/or files
|
|
1005
|
+
*/
|
|
1006
|
+
async send(options) {
|
|
1007
|
+
const opts = typeof options === "string" ? { content: options } : options;
|
|
1008
|
+
const body = buildSendBody(options);
|
|
1009
|
+
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1010
|
+
const postOptions = files?.length ? { body, files } : { body };
|
|
1011
|
+
const data = await this.client.rest.post(Routes5.channelMessages(this.id), postOptions);
|
|
1012
|
+
return new Message(this.client, data);
|
|
1013
|
+
}
|
|
1014
|
+
/** Message manager for this channel. Use channel.messages.fetch(messageId). */
|
|
1015
|
+
get messages() {
|
|
1016
|
+
return new MessageManager(this.client, this.id);
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Create a message collector for this channel.
|
|
1020
|
+
* Collects messages matching the filter until time expires or max is reached.
|
|
1021
|
+
* @param options - Filter, time (ms), and max count
|
|
1022
|
+
* @example
|
|
1023
|
+
* const collector = channel.createMessageCollector({ filter: m => m.author.id === userId, time: 10000 });
|
|
1024
|
+
* collector.on('collect', m => console.log(m.content));
|
|
1025
|
+
* collector.on('end', (collected, reason) => { ... });
|
|
1026
|
+
*/
|
|
1027
|
+
createMessageCollector(options) {
|
|
1028
|
+
return new MessageCollector(this.client, this.id, options);
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Fetch pinned messages in this channel.
|
|
1032
|
+
* @returns Pinned messages
|
|
1033
|
+
*/
|
|
1034
|
+
async fetchPinnedMessages() {
|
|
1035
|
+
const data = await this.client.rest.get(Routes5.channelPins(this.id));
|
|
1036
|
+
const list = Array.isArray(data) ? data : data?.items ?? [];
|
|
1037
|
+
return list.map((item) => {
|
|
1038
|
+
const msg = typeof item === "object" && item && "message" in item ? item.message : item;
|
|
1039
|
+
return new Message(this.client, msg);
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Fetch a message by ID from this channel.
|
|
1044
|
+
* @param messageId - Snowflake of the message
|
|
1045
|
+
* @returns The message, or null if not found
|
|
1046
|
+
* @deprecated Use channel.messages.fetch(messageId) instead.
|
|
1047
|
+
*/
|
|
1048
|
+
async fetchMessage(messageId) {
|
|
1049
|
+
emitDeprecationWarning(
|
|
1050
|
+
"Channel.fetchMessage()",
|
|
1051
|
+
"Use channel.messages.fetch(messageId) instead."
|
|
1052
|
+
);
|
|
1053
|
+
return this.client.channels.fetchMessage(this.id, messageId);
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
var CategoryChannel = class extends GuildChannel {
|
|
1057
|
+
};
|
|
1058
|
+
var VoiceChannel = class extends GuildChannel {
|
|
1059
|
+
bitrate;
|
|
1060
|
+
userLimit;
|
|
1061
|
+
rtcRegion;
|
|
1062
|
+
constructor(client, data) {
|
|
1063
|
+
super(client, data);
|
|
1064
|
+
this.bitrate = data.bitrate ?? null;
|
|
1065
|
+
this.userLimit = data.user_limit ?? null;
|
|
1066
|
+
this.rtcRegion = data.rtc_region ?? null;
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
var LinkChannel = class extends GuildChannel {
|
|
1070
|
+
url;
|
|
1071
|
+
constructor(client, data) {
|
|
1072
|
+
super(client, data);
|
|
1073
|
+
this.url = data.url ?? null;
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
var DMChannel = class extends Channel {
|
|
1077
|
+
lastMessageId;
|
|
1078
|
+
/** Group DM creator ID. Null for 1:1 DMs. */
|
|
1079
|
+
ownerId;
|
|
1080
|
+
/** Group DM recipients as User objects. Empty for 1:1 DMs. */
|
|
1081
|
+
recipients;
|
|
1082
|
+
/** Group DM member display names (userId -> nickname). */
|
|
1083
|
+
nicks;
|
|
1084
|
+
constructor(client, data) {
|
|
1085
|
+
super(client, data);
|
|
1086
|
+
this.lastMessageId = data.last_message_id ?? null;
|
|
1087
|
+
this.ownerId = data.owner_id ?? null;
|
|
1088
|
+
this.recipients = (data.recipients ?? []).map(
|
|
1089
|
+
(u) => client.getOrCreateUser(u)
|
|
1090
|
+
);
|
|
1091
|
+
this.nicks = data.nicks ?? {};
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Send a message to this DM channel.
|
|
1095
|
+
* @param options - Text content or object with content, embeds, and/or files
|
|
1096
|
+
*/
|
|
1097
|
+
async send(options) {
|
|
1098
|
+
const opts = typeof options === "string" ? { content: options } : options;
|
|
1099
|
+
const body = buildSendBody(options);
|
|
1100
|
+
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1101
|
+
const postOptions = files?.length ? { body, files } : { body };
|
|
1102
|
+
const data = await this.client.rest.post(Routes5.channelMessages(this.id), postOptions);
|
|
1103
|
+
return new Message(this.client, data);
|
|
1104
|
+
}
|
|
1105
|
+
/** Message manager for this channel. Use channel.messages.fetch(messageId). */
|
|
1106
|
+
get messages() {
|
|
1107
|
+
return new MessageManager(this.client, this.id);
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Create a message collector for this DM channel.
|
|
1111
|
+
* @param options - Filter, time (ms), and max count
|
|
1112
|
+
*/
|
|
1113
|
+
createMessageCollector(options) {
|
|
1114
|
+
return new MessageCollector(this.client, this.id, options);
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Fetch pinned messages in this DM channel.
|
|
1118
|
+
* @returns Pinned messages
|
|
1119
|
+
*/
|
|
1120
|
+
async fetchPinnedMessages() {
|
|
1121
|
+
const data = await this.client.rest.get(Routes5.channelPins(this.id));
|
|
1122
|
+
const list = Array.isArray(data) ? data : data?.items ?? [];
|
|
1123
|
+
return list.map((item) => {
|
|
1124
|
+
const msg = typeof item === "object" && item && "message" in item ? item.message : item;
|
|
1125
|
+
return new Message(this.client, msg);
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* Fetch a message by ID from this DM channel.
|
|
1130
|
+
* @param messageId - Snowflake of the message
|
|
1131
|
+
* @returns The message, or null if not found
|
|
1132
|
+
* @deprecated Use channel.messages.fetch(messageId) instead.
|
|
1133
|
+
*/
|
|
1134
|
+
async fetchMessage(messageId) {
|
|
1135
|
+
emitDeprecationWarning(
|
|
1136
|
+
"Channel.fetchMessage()",
|
|
1137
|
+
"Use channel.messages.fetch(messageId) instead."
|
|
1138
|
+
);
|
|
1139
|
+
return this.client.channels.fetchMessage(this.id, messageId);
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Add a recipient to this Group DM. Requires Group DM (type GroupDM).
|
|
1143
|
+
* PUT /channels/{id}/recipients/{userId}.
|
|
1144
|
+
*/
|
|
1145
|
+
async addRecipient(userId) {
|
|
1146
|
+
await this.client.rest.put(Routes5.channelRecipient(this.id, userId), { auth: true });
|
|
1147
|
+
const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
|
|
1148
|
+
if (user) this.recipients.push(user);
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Remove a recipient from this Group DM. Requires Group DM (type GroupDM).
|
|
1152
|
+
* DELETE /channels/{id}/recipients/{userId}.
|
|
1153
|
+
* @param options - silent: if true, does not send a system message (default false)
|
|
1154
|
+
*/
|
|
1155
|
+
async removeRecipient(userId, options) {
|
|
1156
|
+
const url = Routes5.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
|
|
1157
|
+
await this.client.rest.delete(url, { auth: true });
|
|
1158
|
+
const idx = this.recipients.findIndex((u) => u.id === userId);
|
|
1159
|
+
if (idx >= 0) this.recipients.splice(idx, 1);
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
// src/client/ChannelManager.ts
|
|
1164
|
+
var ChannelManager = class extends Collection4 {
|
|
1165
|
+
constructor(client) {
|
|
1166
|
+
super();
|
|
1167
|
+
this.client = client;
|
|
1168
|
+
this.maxSize = client.options?.cache?.channels ?? 0;
|
|
1169
|
+
}
|
|
1170
|
+
maxSize;
|
|
1171
|
+
set(key, value) {
|
|
1172
|
+
if (this.maxSize > 0 && this.size >= this.maxSize && !this.has(key)) {
|
|
1173
|
+
const firstKey = this.keys().next().value;
|
|
1174
|
+
if (firstKey !== void 0) this.delete(firstKey);
|
|
1175
|
+
}
|
|
1176
|
+
return super.set(key, value);
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Get a channel from cache or fetch from the API if not present.
|
|
1180
|
+
* Convenience helper to avoid repeating `client.channels.get(id) ?? (await client.channels.fetch(id))`.
|
|
1181
|
+
* @param channelId - Snowflake of the channel
|
|
1182
|
+
* @returns The channel
|
|
1183
|
+
* @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
|
|
1184
|
+
* @example
|
|
1185
|
+
* const channel = await client.channels.resolve(message.channelId);
|
|
1186
|
+
* if (channel?.isSendable()) await channel.send('Hello!');
|
|
1187
|
+
*/
|
|
1188
|
+
async resolve(channelId) {
|
|
1189
|
+
return this.get(channelId) ?? this.fetch(channelId);
|
|
1190
|
+
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Fetch a channel by ID from the API (or return from cache if present).
|
|
1193
|
+
* @param channelId - Snowflake of the channel
|
|
1194
|
+
* @returns The channel
|
|
1195
|
+
* @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
|
|
1196
|
+
* @example
|
|
1197
|
+
* const channel = await client.channels.fetch(channelId);
|
|
1198
|
+
* if (channel?.isSendable()) await channel.send('Hello!');
|
|
1199
|
+
*/
|
|
1200
|
+
async fetch(channelId) {
|
|
1201
|
+
const cached = this.get(channelId);
|
|
1202
|
+
if (cached) return cached;
|
|
1203
|
+
try {
|
|
1204
|
+
const data = await this.client.rest.get(Routes6.channel(channelId));
|
|
1205
|
+
const channel = Channel.fromOrCreate(this.client, data);
|
|
1206
|
+
if (!channel) {
|
|
1207
|
+
throw new FluxerError("Channel data invalid or unsupported type", {
|
|
1208
|
+
code: ErrorCodes.ChannelNotFound
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
this.set(channel.id, channel);
|
|
1212
|
+
if ("guildId" in channel) {
|
|
1213
|
+
const guild = this.client.guilds.get(channel.guildId);
|
|
1214
|
+
if (guild) guild.channels.set(channel.id, channel);
|
|
1215
|
+
}
|
|
1216
|
+
return channel;
|
|
1217
|
+
} catch (err) {
|
|
1218
|
+
if (err instanceof RateLimitError2) throw err;
|
|
1219
|
+
if (err instanceof FluxerAPIError2 && err.statusCode === 404) {
|
|
1220
|
+
throw new FluxerError(`Channel ${channelId} not found`, {
|
|
1221
|
+
code: ErrorCodes.ChannelNotFound,
|
|
1222
|
+
cause: err
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Fetch a message by ID from the API.
|
|
1230
|
+
* @param channelId - Snowflake of the channel
|
|
1231
|
+
* @param messageId - Snowflake of the message
|
|
1232
|
+
* @returns The message
|
|
1233
|
+
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
1234
|
+
* @deprecated Use channel.messages.fetch(messageId). Prefer (await client.channels.resolve(channelId))?.messages?.fetch(messageId).
|
|
1235
|
+
* @example
|
|
1236
|
+
* const channel = await client.channels.resolve(channelId);
|
|
1237
|
+
* const message = await channel?.messages?.fetch(messageId);
|
|
1238
|
+
*/
|
|
1239
|
+
async fetchMessage(channelId, messageId) {
|
|
1240
|
+
emitDeprecationWarning2(
|
|
1241
|
+
"ChannelManager.fetchMessage()",
|
|
1242
|
+
"Use channel.messages.fetch(messageId). Prefer (await client.channels.resolve(channelId))?.messages?.fetch(messageId)."
|
|
1243
|
+
);
|
|
1244
|
+
try {
|
|
1245
|
+
const data = await this.client.rest.get(
|
|
1246
|
+
Routes6.channelMessage(channelId, messageId)
|
|
1247
|
+
);
|
|
1248
|
+
return new Message(this.client, data);
|
|
1249
|
+
} catch (err) {
|
|
1250
|
+
if (err instanceof RateLimitError2) throw err;
|
|
1251
|
+
if (err instanceof FluxerAPIError2 && err.statusCode === 404) {
|
|
1252
|
+
throw new FluxerError(`Message ${messageId} not found in channel ${channelId}`, {
|
|
1253
|
+
code: ErrorCodes.MessageNotFound,
|
|
1254
|
+
cause: err
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Send a message to a channel by ID. Works even when the channel is not cached.
|
|
1262
|
+
* Skips the fetch when you only need to send.
|
|
1263
|
+
* @param channelId - Snowflake of the channel (text channel or DM)
|
|
1264
|
+
* @param payload - Text content or object with content, embeds, and/or files
|
|
1265
|
+
* @returns The created message
|
|
1266
|
+
* @example
|
|
1267
|
+
* await client.channels.send(logChannelId, 'User joined!');
|
|
1268
|
+
* await client.channels.send(channelId, { embeds: [embed] });
|
|
1269
|
+
* await client.channels.send(channelId, { content: 'Report', files: [{ name: 'log.txt', data }] });
|
|
1270
|
+
*/
|
|
1271
|
+
async send(channelId, payload) {
|
|
1272
|
+
const opts = typeof payload === "string" ? { content: payload } : payload;
|
|
1273
|
+
const body = buildSendBody(payload);
|
|
1274
|
+
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1275
|
+
const postOptions = files?.length ? { body, files } : { body };
|
|
1276
|
+
const data = await this.client.rest.post(Routes6.channelMessages(channelId), postOptions);
|
|
1277
|
+
return new Message(this.client, data);
|
|
1278
|
+
}
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
// src/client/GuildManager.ts
|
|
1282
|
+
import { Collection as Collection8 } from "@fluxerjs/collection";
|
|
1283
|
+
import { Routes as Routes15 } from "@fluxerjs/types";
|
|
1284
|
+
|
|
1285
|
+
// src/structures/Guild.ts
|
|
1286
|
+
import {
|
|
1287
|
+
parseRoleMention,
|
|
1288
|
+
resolvePermissionsToBitfield as resolvePermissionsToBitfield2
|
|
1289
|
+
} from "@fluxerjs/util";
|
|
1290
|
+
import { FluxerAPIError as FluxerAPIError3 } from "@fluxerjs/rest";
|
|
1291
|
+
import { Collection as Collection7 } from "@fluxerjs/collection";
|
|
1292
|
+
|
|
1293
|
+
// src/client/GuildMemberManager.ts
|
|
1294
|
+
import { Collection as Collection6 } from "@fluxerjs/collection";
|
|
1295
|
+
import { Routes as Routes9 } from "@fluxerjs/types";
|
|
1296
|
+
|
|
1297
|
+
// src/structures/GuildMember.ts
|
|
1298
|
+
import { PermissionFlagsMap } from "@fluxerjs/util";
|
|
1299
|
+
import { Routes as Routes8 } from "@fluxerjs/types";
|
|
1300
|
+
|
|
1301
|
+
// src/util/permissions.ts
|
|
1302
|
+
import { OverwriteType } from "@fluxerjs/types";
|
|
1303
|
+
import { ALL_PERMISSIONS_BIGINT } from "@fluxerjs/util";
|
|
1304
|
+
function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
|
|
1305
|
+
if (isOwner) return ALL_PERMISSIONS_BIGINT;
|
|
1306
|
+
let perms = basePermissions;
|
|
1307
|
+
for (const overwrite of overwrites ?? []) {
|
|
1308
|
+
const applies = overwrite.type === OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === OverwriteType.Member && overwrite.id === memberId;
|
|
1309
|
+
if (!applies) continue;
|
|
1310
|
+
const allow = BigInt(overwrite.allow || "0");
|
|
1311
|
+
const deny = BigInt(overwrite.deny || "0");
|
|
1312
|
+
perms = perms & ~deny | allow;
|
|
1313
|
+
}
|
|
1314
|
+
return perms;
|
|
1315
|
+
}
|
|
1316
|
+
function hasPermission(bitfield, permission) {
|
|
1317
|
+
const Administrator = 1n << 3n;
|
|
1318
|
+
if ((bitfield & Administrator) !== 0n) return true;
|
|
1319
|
+
return (bitfield & permission) === permission;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
// src/structures/GuildMemberRoleManager.ts
|
|
1323
|
+
import { Collection as Collection5 } from "@fluxerjs/collection";
|
|
1324
|
+
import { Routes as Routes7 } from "@fluxerjs/types";
|
|
1325
|
+
var GuildMemberRoleManager = class {
|
|
1326
|
+
constructor(member, initialRoleIds = []) {
|
|
1327
|
+
this.member = member;
|
|
1328
|
+
this._roleIds = [...initialRoleIds];
|
|
1329
|
+
}
|
|
1330
|
+
_roleIds = [];
|
|
1331
|
+
/** Role IDs for this member. Used by permissions; prefer cache for Role objects. */
|
|
1332
|
+
get roleIds() {
|
|
1333
|
+
return this._roleIds;
|
|
1334
|
+
}
|
|
1335
|
+
/** Check if the member has a role. Discord.js parity: member.roles.cache.has(roleId) */
|
|
1336
|
+
has(roleOrId) {
|
|
1337
|
+
return this._roleIds.includes(this._resolveId(roleOrId));
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* Collection of Role objects for this member's roles (from guild.roles).
|
|
1341
|
+
* Discord.js parity: member.roles.cache
|
|
1342
|
+
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
1343
|
+
*/
|
|
1344
|
+
get cache() {
|
|
1345
|
+
const coll = new Collection5();
|
|
1346
|
+
for (const id of this._roleIds) {
|
|
1347
|
+
const role = this.member.guild.roles.get(id);
|
|
1348
|
+
if (role) coll.set(id, role);
|
|
1349
|
+
}
|
|
1350
|
+
return coll;
|
|
1351
|
+
}
|
|
1352
|
+
/** Resolve role ID from RoleResolvable. */
|
|
1353
|
+
_resolveId(roleOrId) {
|
|
1354
|
+
return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Add a role to this member.
|
|
1358
|
+
* Discord.js parity: member.roles.add(roleId)
|
|
1359
|
+
* Requires Manage Roles permission.
|
|
1360
|
+
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
1361
|
+
*/
|
|
1362
|
+
async add(roleOrId) {
|
|
1363
|
+
const roleId = this._resolveId(roleOrId);
|
|
1364
|
+
if (this._roleIds.includes(roleId)) return;
|
|
1365
|
+
await this.member.client.rest.put(
|
|
1366
|
+
Routes7.guildMemberRole(this.member.guild.id, this.member.id, roleId)
|
|
1367
|
+
);
|
|
1368
|
+
this._roleIds.push(roleId);
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Remove a role from this member.
|
|
1372
|
+
* Discord.js parity: member.roles.remove(roleId)
|
|
1373
|
+
* Requires Manage Roles permission.
|
|
1374
|
+
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
1375
|
+
*/
|
|
1376
|
+
async remove(roleOrId) {
|
|
1377
|
+
const roleId = this._resolveId(roleOrId);
|
|
1378
|
+
const idx = this._roleIds.indexOf(roleId);
|
|
1379
|
+
if (idx === -1) return;
|
|
1380
|
+
await this.member.client.rest.delete(
|
|
1381
|
+
Routes7.guildMemberRole(this.member.guild.id, this.member.id, roleId)
|
|
1382
|
+
);
|
|
1383
|
+
this._roleIds.splice(idx, 1);
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Replace all roles for this member. PATCH /guilds/{id}/members/{userId}
|
|
1387
|
+
* Discord.js parity: member.roles.set(roleIds)
|
|
1388
|
+
* Requires Manage Roles permission.
|
|
1389
|
+
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
1390
|
+
*/
|
|
1391
|
+
async set(roleIds) {
|
|
1392
|
+
const data = await this.member.client.rest.patch(
|
|
1393
|
+
Routes7.guildMember(this.member.guild.id, this.member.id),
|
|
1394
|
+
{ body: { roles: roleIds }, auth: true }
|
|
1395
|
+
);
|
|
1396
|
+
this._roleIds = data.roles ? [...data.roles] : [];
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Update internal role IDs from API response. Called by GuildMember.edit().
|
|
1400
|
+
* @internal
|
|
1401
|
+
*/
|
|
1402
|
+
_patch(roleIds) {
|
|
1403
|
+
this._roleIds = [...roleIds];
|
|
1404
|
+
}
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
// src/structures/GuildMember.ts
|
|
1408
|
+
var GuildMember = class extends Base {
|
|
1409
|
+
client;
|
|
1410
|
+
id;
|
|
1411
|
+
user;
|
|
1412
|
+
guild;
|
|
1413
|
+
nick;
|
|
1414
|
+
/**
|
|
1415
|
+
* Role manager with add/remove/set and cache. Discord.js parity: member.roles.add(), member.roles.cache
|
|
1416
|
+
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
1417
|
+
*/
|
|
1418
|
+
roles;
|
|
1419
|
+
joinedAt;
|
|
1420
|
+
communicationDisabledUntil;
|
|
1421
|
+
mute;
|
|
1422
|
+
deaf;
|
|
1423
|
+
avatar;
|
|
1424
|
+
banner;
|
|
1425
|
+
accentColor;
|
|
1426
|
+
profileFlags;
|
|
1427
|
+
/** @param data - API guild member from GET /guilds/{id}/members or GET /guilds/{id}/members/{user_id} */
|
|
1428
|
+
constructor(client, data, guild) {
|
|
1429
|
+
super();
|
|
1430
|
+
this.client = client;
|
|
1431
|
+
this.user = client.getOrCreateUser(data.user);
|
|
1432
|
+
this.id = data.user.id;
|
|
1433
|
+
this.guild = guild;
|
|
1434
|
+
this.nick = data.nick ?? null;
|
|
1435
|
+
this.roles = new GuildMemberRoleManager(this, data.roles ?? []);
|
|
1436
|
+
this.joinedAt = new Date(data.joined_at);
|
|
1437
|
+
this.communicationDisabledUntil = data.communication_disabled_until ? new Date(data.communication_disabled_until) : null;
|
|
1438
|
+
this.mute = data.mute ?? false;
|
|
1439
|
+
this.deaf = data.deaf ?? false;
|
|
1440
|
+
this.avatar = data.avatar ?? null;
|
|
1441
|
+
this.banner = data.banner ?? null;
|
|
1442
|
+
this.accentColor = data.accent_color ?? null;
|
|
1443
|
+
this.profileFlags = data.profile_flags ?? null;
|
|
1444
|
+
}
|
|
1445
|
+
/** Nickname, or global name, or username. */
|
|
1446
|
+
get displayName() {
|
|
1447
|
+
return this.nick ?? this.user.globalName ?? this.user.username;
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* Get the guild-specific avatar URL for this member.
|
|
1451
|
+
* Returns null if the member has no guild avatar (use displayAvatarURL for fallback).
|
|
1452
|
+
*/
|
|
1453
|
+
avatarURL(options) {
|
|
1454
|
+
return cdnMemberAvatarURL(this.guild.id, this.id, this.avatar, options);
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* Get the avatar URL to display for this member.
|
|
1458
|
+
* Uses guild-specific avatar if set, otherwise falls back to the user's avatar.
|
|
1459
|
+
*/
|
|
1460
|
+
displayAvatarURL(options) {
|
|
1461
|
+
return this.avatarURL(options) ?? this.user.displayAvatarURL(options);
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* Get the guild-specific banner URL for this member.
|
|
1465
|
+
* Returns null if the member has no guild banner.
|
|
1466
|
+
*/
|
|
1467
|
+
bannerURL(options) {
|
|
1468
|
+
return cdnMemberBannerURL(this.guild.id, this.id, this.banner, options);
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Add a role to this member.
|
|
1472
|
+
* Prefer member.roles.add(roleId) for Discord.js parity.
|
|
1473
|
+
* @param roleId - The role ID to add
|
|
1474
|
+
* Requires Manage Roles permission.
|
|
1475
|
+
*/
|
|
1476
|
+
async addRole(roleId) {
|
|
1477
|
+
await this.roles.add(roleId);
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Remove a role from this member.
|
|
1481
|
+
* Prefer member.roles.remove(roleId) for Discord.js parity.
|
|
1482
|
+
* @param roleId - The role ID to remove
|
|
1483
|
+
* Requires Manage Roles permission.
|
|
1484
|
+
*/
|
|
1485
|
+
async removeRole(roleId) {
|
|
1486
|
+
await this.roles.remove(roleId);
|
|
1487
|
+
}
|
|
1488
|
+
/**
|
|
1489
|
+
* Edit this guild member. PATCH /guilds/{id}/members/{userId} or /members/@me for the bot.
|
|
1490
|
+
* For @me: nick, avatar, banner, bio, pronouns, accent_color, profile_flags, mute, deaf,
|
|
1491
|
+
* communication_disabled_until, timeout_reason, channel_id, connection_id.
|
|
1492
|
+
* For other members: same plus roles (array of role IDs).
|
|
1493
|
+
*/
|
|
1494
|
+
async edit(options) {
|
|
1495
|
+
const isMe = this.client.user?.id === this.id;
|
|
1496
|
+
const route = isMe ? `/guilds/${this.guild.id}/members/@me` : Routes8.guildMember(this.guild.id, this.id);
|
|
1497
|
+
const data = await this.client.rest.patch(route, {
|
|
1498
|
+
body: options,
|
|
1499
|
+
auth: true
|
|
1500
|
+
});
|
|
1501
|
+
this.nick = data.nick ?? this.nick;
|
|
1502
|
+
if (data.roles) this.roles._patch(data.roles);
|
|
1503
|
+
if (data.communication_disabled_until != null) {
|
|
1504
|
+
this.communicationDisabledUntil = data.communication_disabled_until ? new Date(data.communication_disabled_until) : null;
|
|
1505
|
+
}
|
|
1506
|
+
return this;
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Get the member's guild-level permissions (from roles only, no channel overwrites).
|
|
1510
|
+
* Use this for server-wide permission checks (e.g. ban, kick, manage roles).
|
|
1511
|
+
* @returns Object with has(permission) to check specific permissions
|
|
1512
|
+
* @example
|
|
1513
|
+
* const perms = member.permissions;
|
|
1514
|
+
* if (perms.has(PermissionFlags.BanMembers)) { ... }
|
|
1515
|
+
*/
|
|
1516
|
+
get permissions() {
|
|
1517
|
+
const base = this._computeBasePermissions();
|
|
1518
|
+
const ownerId = this.guild.ownerId;
|
|
1519
|
+
const isOwner = ownerId != null && ownerId !== "" && String(ownerId) === String(this.id);
|
|
1520
|
+
const perms = computePermissions(base, [], [], this.id, isOwner);
|
|
1521
|
+
return {
|
|
1522
|
+
has(permission) {
|
|
1523
|
+
const perm = typeof permission === "number" ? permission : PermissionFlagsMap[String(permission)];
|
|
1524
|
+
if (perm === void 0) return false;
|
|
1525
|
+
return hasPermission(perms, BigInt(perm));
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
/**
|
|
1530
|
+
* Compute the member's effective permissions in a guild channel.
|
|
1531
|
+
* Applies role permissions and channel overwrites.
|
|
1532
|
+
* @param channel - The guild channel to check permissions for
|
|
1533
|
+
* @returns Object with has(permission) to check specific permissions
|
|
1534
|
+
* @example
|
|
1535
|
+
* const perms = member.permissionsIn(channel);
|
|
1536
|
+
* if (perms.has(PermissionFlags.SendMessages)) { ... }
|
|
1537
|
+
*/
|
|
1538
|
+
permissionsIn(channel) {
|
|
1539
|
+
const base = this._computeBasePermissions();
|
|
1540
|
+
const ownerId = this.guild.ownerId;
|
|
1541
|
+
const isOwner = ownerId != null && ownerId !== "" && String(ownerId) === String(this.id);
|
|
1542
|
+
const perms = computePermissions(
|
|
1543
|
+
base,
|
|
1544
|
+
channel.permissionOverwrites,
|
|
1545
|
+
[...this.roles.roleIds],
|
|
1546
|
+
this.id,
|
|
1547
|
+
isOwner
|
|
1548
|
+
);
|
|
1549
|
+
return {
|
|
1550
|
+
has(permission) {
|
|
1551
|
+
const perm = typeof permission === "number" ? permission : PermissionFlagsMap[String(permission)];
|
|
1552
|
+
if (perm === void 0) return false;
|
|
1553
|
+
return hasPermission(perms, BigInt(perm));
|
|
1554
|
+
}
|
|
1555
|
+
};
|
|
1556
|
+
}
|
|
1557
|
+
_computeBasePermissions() {
|
|
1558
|
+
let base = 0n;
|
|
1559
|
+
const everyone = this.guild.roles.get(this.guild.id);
|
|
1560
|
+
if (everyone) base |= BigInt(everyone.permissions);
|
|
1561
|
+
for (const roleId of this.roles.roleIds) {
|
|
1562
|
+
if (roleId === this.guild.id) continue;
|
|
1563
|
+
const role = this.guild.roles.get(roleId);
|
|
1564
|
+
if (role) base |= BigInt(role.permissions);
|
|
1565
|
+
}
|
|
1566
|
+
return base;
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
|
|
1570
|
+
// src/client/GuildMemberManager.ts
|
|
1571
|
+
var GuildMemberManager = class extends Collection6 {
|
|
1572
|
+
constructor(guild) {
|
|
1573
|
+
super();
|
|
1574
|
+
this.guild = guild;
|
|
1575
|
+
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Get a guild member from cache or fetch from the API if not present.
|
|
1578
|
+
* Convenience helper to avoid repeating `guild.members.get(userId) ?? (await guild.fetchMember(userId))`.
|
|
1579
|
+
* @param userId - Snowflake of the user
|
|
1580
|
+
* @returns The guild member
|
|
1581
|
+
* @throws FluxerError with MEMBER_NOT_FOUND if user is not in the guild (404)
|
|
1582
|
+
* @example
|
|
1583
|
+
* const member = await guild.members.resolve(userId);
|
|
1584
|
+
* console.log(member.displayName);
|
|
1585
|
+
*/
|
|
1586
|
+
async resolve(userId) {
|
|
1587
|
+
return this.get(userId) ?? this.guild.fetchMember(userId);
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* The current bot user as a GuildMember in this guild.
|
|
1591
|
+
* Returns null if the bot's member is not cached or client.user is null.
|
|
1592
|
+
* Use fetchMe() to load the bot's member when not cached.
|
|
1593
|
+
*
|
|
1594
|
+
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberManager
|
|
1595
|
+
* @example
|
|
1596
|
+
* const perms = guild.members.me?.permissions;
|
|
1597
|
+
* if (perms?.has(PermissionFlags.BanMembers)) { ... }
|
|
1598
|
+
*/
|
|
1599
|
+
get me() {
|
|
1600
|
+
const userId = this.guild.client.user?.id;
|
|
1601
|
+
return userId ? this.get(userId) ?? null : null;
|
|
1602
|
+
}
|
|
1603
|
+
/**
|
|
1604
|
+
* Fetch the current bot user as a GuildMember in this guild.
|
|
1605
|
+
* Caches the result in guild.members.
|
|
1606
|
+
*
|
|
1607
|
+
* @throws Error if client.user is null (client not ready)
|
|
1608
|
+
* @example
|
|
1609
|
+
* const me = await guild.members.fetchMe();
|
|
1610
|
+
* console.log(me.displayName);
|
|
1611
|
+
*/
|
|
1612
|
+
async fetchMe() {
|
|
1613
|
+
const userId = this.guild.client.user?.id;
|
|
1614
|
+
if (!userId) {
|
|
1615
|
+
throw new Error("Cannot fetch me: client.user is null (client not ready)");
|
|
1616
|
+
}
|
|
1617
|
+
return this.guild.fetchMember(userId);
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Fetch guild members with pagination. GET /guilds/{id}/members.
|
|
1621
|
+
* @param options - limit (1-1000), after (user ID for pagination)
|
|
1622
|
+
* @returns Array of GuildMember objects (cached in guild.members)
|
|
1623
|
+
*/
|
|
1624
|
+
async fetch(options) {
|
|
1625
|
+
const params = new URLSearchParams();
|
|
1626
|
+
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
1627
|
+
if (options?.after) params.set("after", options.after);
|
|
1628
|
+
const qs = params.toString();
|
|
1629
|
+
const url = Routes9.guildMembers(this.guild.id) + (qs ? `?${qs}` : "");
|
|
1630
|
+
const data = await this.guild.client.rest.get(url, { auth: true });
|
|
1631
|
+
const list = Array.isArray(data) ? data : data?.members ?? [];
|
|
1632
|
+
const members = [];
|
|
1633
|
+
for (const m of list) {
|
|
1634
|
+
const member = new GuildMember(
|
|
1635
|
+
this.guild.client,
|
|
1636
|
+
{ ...m, guild_id: this.guild.id },
|
|
1637
|
+
this.guild
|
|
1638
|
+
);
|
|
1639
|
+
this.set(member.id, member);
|
|
1640
|
+
members.push(member);
|
|
1641
|
+
}
|
|
1642
|
+
return members;
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
|
|
1646
|
+
// src/structures/Role.ts
|
|
1647
|
+
import { Routes as Routes10 } from "@fluxerjs/types";
|
|
1648
|
+
import {
|
|
1649
|
+
PermissionFlags,
|
|
1650
|
+
resolvePermissionsToBitfield
|
|
1651
|
+
} from "@fluxerjs/util";
|
|
1652
|
+
var Role = class extends Base {
|
|
1653
|
+
client;
|
|
1654
|
+
id;
|
|
1655
|
+
guildId;
|
|
1656
|
+
name;
|
|
1657
|
+
color;
|
|
1658
|
+
position;
|
|
1659
|
+
permissions;
|
|
1660
|
+
hoist;
|
|
1661
|
+
mentionable;
|
|
1662
|
+
unicodeEmoji;
|
|
1663
|
+
/** Separately sorted position for hoisted roles. Null if not set. */
|
|
1664
|
+
hoistPosition;
|
|
1665
|
+
/** @param client - The client instance */
|
|
1666
|
+
/** @param data - API role from GET /guilds/{id}/roles or gateway role events */
|
|
1667
|
+
/** @param guildId - The guild this role belongs to */
|
|
1668
|
+
constructor(client, data, guildId) {
|
|
1669
|
+
super();
|
|
1670
|
+
this.client = client;
|
|
1671
|
+
this.id = data.id;
|
|
1672
|
+
this.guildId = guildId;
|
|
1673
|
+
this.name = data.name;
|
|
1674
|
+
this.color = data.color;
|
|
1675
|
+
this.position = data.position;
|
|
1676
|
+
this.permissions = data.permissions;
|
|
1677
|
+
this.hoist = !!data.hoist;
|
|
1678
|
+
this.mentionable = !!data.mentionable;
|
|
1679
|
+
this.unicodeEmoji = data.unicode_emoji ?? null;
|
|
1680
|
+
this.hoistPosition = data.hoist_position ?? null;
|
|
1681
|
+
}
|
|
1682
|
+
/** Update mutable fields from fresh API data. Used by edit and gateway events. */
|
|
1683
|
+
_patch(data) {
|
|
1684
|
+
if (data.name !== void 0) this.name = data.name;
|
|
1685
|
+
if (data.color !== void 0) this.color = data.color;
|
|
1686
|
+
if (data.position !== void 0) this.position = data.position;
|
|
1687
|
+
if (data.permissions !== void 0) this.permissions = data.permissions;
|
|
1688
|
+
if (data.hoist !== void 0) this.hoist = !!data.hoist;
|
|
1689
|
+
if (data.mentionable !== void 0) this.mentionable = !!data.mentionable;
|
|
1690
|
+
if (data.unicode_emoji !== void 0) this.unicodeEmoji = data.unicode_emoji ?? null;
|
|
1691
|
+
if (data.hoist_position !== void 0) this.hoistPosition = data.hoist_position ?? null;
|
|
1692
|
+
}
|
|
1693
|
+
/** Returns a mention string (e.g. `<@&123456>`). */
|
|
1694
|
+
toString() {
|
|
1695
|
+
return `<@&${this.id}>`;
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Check if this role has a permission. Administrator grants all permissions.
|
|
1699
|
+
* @param permission - Permission flag, name, or resolvable
|
|
1700
|
+
* @returns true if the role has the permission
|
|
1701
|
+
* @example
|
|
1702
|
+
* if (role.has(PermissionFlags.BanMembers)) { ... }
|
|
1703
|
+
* if (role.has('ManageChannels')) { ... }
|
|
1704
|
+
*/
|
|
1705
|
+
has(permission) {
|
|
1706
|
+
const perm = typeof permission === "number" ? permission : PermissionFlags[permission];
|
|
1707
|
+
if (perm === void 0) return false;
|
|
1708
|
+
const permNum = Number(perm);
|
|
1709
|
+
const rolePerms = BigInt(this.permissions);
|
|
1710
|
+
const permBig = BigInt(permNum);
|
|
1711
|
+
if (permBig < 0) return false;
|
|
1712
|
+
if ((rolePerms & BigInt(PermissionFlags.Administrator)) !== 0n) return true;
|
|
1713
|
+
return (rolePerms & permBig) === permBig;
|
|
1714
|
+
}
|
|
1715
|
+
/**
|
|
1716
|
+
* Edit this role.
|
|
1717
|
+
* Requires Manage Roles permission.
|
|
1718
|
+
* @param options - Role updates (permissions accepts PermissionResolvable for convenience)
|
|
1719
|
+
* @returns This role (updated in place)
|
|
1720
|
+
* @example
|
|
1721
|
+
* await role.edit({ name: 'Moderator', permissions: ['BanMembers', 'KickMembers'] });
|
|
1722
|
+
*/
|
|
1723
|
+
async edit(options) {
|
|
1724
|
+
const body = {};
|
|
1725
|
+
if (options.name !== void 0) body.name = options.name;
|
|
1726
|
+
if (options.permissions !== void 0) {
|
|
1727
|
+
body.permissions = typeof options.permissions === "string" ? options.permissions : resolvePermissionsToBitfield(options.permissions);
|
|
1728
|
+
}
|
|
1729
|
+
if (options.color !== void 0) body.color = options.color;
|
|
1730
|
+
if (options.hoist !== void 0) body.hoist = options.hoist;
|
|
1731
|
+
if (options.mentionable !== void 0) body.mentionable = options.mentionable;
|
|
1732
|
+
if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
|
|
1733
|
+
if (options.position !== void 0) body.position = options.position;
|
|
1734
|
+
if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
|
|
1735
|
+
const data = await this.client.rest.patch(Routes10.guildRole(this.guildId, this.id), {
|
|
1736
|
+
body: Object.keys(body).length ? body : void 0,
|
|
1737
|
+
auth: true
|
|
1738
|
+
});
|
|
1739
|
+
this._patch(data);
|
|
1740
|
+
return this;
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Delete this role.
|
|
1744
|
+
* Requires Manage Roles permission.
|
|
1745
|
+
*/
|
|
1746
|
+
async delete() {
|
|
1747
|
+
await this.client.rest.delete(Routes10.guildRole(this.guildId, this.id), { auth: true });
|
|
1748
|
+
const guild = this.client.guilds.get(this.guildId);
|
|
1749
|
+
if (guild) guild.roles.delete(this.id);
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
|
|
1753
|
+
// src/structures/Guild.ts
|
|
1754
|
+
import { Routes as Routes14 } from "@fluxerjs/types";
|
|
1755
|
+
|
|
1756
|
+
// src/structures/GuildBan.ts
|
|
1757
|
+
import { Routes as Routes11 } from "@fluxerjs/types";
|
|
1758
|
+
var GuildBan = class extends Base {
|
|
1759
|
+
client;
|
|
1760
|
+
guildId;
|
|
1761
|
+
user;
|
|
1762
|
+
reason;
|
|
1763
|
+
/** ISO timestamp when a temporary ban expires. Null for permanent bans. */
|
|
1764
|
+
expiresAt;
|
|
1765
|
+
/** @param data - API ban from GET /guilds/{id}/bans or gateway GUILD_BAN_ADD */
|
|
1766
|
+
constructor(client, data, guildId) {
|
|
1767
|
+
super();
|
|
1768
|
+
this.client = client;
|
|
1769
|
+
this.guildId = data.guild_id ?? guildId;
|
|
1770
|
+
this.user = client.getOrCreateUser(data.user);
|
|
1771
|
+
this.reason = data.reason ?? null;
|
|
1772
|
+
this.expiresAt = data.expires_at ?? null;
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Remove this ban (unban the user).
|
|
1776
|
+
* Requires Ban Members permission.
|
|
1777
|
+
*/
|
|
1778
|
+
async unban() {
|
|
1779
|
+
await this.client.rest.delete(Routes11.guildBan(this.guildId, this.user.id), {
|
|
1780
|
+
auth: true
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
};
|
|
1784
|
+
|
|
1785
|
+
// src/structures/GuildEmoji.ts
|
|
1786
|
+
import { Routes as Routes12 } from "@fluxerjs/types";
|
|
1787
|
+
var GuildEmoji = class extends Base {
|
|
1788
|
+
client;
|
|
1789
|
+
id;
|
|
1790
|
+
guildId;
|
|
1791
|
+
name;
|
|
1792
|
+
animated;
|
|
1793
|
+
/** @param data - API emoji from GET /guilds/{id}/emojis or guild emoji events */
|
|
1794
|
+
constructor(client, data, guildId) {
|
|
1795
|
+
super();
|
|
1796
|
+
this.client = client;
|
|
1797
|
+
this.id = data.id;
|
|
1798
|
+
this.guildId = data.guild_id ?? guildId;
|
|
1799
|
+
this.name = data.name;
|
|
1800
|
+
this.animated = data.animated ?? false;
|
|
1801
|
+
}
|
|
1802
|
+
/** CDN URL for this emoji image. */
|
|
1803
|
+
get url() {
|
|
1804
|
+
const ext = this.animated ? "gif" : "png";
|
|
1805
|
+
return `${CDN_URL}/emojis/${this.id}.${ext}`;
|
|
1806
|
+
}
|
|
1807
|
+
/** Emoji identifier for use in reactions: `name:id` */
|
|
1808
|
+
get identifier() {
|
|
1809
|
+
return `${this.name}:${this.id}`;
|
|
1810
|
+
}
|
|
1811
|
+
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
1812
|
+
async delete() {
|
|
1813
|
+
await this.client.rest.delete(Routes12.guildEmoji(this.guildId, this.id), {
|
|
1814
|
+
auth: true
|
|
1815
|
+
});
|
|
1816
|
+
const guild = this.client.guilds.get(this.guildId);
|
|
1817
|
+
if (guild) guild.emojis.delete(this.id);
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Edit this emoji's name.
|
|
1821
|
+
* Requires Manage Emojis and Stickers permission.
|
|
1822
|
+
*/
|
|
1823
|
+
async edit(options) {
|
|
1824
|
+
const data = await this.client.rest.patch(Routes12.guildEmoji(this.guildId, this.id), {
|
|
1825
|
+
body: options,
|
|
1826
|
+
auth: true
|
|
1827
|
+
});
|
|
1828
|
+
this.name = data.name;
|
|
1829
|
+
return this;
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
|
|
1833
|
+
// src/structures/GuildSticker.ts
|
|
1834
|
+
import { Routes as Routes13 } from "@fluxerjs/types";
|
|
1835
|
+
var GuildSticker = class extends Base {
|
|
1836
|
+
client;
|
|
1837
|
+
id;
|
|
1838
|
+
guildId;
|
|
1839
|
+
name;
|
|
1840
|
+
description;
|
|
1841
|
+
tags;
|
|
1842
|
+
animated;
|
|
1843
|
+
/** @param data - API sticker from GET /guilds/{id}/stickers or guild sticker events */
|
|
1844
|
+
constructor(client, data, guildId) {
|
|
1845
|
+
super();
|
|
1846
|
+
this.client = client;
|
|
1847
|
+
this.id = data.id;
|
|
1848
|
+
this.guildId = data.guild_id ?? guildId;
|
|
1849
|
+
this.name = data.name;
|
|
1850
|
+
this.description = data.description ?? "";
|
|
1851
|
+
this.tags = data.tags ?? [];
|
|
1852
|
+
this.animated = data.animated ?? false;
|
|
1853
|
+
}
|
|
1854
|
+
/** CDN URL for this sticker image. */
|
|
1855
|
+
get url() {
|
|
1856
|
+
const ext = this.animated ? "gif" : "png";
|
|
1857
|
+
return `${CDN_URL}/stickers/${this.id}.${ext}`;
|
|
1858
|
+
}
|
|
1859
|
+
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
1860
|
+
async delete() {
|
|
1861
|
+
await this.client.rest.delete(Routes13.guildSticker(this.guildId, this.id), {
|
|
1862
|
+
auth: true
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
/**
|
|
1866
|
+
* Edit this sticker's name and/or description.
|
|
1867
|
+
* Requires Manage Emojis and Stickers permission.
|
|
1868
|
+
*/
|
|
1869
|
+
async edit(options) {
|
|
1870
|
+
const data = await this.client.rest.patch(Routes13.guildSticker(this.guildId, this.id), {
|
|
1871
|
+
body: options,
|
|
1872
|
+
auth: true
|
|
1873
|
+
});
|
|
1874
|
+
const s = data;
|
|
1875
|
+
this.name = s.name;
|
|
1876
|
+
this.description = s.description ?? "";
|
|
1877
|
+
return this;
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
|
|
1881
|
+
// src/structures/Guild.ts
|
|
1882
|
+
var Guild = class extends Base {
|
|
1883
|
+
client;
|
|
1884
|
+
id;
|
|
1885
|
+
name;
|
|
1886
|
+
icon;
|
|
1887
|
+
banner;
|
|
1888
|
+
ownerId;
|
|
1889
|
+
/** Invite splash image hash. Null if none. */
|
|
1890
|
+
splash;
|
|
1891
|
+
/** Custom vanity URL code (e.g. fluxer.gg/code). Null if none. */
|
|
1892
|
+
vanityURLCode;
|
|
1893
|
+
/** Enabled guild features. */
|
|
1894
|
+
features;
|
|
1895
|
+
verificationLevel;
|
|
1896
|
+
defaultMessageNotifications;
|
|
1897
|
+
explicitContentFilter;
|
|
1898
|
+
/** AFK voice channel ID. Null if none. */
|
|
1899
|
+
afkChannelId;
|
|
1900
|
+
/** AFK timeout in seconds. */
|
|
1901
|
+
afkTimeout;
|
|
1902
|
+
/** System messages channel ID. Null if none. */
|
|
1903
|
+
systemChannelId;
|
|
1904
|
+
/** Rules/guidelines channel ID. Null if none. */
|
|
1905
|
+
rulesChannelId;
|
|
1906
|
+
nsfwLevel;
|
|
1907
|
+
mfaLevel;
|
|
1908
|
+
/** Banner image width. Optional. */
|
|
1909
|
+
bannerWidth;
|
|
1910
|
+
/** Banner image height. Optional. */
|
|
1911
|
+
bannerHeight;
|
|
1912
|
+
/** Splash image width. Optional. */
|
|
1913
|
+
splashWidth;
|
|
1914
|
+
/** Splash image height. Optional. */
|
|
1915
|
+
splashHeight;
|
|
1916
|
+
members;
|
|
1917
|
+
channels = new Collection7();
|
|
1918
|
+
roles = new Collection7();
|
|
1919
|
+
emojis = new Collection7();
|
|
1920
|
+
/** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
|
|
1921
|
+
constructor(client, data) {
|
|
1922
|
+
super();
|
|
1923
|
+
this.client = client;
|
|
1924
|
+
this.id = data.id;
|
|
1925
|
+
this.members = new GuildMemberManager(this);
|
|
1926
|
+
this.name = data.name;
|
|
1927
|
+
this.icon = data.icon ?? null;
|
|
1928
|
+
this.banner = data.banner ?? null;
|
|
1929
|
+
this.ownerId = data.owner_id ?? data.ownerId ?? "";
|
|
1930
|
+
this.splash = data.splash ?? null;
|
|
1931
|
+
this.vanityURLCode = data.vanity_url_code ?? null;
|
|
1932
|
+
this.features = data.features ?? [];
|
|
1933
|
+
this.verificationLevel = data.verification_level ?? 0;
|
|
1934
|
+
this.defaultMessageNotifications = data.default_message_notifications ?? 0;
|
|
1935
|
+
this.explicitContentFilter = data.explicit_content_filter ?? 0;
|
|
1936
|
+
this.afkChannelId = data.afk_channel_id ?? null;
|
|
1937
|
+
this.afkTimeout = data.afk_timeout ?? 0;
|
|
1938
|
+
this.systemChannelId = data.system_channel_id ?? null;
|
|
1939
|
+
this.rulesChannelId = data.rules_channel_id ?? null;
|
|
1940
|
+
this.nsfwLevel = data.nsfw_level ?? 0;
|
|
1941
|
+
this.mfaLevel = data.mfa_level ?? 0;
|
|
1942
|
+
this.bannerWidth = data.banner_width ?? null;
|
|
1943
|
+
this.bannerHeight = data.banner_height ?? null;
|
|
1944
|
+
this.splashWidth = data.splash_width ?? null;
|
|
1945
|
+
this.splashHeight = data.splash_height ?? null;
|
|
1946
|
+
for (const r of data.roles ?? []) {
|
|
1947
|
+
this.roles.set(r.id, new Role(client, r, this.id));
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
/** Get the guild icon URL, or null if no icon. */
|
|
1951
|
+
iconURL(options) {
|
|
1952
|
+
if (!this.icon) return null;
|
|
1953
|
+
const size = options?.size ? `?size=${options.size}` : "";
|
|
1954
|
+
return `${CDN_URL}/icons/${this.id}/${this.icon}.png${size}`;
|
|
1955
|
+
}
|
|
1956
|
+
/** Get the guild banner URL, or null if no banner. */
|
|
1957
|
+
bannerURL(options) {
|
|
1958
|
+
if (!this.banner) return null;
|
|
1959
|
+
const size = options?.size ? `?size=${options.size}` : "";
|
|
1960
|
+
return `${CDN_URL}/banners/${this.id}/${this.banner}.png${size}`;
|
|
1961
|
+
}
|
|
1962
|
+
/** Get the guild splash (invite background) URL, or null if no splash. */
|
|
1963
|
+
splashURL(options) {
|
|
1964
|
+
if (!this.splash) return null;
|
|
1965
|
+
const size = options?.size ? `?size=${options.size}` : "";
|
|
1966
|
+
return `${CDN_URL}/splashes/${this.id}/${this.splash}.png${size}`;
|
|
1967
|
+
}
|
|
1968
|
+
/**
|
|
1969
|
+
* Add a role to a member by user ID. Does not require fetching the member first.
|
|
1970
|
+
* @param userId - The user ID of the member
|
|
1971
|
+
* @param roleId - The role ID to add (or use guild.resolveRoleId for mention/name resolution)
|
|
1972
|
+
* Requires Manage Roles permission.
|
|
1973
|
+
*/
|
|
1974
|
+
async addRoleToMember(userId, roleId) {
|
|
1975
|
+
await this.client.rest.put(Routes14.guildMemberRole(this.id, userId, roleId));
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Remove a role from a member by user ID. Does not require fetching the member first.
|
|
1979
|
+
* @param userId - The user ID of the member
|
|
1980
|
+
* @param roleId - The role ID to remove
|
|
1981
|
+
* Requires Manage Roles permission.
|
|
1982
|
+
*/
|
|
1983
|
+
async removeRoleFromMember(userId, roleId) {
|
|
1984
|
+
await this.client.rest.delete(Routes14.guildMemberRole(this.id, userId, roleId));
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
* Create a role in this guild.
|
|
1988
|
+
* Requires Manage Roles permission.
|
|
1989
|
+
* @param options - Role data (permissions accepts PermissionResolvable for convenience)
|
|
1990
|
+
* @returns The created role
|
|
1991
|
+
* @example
|
|
1992
|
+
* const role = await guild.createRole({ name: 'Mod', permissions: ['KickMembers', 'BanMembers'] });
|
|
1993
|
+
*/
|
|
1994
|
+
async createRole(options) {
|
|
1995
|
+
const body = {};
|
|
1996
|
+
if (options.name !== void 0) body.name = options.name;
|
|
1997
|
+
if (options.permissions !== void 0) {
|
|
1998
|
+
body.permissions = typeof options.permissions === "string" ? options.permissions : resolvePermissionsToBitfield2(options.permissions);
|
|
1999
|
+
}
|
|
2000
|
+
if (options.color !== void 0) body.color = options.color;
|
|
2001
|
+
if (options.hoist !== void 0) body.hoist = options.hoist;
|
|
2002
|
+
if (options.mentionable !== void 0) body.mentionable = options.mentionable;
|
|
2003
|
+
if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
|
|
2004
|
+
if (options.position !== void 0) body.position = options.position;
|
|
2005
|
+
if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
|
|
2006
|
+
const data = await this.client.rest.post(Routes14.guildRoles(this.id), {
|
|
2007
|
+
body: Object.keys(body).length ? body : void 0,
|
|
2008
|
+
auth: true
|
|
2009
|
+
});
|
|
2010
|
+
const role = new Role(this.client, data, this.id);
|
|
2011
|
+
this.roles.set(role.id, role);
|
|
2012
|
+
return role;
|
|
2013
|
+
}
|
|
2014
|
+
/**
|
|
2015
|
+
* Fetch all roles in this guild.
|
|
2016
|
+
* @returns Array of Role objects (cached in guild.roles)
|
|
2017
|
+
*/
|
|
2018
|
+
async fetchRoles() {
|
|
2019
|
+
const data = await this.client.rest.get(
|
|
2020
|
+
Routes14.guildRoles(this.id)
|
|
2021
|
+
);
|
|
2022
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2023
|
+
const roles = [];
|
|
2024
|
+
for (const r of list) {
|
|
2025
|
+
const role = new Role(this.client, r, this.id);
|
|
2026
|
+
this.roles.set(role.id, role);
|
|
2027
|
+
roles.push(role);
|
|
2028
|
+
}
|
|
2029
|
+
return roles;
|
|
2030
|
+
}
|
|
2031
|
+
/**
|
|
2032
|
+
* Fetch a role by ID.
|
|
2033
|
+
* @param roleId - The role ID to fetch
|
|
2034
|
+
* @returns The role
|
|
2035
|
+
* @throws FluxerError with ROLE_NOT_FOUND if role does not exist (404)
|
|
2036
|
+
*/
|
|
2037
|
+
async fetchRole(roleId) {
|
|
2038
|
+
try {
|
|
2039
|
+
const data = await this.client.rest.get(Routes14.guildRole(this.id, roleId));
|
|
2040
|
+
const role = new Role(this.client, data, this.id);
|
|
2041
|
+
this.roles.set(role.id, role);
|
|
2042
|
+
return role;
|
|
2043
|
+
} catch (err) {
|
|
2044
|
+
const statusCode = err instanceof FluxerAPIError3 ? err.statusCode : err?.statusCode;
|
|
2045
|
+
if (statusCode === 404) {
|
|
2046
|
+
throw new FluxerError(`Role ${roleId} not found in guild`, {
|
|
2047
|
+
code: ErrorCodes.RoleNotFound,
|
|
2048
|
+
cause: err
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
throw err instanceof FluxerError ? err : new FluxerError("Failed to fetch guild role", { cause: err });
|
|
2052
|
+
}
|
|
90
2053
|
}
|
|
91
2054
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* @
|
|
95
|
-
* @
|
|
96
|
-
* @example
|
|
97
|
-
* const channel = await client.channels.fetch(channelId);
|
|
98
|
-
* if (channel?.isSendable()) await channel.send('Hello!');
|
|
2055
|
+
* Resolve a role ID from an argument (role mention, raw ID, or name).
|
|
2056
|
+
* Fetches guild roles if name is provided.
|
|
2057
|
+
* @param arg - Role mention (@role), role ID, or role name
|
|
2058
|
+
* @returns The role ID, or null if not found
|
|
99
2059
|
*/
|
|
100
|
-
async
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
2060
|
+
async resolveRoleId(arg) {
|
|
2061
|
+
const parsed = parseRoleMention(arg);
|
|
2062
|
+
if (parsed) return parsed;
|
|
2063
|
+
if (/^\d{17,19}$/.test(arg.trim())) return arg.trim();
|
|
2064
|
+
const cached = this.roles.find(
|
|
2065
|
+
(r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase())
|
|
2066
|
+
);
|
|
2067
|
+
if (cached) return cached.id;
|
|
2068
|
+
const roles = await this.client.rest.get(Routes14.guildRoles(this.id));
|
|
2069
|
+
const list = Array.isArray(roles) ? roles : Object.values(roles ?? {});
|
|
2070
|
+
const role = list.find((r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase()));
|
|
2071
|
+
if (role) {
|
|
2072
|
+
this.roles.set(role.id, new Role(this.client, role, this.id));
|
|
2073
|
+
return role.id;
|
|
2074
|
+
}
|
|
2075
|
+
return null;
|
|
2076
|
+
}
|
|
2077
|
+
/**
|
|
2078
|
+
* Ban a user from this guild.
|
|
2079
|
+
* @param userId - The user ID to ban
|
|
2080
|
+
* @param options - Optional reason, delete_message_days (0–7), and ban_duration_seconds (temporary ban).
|
|
2081
|
+
* ban_duration_seconds: 0 = permanent, or use 3600, 43200, 86400, 259200, 432000, 604800, 1209600, 2592000.
|
|
2082
|
+
* Requires Ban Members permission.
|
|
2083
|
+
*/
|
|
2084
|
+
async ban(userId, options) {
|
|
2085
|
+
const body = {};
|
|
2086
|
+
if (options?.reason) body.reason = options.reason;
|
|
2087
|
+
if (options?.delete_message_days != null)
|
|
2088
|
+
body.delete_message_days = options.delete_message_days;
|
|
2089
|
+
if (options?.ban_duration_seconds != null)
|
|
2090
|
+
body.ban_duration_seconds = options.ban_duration_seconds;
|
|
2091
|
+
await this.client.rest.put(Routes14.guildBan(this.id, userId), {
|
|
2092
|
+
body: Object.keys(body).length ? body : void 0,
|
|
2093
|
+
auth: true
|
|
2094
|
+
});
|
|
2095
|
+
}
|
|
2096
|
+
/**
|
|
2097
|
+
* Fetch guild bans. Requires Ban Members permission.
|
|
2098
|
+
* @returns List of GuildBan objects
|
|
2099
|
+
*/
|
|
2100
|
+
async fetchBans() {
|
|
2101
|
+
const data = await this.client.rest.get(
|
|
2102
|
+
Routes14.guildBans(this.id)
|
|
2103
|
+
);
|
|
2104
|
+
const list = Array.isArray(data) ? data : data?.bans ?? [];
|
|
2105
|
+
return list.map((b) => new GuildBan(this.client, { ...b, guild_id: this.id }, this.id));
|
|
2106
|
+
}
|
|
2107
|
+
/**
|
|
2108
|
+
* Remove a ban (unban a user).
|
|
2109
|
+
* @param userId - The user ID to unban
|
|
2110
|
+
* Requires Ban Members permission.
|
|
2111
|
+
*/
|
|
2112
|
+
async unban(userId) {
|
|
2113
|
+
await this.client.rest.delete(Routes14.guildBan(this.id, userId), { auth: true });
|
|
2114
|
+
}
|
|
2115
|
+
/**
|
|
2116
|
+
* Kick a member from this guild.
|
|
2117
|
+
* @param userId - The user ID to kick
|
|
2118
|
+
* Requires Kick Members permission.
|
|
2119
|
+
*/
|
|
2120
|
+
async kick(userId) {
|
|
2121
|
+
await this.client.rest.delete(Routes14.guildMember(this.id, userId), { auth: true });
|
|
2122
|
+
}
|
|
2123
|
+
/**
|
|
2124
|
+
* Fetch a guild member by user ID.
|
|
2125
|
+
* @param userId - The user ID of the member to fetch
|
|
2126
|
+
* @returns The guild member
|
|
2127
|
+
* @throws FluxerError with MEMBER_NOT_FOUND if user is not in the guild (404)
|
|
2128
|
+
* @throws FluxerError with cause for permission denied (403) or other REST errors
|
|
2129
|
+
*/
|
|
2130
|
+
async fetchMember(userId) {
|
|
103
2131
|
try {
|
|
104
|
-
const { Channel: Channel2 } = await import("./Channel-JFQXR7SZ.mjs");
|
|
105
2132
|
const data = await this.client.rest.get(
|
|
106
|
-
|
|
2133
|
+
Routes14.guildMember(this.id, userId)
|
|
107
2134
|
);
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
code: ErrorCodes.ChannelNotFound
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
this.set(channel.id, channel);
|
|
115
|
-
return channel;
|
|
2135
|
+
const member = new GuildMember(this.client, { ...data, guild_id: this.id }, this);
|
|
2136
|
+
this.members.set(member.id, member);
|
|
2137
|
+
return member;
|
|
116
2138
|
} catch (err) {
|
|
117
|
-
|
|
118
|
-
if (
|
|
119
|
-
throw new FluxerError(`
|
|
120
|
-
code: ErrorCodes.
|
|
2139
|
+
const statusCode = err instanceof FluxerAPIError3 ? err.statusCode : err?.statusCode;
|
|
2140
|
+
if (statusCode === 404) {
|
|
2141
|
+
throw new FluxerError(`Member ${userId} not found in guild`, {
|
|
2142
|
+
code: ErrorCodes.MemberNotFound,
|
|
121
2143
|
cause: err
|
|
122
2144
|
});
|
|
123
2145
|
}
|
|
124
|
-
throw err instanceof FluxerError ? err : new FluxerError(
|
|
2146
|
+
throw err instanceof FluxerError ? err : new FluxerError("Failed to fetch guild member", { cause: err });
|
|
125
2147
|
}
|
|
126
2148
|
}
|
|
127
2149
|
/**
|
|
128
|
-
* Fetch
|
|
129
|
-
* @param
|
|
130
|
-
* @param messageId - Snowflake of the message
|
|
131
|
-
* @returns The message
|
|
132
|
-
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
133
|
-
* @deprecated Use channel.messages.fetch(messageId). Prefer (await client.channels.fetch(channelId))?.messages?.fetch(messageId).
|
|
134
|
-
* @example
|
|
135
|
-
* const channel = await client.channels.fetch(channelId);
|
|
136
|
-
* const message = await channel?.messages?.fetch(messageId);
|
|
2150
|
+
* Fetch guild audit logs. Requires View Audit Log permission.
|
|
2151
|
+
* @param options - Optional limit, before, after, user_id, action_type for filtering
|
|
137
2152
|
*/
|
|
138
|
-
async
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
2153
|
+
async fetchAuditLogs(options) {
|
|
2154
|
+
const params = new URLSearchParams();
|
|
2155
|
+
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
2156
|
+
if (options?.before) params.set("before", options.before);
|
|
2157
|
+
if (options?.after) params.set("after", options.after);
|
|
2158
|
+
if (options?.userId) params.set("user_id", options.userId);
|
|
2159
|
+
if (options?.actionType != null) params.set("action_type", String(options.actionType));
|
|
2160
|
+
const qs = params.toString();
|
|
2161
|
+
const url = Routes14.guildAuditLogs(this.id) + (qs ? `?${qs}` : "");
|
|
2162
|
+
return this.client.rest.get(url);
|
|
2163
|
+
}
|
|
2164
|
+
/** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
|
|
2165
|
+
async fetchWebhooks() {
|
|
2166
|
+
const data = await this.client.rest.get(Routes14.guildWebhooks(this.id));
|
|
2167
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2168
|
+
return list.map((w) => new Webhook(this.client, w));
|
|
2169
|
+
}
|
|
2170
|
+
/**
|
|
2171
|
+
* Create a channel in this guild.
|
|
2172
|
+
* @param data - Channel data: type (0=text, 2=voice, 4=category, 5=link), name, and optional parent_id, topic, bitrate, user_limit, nsfw, permission_overwrites
|
|
2173
|
+
* Requires Manage Channels permission.
|
|
2174
|
+
*/
|
|
2175
|
+
async createChannel(data) {
|
|
2176
|
+
const created = await this.client.rest.post(Routes14.guildChannels(this.id), {
|
|
2177
|
+
body: data,
|
|
2178
|
+
auth: true
|
|
2179
|
+
});
|
|
2180
|
+
const channel = Channel.from(this.client, created);
|
|
2181
|
+
if (channel) {
|
|
2182
|
+
this.client.channels.set(channel.id, channel);
|
|
2183
|
+
this.channels.set(channel.id, channel);
|
|
2184
|
+
}
|
|
2185
|
+
return channel;
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* Fetch all channels in this guild.
|
|
2189
|
+
* @returns Array of GuildChannel objects (cached in guild.channels and client.channels)
|
|
2190
|
+
*/
|
|
2191
|
+
async fetchChannels() {
|
|
2192
|
+
const data = await this.client.rest.get(Routes14.guildChannels(this.id));
|
|
2193
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2194
|
+
const channels = [];
|
|
2195
|
+
for (const ch of list) {
|
|
2196
|
+
const channel = Channel.from(this.client, ch);
|
|
2197
|
+
if (channel) {
|
|
2198
|
+
this.client.channels.set(channel.id, channel);
|
|
2199
|
+
this.channels.set(channel.id, channel);
|
|
2200
|
+
channels.push(channel);
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
return channels;
|
|
2204
|
+
}
|
|
2205
|
+
/**
|
|
2206
|
+
* Edit this guild. PATCH /guilds/{id}.
|
|
2207
|
+
* Requires guild owner or Administrator.
|
|
2208
|
+
*/
|
|
2209
|
+
async edit(options) {
|
|
2210
|
+
const data = await this.client.rest.patch(Routes14.guild(this.id), {
|
|
2211
|
+
body: options,
|
|
2212
|
+
auth: true
|
|
2213
|
+
});
|
|
2214
|
+
this.name = data.name;
|
|
2215
|
+
this.icon = data.icon ?? this.icon;
|
|
2216
|
+
this.banner = data.banner ?? this.banner;
|
|
2217
|
+
this.splash = data.splash ?? this.splash;
|
|
2218
|
+
this.systemChannelId = data.system_channel_id ?? this.systemChannelId;
|
|
2219
|
+
this.afkChannelId = data.afk_channel_id ?? this.afkChannelId;
|
|
2220
|
+
this.afkTimeout = data.afk_timeout ?? this.afkTimeout;
|
|
2221
|
+
this.verificationLevel = data.verification_level ?? this.verificationLevel;
|
|
2222
|
+
this.mfaLevel = data.mfa_level ?? this.mfaLevel;
|
|
2223
|
+
this.explicitContentFilter = data.explicit_content_filter ?? this.explicitContentFilter;
|
|
2224
|
+
this.defaultMessageNotifications = data.default_message_notifications ?? this.defaultMessageNotifications;
|
|
2225
|
+
this.features = data.features ?? this.features;
|
|
2226
|
+
return this;
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* Delete this guild. POST /guilds/{id}/delete.
|
|
2230
|
+
* Must be the guild owner.
|
|
2231
|
+
*/
|
|
2232
|
+
async delete() {
|
|
2233
|
+
await this.client.rest.post(Routes14.guildDelete(this.id), { auth: true });
|
|
2234
|
+
this.client.guilds.delete(this.id);
|
|
2235
|
+
}
|
|
2236
|
+
/**
|
|
2237
|
+
* Fetch vanity URL for this guild. GET /guilds/{id}/vanity-url.
|
|
2238
|
+
* Requires Manage Guild permission.
|
|
2239
|
+
*/
|
|
2240
|
+
async fetchVanityURL() {
|
|
2241
|
+
return this.client.rest.get(Routes14.guildVanityUrl(this.id), { auth: true });
|
|
2242
|
+
}
|
|
2243
|
+
/**
|
|
2244
|
+
* Transfer guild ownership to another user. POST /guilds/{id}/transfer-ownership.
|
|
2245
|
+
* Must be the guild owner.
|
|
2246
|
+
*/
|
|
2247
|
+
async transferOwnership(newOwnerId, password) {
|
|
2248
|
+
await this.client.rest.post(Routes14.guildTransferOwnership(this.id), {
|
|
2249
|
+
body: { new_owner_id: newOwnerId, ...password != null && { password } },
|
|
2250
|
+
auth: true
|
|
2251
|
+
});
|
|
2252
|
+
}
|
|
2253
|
+
/**
|
|
2254
|
+
* Set text channel flexible names feature. PATCH /guilds/{id}/text-channel-flexible-names.
|
|
2255
|
+
*/
|
|
2256
|
+
setTextChannelFlexibleNames(enabled) {
|
|
2257
|
+
return this.client.rest.patch(Routes14.guildTextChannelFlexibleNames(this.id), {
|
|
2258
|
+
body: { enabled },
|
|
2259
|
+
auth: true
|
|
2260
|
+
}).then(() => this);
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Set detached banner feature. PATCH /guilds/{id}/detached-banner.
|
|
2264
|
+
*/
|
|
2265
|
+
setDetachedBanner(enabled) {
|
|
2266
|
+
return this.client.rest.patch(Routes14.guildDetachedBanner(this.id), {
|
|
2267
|
+
body: { enabled },
|
|
2268
|
+
auth: true
|
|
2269
|
+
}).then(() => this);
|
|
2270
|
+
}
|
|
2271
|
+
/**
|
|
2272
|
+
* Set disallow unclaimed accounts. PATCH /guilds/{id}/disallow-unclaimed-accounts.
|
|
2273
|
+
*/
|
|
2274
|
+
setDisallowUnclaimedAccounts(enabled) {
|
|
2275
|
+
return this.client.rest.patch(Routes14.guildDisallowUnclaimedAccounts(this.id), {
|
|
2276
|
+
body: { enabled },
|
|
2277
|
+
auth: true
|
|
2278
|
+
}).then(() => this);
|
|
2279
|
+
}
|
|
2280
|
+
/**
|
|
2281
|
+
* Update role positions. PATCH /guilds/{id}/roles.
|
|
2282
|
+
* @param updates - Array of { id, position? }
|
|
2283
|
+
*/
|
|
2284
|
+
async setRolePositions(updates) {
|
|
2285
|
+
const data = await this.client.rest.patch(
|
|
2286
|
+
Routes14.guildRoles(this.id),
|
|
2287
|
+
{ body: updates, auth: true }
|
|
2288
|
+
);
|
|
2289
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2290
|
+
for (const r of list) {
|
|
2291
|
+
this.roles.set(r.id, new Role(this.client, r, this.id));
|
|
2292
|
+
}
|
|
2293
|
+
return list;
|
|
2294
|
+
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Update role hoist positions. PATCH /guilds/{id}/roles/hoist-positions.
|
|
2297
|
+
*/
|
|
2298
|
+
async setRoleHoistPositions(updates) {
|
|
2299
|
+
const data = await this.client.rest.patch(
|
|
2300
|
+
Routes14.guildRolesHoistPositions(this.id),
|
|
2301
|
+
{ body: updates, auth: true }
|
|
2302
|
+
);
|
|
2303
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2304
|
+
for (const r of list) {
|
|
2305
|
+
this.roles.set(r.id, new Role(this.client, r, this.id));
|
|
2306
|
+
}
|
|
2307
|
+
return list;
|
|
2308
|
+
}
|
|
2309
|
+
/**
|
|
2310
|
+
* Reset role hoist positions. DELETE /guilds/{id}/roles/hoist-positions.
|
|
2311
|
+
*/
|
|
2312
|
+
async resetRoleHoistPositions() {
|
|
2313
|
+
const data = await this.client.rest.delete(
|
|
2314
|
+
Routes14.guildRolesHoistPositions(this.id),
|
|
2315
|
+
{ auth: true }
|
|
142
2316
|
);
|
|
2317
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2318
|
+
for (const r of list) {
|
|
2319
|
+
this.roles.set(r.id, new Role(this.client, r, this.id));
|
|
2320
|
+
}
|
|
2321
|
+
return list;
|
|
2322
|
+
}
|
|
2323
|
+
/**
|
|
2324
|
+
* Update channel positions.
|
|
2325
|
+
* @param updates - Array of { id, position?, parent_id?, lock_permissions? }
|
|
2326
|
+
* Requires Manage Channels permission.
|
|
2327
|
+
*/
|
|
2328
|
+
async setChannelPositions(updates) {
|
|
2329
|
+
await this.client.rest.patch(Routes14.guildChannels(this.id), {
|
|
2330
|
+
body: updates,
|
|
2331
|
+
auth: true
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2334
|
+
/**
|
|
2335
|
+
* Fetch all emojis in this guild.
|
|
2336
|
+
* @returns Array of GuildEmoji objects (cached in guild.emojis)
|
|
2337
|
+
*/
|
|
2338
|
+
async fetchEmojis() {
|
|
2339
|
+
const data = await this.client.rest.get(
|
|
2340
|
+
Routes14.guildEmojis(this.id)
|
|
2341
|
+
);
|
|
2342
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2343
|
+
const emojis = [];
|
|
2344
|
+
for (const e of list) {
|
|
2345
|
+
const emoji = new GuildEmoji(this.client, { ...e, guild_id: this.id }, this.id);
|
|
2346
|
+
this.emojis.set(emoji.id, emoji);
|
|
2347
|
+
emojis.push(emoji);
|
|
2348
|
+
}
|
|
2349
|
+
return emojis;
|
|
2350
|
+
}
|
|
2351
|
+
/**
|
|
2352
|
+
* Fetch a single emoji by ID.
|
|
2353
|
+
* @param emojiId - The emoji ID to fetch
|
|
2354
|
+
* @returns The guild emoji
|
|
2355
|
+
* @throws FluxerError if emoji not found (404)
|
|
2356
|
+
*/
|
|
2357
|
+
async fetchEmoji(emojiId) {
|
|
143
2358
|
try {
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return new Message2(this.client, data);
|
|
2359
|
+
const data = await this.client.rest.get(Routes14.guildEmoji(this.id, emojiId));
|
|
2360
|
+
const emoji = new GuildEmoji(this.client, { ...data, guild_id: this.id }, this.id);
|
|
2361
|
+
this.emojis.set(emoji.id, emoji);
|
|
2362
|
+
return emoji;
|
|
149
2363
|
} catch (err) {
|
|
150
|
-
|
|
151
|
-
if (
|
|
152
|
-
throw new FluxerError(`
|
|
153
|
-
code: ErrorCodes.
|
|
2364
|
+
const statusCode = err instanceof FluxerAPIError3 ? err.statusCode : err?.statusCode;
|
|
2365
|
+
if (statusCode === 404) {
|
|
2366
|
+
throw new FluxerError(`Emoji ${emojiId} not found in guild`, {
|
|
2367
|
+
code: ErrorCodes.EmojiNotFound,
|
|
154
2368
|
cause: err
|
|
155
2369
|
});
|
|
156
2370
|
}
|
|
157
|
-
throw err instanceof FluxerError ? err : new FluxerError(
|
|
2371
|
+
throw err instanceof FluxerError ? err : new FluxerError("Failed to fetch guild emoji", { cause: err });
|
|
158
2372
|
}
|
|
159
2373
|
}
|
|
160
2374
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* @
|
|
164
|
-
* @param payload - Text content or object with content, embeds, and/or files
|
|
165
|
-
* @returns The created message
|
|
166
|
-
* @example
|
|
167
|
-
* await client.channels.send(logChannelId, 'User joined!');
|
|
168
|
-
* await client.channels.send(channelId, { embeds: [embed.toJSON()] });
|
|
169
|
-
* await client.channels.send(channelId, { content: 'Report', files: [{ name: 'log.txt', data }] });
|
|
2375
|
+
* Bulk create emojis. POST /guilds/{id}/emojis/bulk.
|
|
2376
|
+
* @param emojis - Array of { name, image } (base64), 1-50 emojis
|
|
2377
|
+
* @returns Array of created GuildEmoji objects
|
|
170
2378
|
*/
|
|
171
|
-
async
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
2379
|
+
async createEmojisBulk(emojis) {
|
|
2380
|
+
const data = await this.client.rest.post(
|
|
2381
|
+
Routes14.guildEmojisBulk(this.id),
|
|
2382
|
+
{
|
|
2383
|
+
body: { emojis },
|
|
2384
|
+
auth: true
|
|
2385
|
+
}
|
|
2386
|
+
);
|
|
2387
|
+
const list = Array.isArray(data) ? data : data?.emojis ?? [];
|
|
2388
|
+
return list.map((e) => new GuildEmoji(this.client, { ...e, guild_id: this.id }, this.id));
|
|
2389
|
+
}
|
|
2390
|
+
/**
|
|
2391
|
+
* Bulk create stickers. POST /guilds/{id}/stickers/bulk.
|
|
2392
|
+
* @param stickers - Array of { name, image, description?, tags? }, 1-50 stickers
|
|
2393
|
+
* @returns Array of created GuildSticker objects
|
|
2394
|
+
*/
|
|
2395
|
+
async createStickersBulk(stickers) {
|
|
2396
|
+
const data = await this.client.rest.post(
|
|
2397
|
+
Routes14.guildStickersBulk(this.id),
|
|
2398
|
+
{
|
|
2399
|
+
body: { stickers },
|
|
2400
|
+
auth: true
|
|
2401
|
+
}
|
|
2402
|
+
);
|
|
2403
|
+
const list = Array.isArray(data) ? data : data?.stickers ?? [];
|
|
2404
|
+
return list.map((s) => new GuildSticker(this.client, { ...s, guild_id: this.id }, this.id));
|
|
179
2405
|
}
|
|
180
2406
|
};
|
|
181
2407
|
|
|
182
2408
|
// src/client/GuildManager.ts
|
|
183
|
-
|
|
184
|
-
import { Routes as Routes2 } from "@fluxerjs/types";
|
|
185
|
-
var GuildManager = class extends Collection2 {
|
|
2409
|
+
var GuildManager = class extends Collection8 {
|
|
186
2410
|
constructor(client) {
|
|
187
2411
|
super();
|
|
188
2412
|
this.client = client;
|
|
2413
|
+
this.maxSize = client.options?.cache?.guilds ?? 0;
|
|
2414
|
+
}
|
|
2415
|
+
maxSize;
|
|
2416
|
+
set(key, value) {
|
|
2417
|
+
if (this.maxSize > 0 && this.size >= this.maxSize && !this.has(key)) {
|
|
2418
|
+
const firstKey = this.keys().next().value;
|
|
2419
|
+
if (firstKey !== void 0) this.delete(firstKey);
|
|
2420
|
+
}
|
|
2421
|
+
return super.set(key, value);
|
|
2422
|
+
}
|
|
2423
|
+
/**
|
|
2424
|
+
* Get a guild from cache or fetch from the API if not present.
|
|
2425
|
+
* Convenience helper to avoid repeating `client.guilds.get(id) ?? (await client.guilds.fetch(id))`.
|
|
2426
|
+
* @param guildId - Snowflake of the guild
|
|
2427
|
+
* @returns The guild, or null if not found
|
|
2428
|
+
* @example
|
|
2429
|
+
* const guild = await client.guilds.resolve(message.guildId);
|
|
2430
|
+
* if (guild) console.log(guild.name);
|
|
2431
|
+
*/
|
|
2432
|
+
async resolve(guildId) {
|
|
2433
|
+
return this.get(guildId) ?? this.fetch(guildId);
|
|
189
2434
|
}
|
|
190
2435
|
/**
|
|
191
2436
|
* Create a guild. POST /guilds.
|
|
@@ -193,12 +2438,11 @@ var GuildManager = class extends Collection2 {
|
|
|
193
2438
|
* @returns The created guild
|
|
194
2439
|
*/
|
|
195
2440
|
async create(options) {
|
|
196
|
-
const
|
|
197
|
-
const data = await this.client.rest.post(Routes2.guilds(), {
|
|
2441
|
+
const data = await this.client.rest.post(Routes15.guilds(), {
|
|
198
2442
|
body: options,
|
|
199
2443
|
auth: true
|
|
200
2444
|
});
|
|
201
|
-
const guild = new
|
|
2445
|
+
const guild = new Guild(this.client, data);
|
|
202
2446
|
this.set(guild.id, guild);
|
|
203
2447
|
return guild;
|
|
204
2448
|
}
|
|
@@ -214,11 +2458,8 @@ var GuildManager = class extends Collection2 {
|
|
|
214
2458
|
const cached = this.get(guildId);
|
|
215
2459
|
if (cached) return cached;
|
|
216
2460
|
try {
|
|
217
|
-
const
|
|
218
|
-
const
|
|
219
|
-
Routes2.guild(guildId)
|
|
220
|
-
);
|
|
221
|
-
const guild = new Guild2(this.client, data);
|
|
2461
|
+
const data = await this.client.rest.get(Routes15.guild(guildId));
|
|
2462
|
+
const guild = new Guild(this.client, data);
|
|
222
2463
|
this.set(guild.id, guild);
|
|
223
2464
|
return guild;
|
|
224
2465
|
} catch {
|
|
@@ -227,21 +2468,156 @@ var GuildManager = class extends Collection2 {
|
|
|
227
2468
|
}
|
|
228
2469
|
};
|
|
229
2470
|
|
|
2471
|
+
// src/structures/User.ts
|
|
2472
|
+
import { Routes as Routes16 } from "@fluxerjs/types";
|
|
2473
|
+
var User = class extends Base {
|
|
2474
|
+
client;
|
|
2475
|
+
id;
|
|
2476
|
+
username;
|
|
2477
|
+
discriminator;
|
|
2478
|
+
globalName;
|
|
2479
|
+
avatar;
|
|
2480
|
+
bot;
|
|
2481
|
+
/** RGB avatar color (e.g. 7577782). Null if not set. */
|
|
2482
|
+
avatarColor;
|
|
2483
|
+
/** Public flags bitfield. Null if not set. */
|
|
2484
|
+
flags;
|
|
2485
|
+
/** Whether this is an official system user. */
|
|
2486
|
+
system;
|
|
2487
|
+
/** Banner hash (from profile, member, or invite context). Null when not available. */
|
|
2488
|
+
banner;
|
|
2489
|
+
/** @param data - API user from message author, GET /users/{id}, or GET /users/@me */
|
|
2490
|
+
constructor(client, data) {
|
|
2491
|
+
super();
|
|
2492
|
+
this.client = client;
|
|
2493
|
+
this.id = data.id;
|
|
2494
|
+
this.username = data.username;
|
|
2495
|
+
this.discriminator = data.discriminator;
|
|
2496
|
+
this.globalName = data.global_name ?? null;
|
|
2497
|
+
this.avatar = data.avatar ?? null;
|
|
2498
|
+
this.bot = !!data.bot;
|
|
2499
|
+
this.avatarColor = data.avatar_color ?? null;
|
|
2500
|
+
this.flags = data.flags ?? data.public_flags ?? null;
|
|
2501
|
+
this.system = !!data.system;
|
|
2502
|
+
this.banner = data.banner ?? null;
|
|
2503
|
+
}
|
|
2504
|
+
/** Update mutable fields from fresh API data. Used by getOrCreateUser cache. */
|
|
2505
|
+
_patch(data) {
|
|
2506
|
+
this.username = data.username;
|
|
2507
|
+
this.discriminator = data.discriminator;
|
|
2508
|
+
this.globalName = data.global_name ?? null;
|
|
2509
|
+
this.avatar = data.avatar ?? null;
|
|
2510
|
+
if (data.avatar_color !== void 0) this.avatarColor = data.avatar_color;
|
|
2511
|
+
if (data.flags !== void 0) this.flags = data.flags;
|
|
2512
|
+
if (data.banner !== void 0) this.banner = data.banner;
|
|
2513
|
+
}
|
|
2514
|
+
/**
|
|
2515
|
+
* Get the URL for this user's avatar.
|
|
2516
|
+
* Auto-detects animated avatars (hash starting with `a_`) and uses gif extension.
|
|
2517
|
+
* @param options - Optional `size` and `extension` (default: png, or gif for animated)
|
|
2518
|
+
*/
|
|
2519
|
+
avatarURL(options) {
|
|
2520
|
+
if (!this.avatar) return null;
|
|
2521
|
+
const ext = this.avatar.startsWith("a_") ? "gif" : options?.extension ?? "png";
|
|
2522
|
+
const size = options?.size ? `?size=${options.size}` : "";
|
|
2523
|
+
return `${CDN_URL}/avatars/${this.id}/${this.avatar}.${ext}${size}`;
|
|
2524
|
+
}
|
|
2525
|
+
/** Get the avatar URL, or the default avatar if none set (Fluxer: fluxerstatic.com). */
|
|
2526
|
+
displayAvatarURL(options) {
|
|
2527
|
+
return this.avatarURL(options) ?? cdnDefaultAvatarURL(this.id);
|
|
2528
|
+
}
|
|
2529
|
+
/**
|
|
2530
|
+
* Get the URL for this user's banner.
|
|
2531
|
+
* Returns null if the user has no banner (only available when fetched from profile/member context).
|
|
2532
|
+
*/
|
|
2533
|
+
bannerURL(options) {
|
|
2534
|
+
if (!this.banner) return null;
|
|
2535
|
+
const ext = this.banner.startsWith("a_") ? "gif" : options?.extension ?? "png";
|
|
2536
|
+
const size = options?.size ? `?size=${options.size}` : "";
|
|
2537
|
+
return `${CDN_URL}/banners/${this.id}/${this.banner}.${ext}${size}`;
|
|
2538
|
+
}
|
|
2539
|
+
/** Returns a mention string (e.g. `<@123456>`). */
|
|
2540
|
+
toString() {
|
|
2541
|
+
return `<@${this.id}>`;
|
|
2542
|
+
}
|
|
2543
|
+
/**
|
|
2544
|
+
* Create or get a DM channel with this user.
|
|
2545
|
+
* Returns the DM channel; use {@link DMChannel.send} to send messages.
|
|
2546
|
+
*/
|
|
2547
|
+
async createDM() {
|
|
2548
|
+
const data = await this.client.rest.post(Routes16.userMeChannels(), {
|
|
2549
|
+
body: { recipient_id: this.id },
|
|
2550
|
+
auth: true
|
|
2551
|
+
});
|
|
2552
|
+
return new DMChannel(this.client, data);
|
|
2553
|
+
}
|
|
2554
|
+
/**
|
|
2555
|
+
* Send a DM to this user.
|
|
2556
|
+
* Convenience method that creates the DM channel and sends the message.
|
|
2557
|
+
*/
|
|
2558
|
+
async send(options) {
|
|
2559
|
+
const dm = await this.createDM();
|
|
2560
|
+
return dm.send(options);
|
|
2561
|
+
}
|
|
2562
|
+
};
|
|
2563
|
+
|
|
2564
|
+
// src/client/ClientUser.ts
|
|
2565
|
+
import { Routes as Routes17 } from "@fluxerjs/types";
|
|
2566
|
+
var ClientUser = class extends User {
|
|
2567
|
+
constructor(client, data) {
|
|
2568
|
+
super(client, { ...data });
|
|
2569
|
+
}
|
|
2570
|
+
/**
|
|
2571
|
+
* Fetch guilds the bot is a member of.
|
|
2572
|
+
* @returns Array of Guild objects (cached in client.guilds)
|
|
2573
|
+
*/
|
|
2574
|
+
async fetchGuilds() {
|
|
2575
|
+
const data = await this.client.rest.get(
|
|
2576
|
+
Routes17.currentUserGuilds()
|
|
2577
|
+
);
|
|
2578
|
+
const list = Array.isArray(data) ? data : data?.guilds ?? [];
|
|
2579
|
+
const guilds = [];
|
|
2580
|
+
for (const g of list) {
|
|
2581
|
+
const guild = new Guild(this.client, g);
|
|
2582
|
+
this.client.guilds.set(guild.id, guild);
|
|
2583
|
+
guilds.push(guild);
|
|
2584
|
+
}
|
|
2585
|
+
return guilds;
|
|
2586
|
+
}
|
|
2587
|
+
/**
|
|
2588
|
+
* Leave a guild. Requires the bot to be a member.
|
|
2589
|
+
* @param guildId - The guild ID to leave
|
|
2590
|
+
*/
|
|
2591
|
+
async leaveGuild(guildId) {
|
|
2592
|
+
await this.client.rest.delete(Routes17.leaveGuild(guildId), { auth: true });
|
|
2593
|
+
this.client.guilds.delete(guildId);
|
|
2594
|
+
}
|
|
2595
|
+
};
|
|
2596
|
+
|
|
230
2597
|
// src/client/Client.ts
|
|
231
2598
|
import {
|
|
232
|
-
emitDeprecationWarning as
|
|
2599
|
+
emitDeprecationWarning as emitDeprecationWarning3,
|
|
233
2600
|
formatEmoji,
|
|
234
2601
|
getUnicodeFromShortcode,
|
|
235
2602
|
parseEmoji
|
|
236
2603
|
} from "@fluxerjs/util";
|
|
237
2604
|
|
|
238
2605
|
// src/client/UsersManager.ts
|
|
239
|
-
import { Collection as
|
|
240
|
-
import { Routes as
|
|
241
|
-
var UsersManager = class extends
|
|
2606
|
+
import { Collection as Collection9 } from "@fluxerjs/collection";
|
|
2607
|
+
import { Routes as Routes18 } from "@fluxerjs/types";
|
|
2608
|
+
var UsersManager = class extends Collection9 {
|
|
242
2609
|
constructor(client) {
|
|
243
2610
|
super();
|
|
244
2611
|
this.client = client;
|
|
2612
|
+
this.maxSize = client.options?.cache?.users ?? 0;
|
|
2613
|
+
}
|
|
2614
|
+
maxSize;
|
|
2615
|
+
set(key, value) {
|
|
2616
|
+
if (this.maxSize > 0 && this.size >= this.maxSize && !this.has(key)) {
|
|
2617
|
+
const firstKey = this.keys().next().value;
|
|
2618
|
+
if (firstKey !== void 0) this.delete(firstKey);
|
|
2619
|
+
}
|
|
2620
|
+
return super.set(key, value);
|
|
245
2621
|
}
|
|
246
2622
|
/**
|
|
247
2623
|
* Fetch a user by ID from the API.
|
|
@@ -254,7 +2630,7 @@ var UsersManager = class extends Collection3 {
|
|
|
254
2630
|
* console.log(user.username);
|
|
255
2631
|
*/
|
|
256
2632
|
async fetch(userId) {
|
|
257
|
-
const data = await this.client.rest.get(
|
|
2633
|
+
const data = await this.client.rest.get(Routes18.user(userId));
|
|
258
2634
|
return this.client.getOrCreateUser(data);
|
|
259
2635
|
}
|
|
260
2636
|
/**
|
|
@@ -274,10 +2650,10 @@ var UsersManager = class extends Collection3 {
|
|
|
274
2650
|
async fetchWithProfile(userId, options) {
|
|
275
2651
|
const guildId = options?.guildId ?? void 0;
|
|
276
2652
|
const [userData, globalProfileData, serverProfileData, memberData] = await Promise.all([
|
|
277
|
-
this.client.rest.get(
|
|
278
|
-
this.client.rest.get(
|
|
279
|
-
guildId ? this.client.rest.get(
|
|
280
|
-
guildId ? this.client.rest.get(
|
|
2653
|
+
this.client.rest.get(Routes18.user(userId)),
|
|
2654
|
+
this.client.rest.get(Routes18.userProfile(userId)).catch(() => null),
|
|
2655
|
+
guildId ? this.client.rest.get(Routes18.userProfile(userId, guildId)).catch(() => null) : Promise.resolve(null),
|
|
2656
|
+
guildId ? this.client.rest.get(Routes18.guildMember(guildId, userId)).catch(() => null) : Promise.resolve(null)
|
|
281
2657
|
]);
|
|
282
2658
|
const user = this.client.getOrCreateUser(userData);
|
|
283
2659
|
const globalProfile = globalProfileData && typeof globalProfileData === "object" ? globalProfileData : null;
|
|
@@ -301,25 +2677,89 @@ var UsersManager = class extends Collection3 {
|
|
|
301
2677
|
}
|
|
302
2678
|
};
|
|
303
2679
|
|
|
2680
|
+
// src/util/guildUtils.ts
|
|
2681
|
+
function normalizeGuildPayload(raw) {
|
|
2682
|
+
if (!raw || typeof raw !== "object") {
|
|
2683
|
+
return null;
|
|
2684
|
+
}
|
|
2685
|
+
if ("properties" in raw && raw.properties != null && typeof raw.properties === "object") {
|
|
2686
|
+
const r = raw;
|
|
2687
|
+
return {
|
|
2688
|
+
...r.properties,
|
|
2689
|
+
roles: r.roles
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2692
|
+
return raw;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
// src/structures/MessageReaction.ts
|
|
2696
|
+
import { Routes as Routes19 } from "@fluxerjs/types";
|
|
2697
|
+
import { FluxerAPIError as FluxerAPIError4, RateLimitError as RateLimitError3 } from "@fluxerjs/rest";
|
|
2698
|
+
var MessageReaction = class extends Base {
|
|
2699
|
+
client;
|
|
2700
|
+
messageId;
|
|
2701
|
+
channelId;
|
|
2702
|
+
guildId;
|
|
2703
|
+
emoji;
|
|
2704
|
+
/** Raw gateway payload for low-level access. */
|
|
2705
|
+
_data;
|
|
2706
|
+
constructor(client, data) {
|
|
2707
|
+
super();
|
|
2708
|
+
this.client = client;
|
|
2709
|
+
this._data = data;
|
|
2710
|
+
this.messageId = data.message_id;
|
|
2711
|
+
this.channelId = data.channel_id;
|
|
2712
|
+
this.guildId = data.guild_id ?? null;
|
|
2713
|
+
this.emoji = data.emoji;
|
|
2714
|
+
}
|
|
2715
|
+
/** Emoji as a string: unicode or "name:id" for custom. */
|
|
2716
|
+
get emojiIdentifier() {
|
|
2717
|
+
return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
|
|
2718
|
+
}
|
|
2719
|
+
/** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
|
|
2720
|
+
get guild() {
|
|
2721
|
+
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
2722
|
+
}
|
|
2723
|
+
/**
|
|
2724
|
+
* Fetch the message this reaction belongs to.
|
|
2725
|
+
* Use when you need to edit, delete, or otherwise interact with the message.
|
|
2726
|
+
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
2727
|
+
*/
|
|
2728
|
+
async fetchMessage() {
|
|
2729
|
+
try {
|
|
2730
|
+
const data = await this.client.rest.get(
|
|
2731
|
+
Routes19.channelMessage(this.channelId, this.messageId)
|
|
2732
|
+
);
|
|
2733
|
+
return new Message(this.client, data);
|
|
2734
|
+
} catch (err) {
|
|
2735
|
+
if (err instanceof RateLimitError3) throw err;
|
|
2736
|
+
if (err instanceof FluxerAPIError4 && err.statusCode === 404) {
|
|
2737
|
+
throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
|
|
2738
|
+
code: ErrorCodes.MessageNotFound,
|
|
2739
|
+
cause: err
|
|
2740
|
+
});
|
|
2741
|
+
}
|
|
2742
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
};
|
|
2746
|
+
|
|
304
2747
|
// src/client/EventHandlerRegistry.ts
|
|
305
2748
|
var handlers = /* @__PURE__ */ new Map();
|
|
306
2749
|
handlers.set("MESSAGE_CREATE", async (client, d) => {
|
|
307
|
-
const { Message: Message2 } = await import("./Message-QNWAPT55.mjs");
|
|
308
|
-
const { GuildMember: GuildMember2 } = await import("./GuildMember-FSGDPKUU.mjs");
|
|
309
2750
|
const data = d;
|
|
310
2751
|
if (data.guild_id && data.member && data.author) {
|
|
311
2752
|
const guild = client.guilds.get(data.guild_id);
|
|
312
2753
|
if (guild) {
|
|
313
2754
|
const memberData = { ...data.member, user: data.author, guild_id: data.guild_id };
|
|
314
|
-
const member = new
|
|
2755
|
+
const member = new GuildMember(client, memberData, guild);
|
|
315
2756
|
guild.members.set(member.id, member);
|
|
316
2757
|
}
|
|
317
2758
|
}
|
|
318
|
-
client.emit(Events.MessageCreate, new
|
|
2759
|
+
client.emit(Events.MessageCreate, new Message(client, data));
|
|
319
2760
|
});
|
|
320
2761
|
handlers.set("MESSAGE_UPDATE", async (client, d) => {
|
|
321
|
-
|
|
322
|
-
client.emit(Events.MessageUpdate, null, new Message2(client, d));
|
|
2762
|
+
client.emit(Events.MessageUpdate, null, new Message(client, d));
|
|
323
2763
|
});
|
|
324
2764
|
handlers.set("MESSAGE_DELETE", async (client, d) => {
|
|
325
2765
|
const data = d;
|
|
@@ -334,41 +2774,23 @@ handlers.set("MESSAGE_DELETE", async (client, d) => {
|
|
|
334
2774
|
});
|
|
335
2775
|
handlers.set("MESSAGE_REACTION_ADD", async (client, d) => {
|
|
336
2776
|
const data = d;
|
|
337
|
-
const
|
|
338
|
-
const reaction = new MessageReaction2(client, data);
|
|
2777
|
+
const reaction = new MessageReaction(client, data);
|
|
339
2778
|
const user = client.getOrCreateUser({
|
|
340
2779
|
id: data.user_id,
|
|
341
2780
|
username: "Unknown",
|
|
342
2781
|
discriminator: "0"
|
|
343
2782
|
});
|
|
344
|
-
client.emit(
|
|
345
|
-
Events.MessageReactionAdd,
|
|
346
|
-
reaction,
|
|
347
|
-
user,
|
|
348
|
-
reaction.messageId,
|
|
349
|
-
reaction.channelId,
|
|
350
|
-
reaction.emoji,
|
|
351
|
-
user.id
|
|
352
|
-
);
|
|
2783
|
+
client.emit(Events.MessageReactionAdd, reaction, user);
|
|
353
2784
|
});
|
|
354
2785
|
handlers.set("MESSAGE_REACTION_REMOVE", async (client, d) => {
|
|
355
2786
|
const data = d;
|
|
356
|
-
const
|
|
357
|
-
const reaction = new MessageReaction2(client, data);
|
|
2787
|
+
const reaction = new MessageReaction(client, data);
|
|
358
2788
|
const user = client.getOrCreateUser({
|
|
359
2789
|
id: data.user_id,
|
|
360
2790
|
username: "Unknown",
|
|
361
2791
|
discriminator: "0"
|
|
362
2792
|
});
|
|
363
|
-
client.emit(
|
|
364
|
-
Events.MessageReactionRemove,
|
|
365
|
-
reaction,
|
|
366
|
-
user,
|
|
367
|
-
reaction.messageId,
|
|
368
|
-
reaction.channelId,
|
|
369
|
-
reaction.emoji,
|
|
370
|
-
user.id
|
|
371
|
-
);
|
|
2793
|
+
client.emit(Events.MessageReactionRemove, reaction, user);
|
|
372
2794
|
});
|
|
373
2795
|
handlers.set("MESSAGE_REACTION_REMOVE_ALL", async (client, d) => {
|
|
374
2796
|
client.emit(Events.MessageReactionRemoveAll, d);
|
|
@@ -380,22 +2802,22 @@ handlers.set("MESSAGE_REACTION_REMOVE_EMOJI", async (client, d) => {
|
|
|
380
2802
|
);
|
|
381
2803
|
});
|
|
382
2804
|
handlers.set("GUILD_CREATE", async (client, d) => {
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
const
|
|
386
|
-
const raw = d;
|
|
387
|
-
const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
|
|
388
|
-
const guild = new Guild2(client, guildData);
|
|
2805
|
+
const guildData = normalizeGuildPayload(d);
|
|
2806
|
+
if (!guildData) return;
|
|
2807
|
+
const guild = new Guild(client, guildData);
|
|
389
2808
|
client.guilds.set(guild.id, guild);
|
|
390
2809
|
const g = d;
|
|
391
2810
|
for (const ch of g.channels ?? []) {
|
|
392
|
-
const channel =
|
|
393
|
-
if (channel)
|
|
2811
|
+
const channel = Channel.from(client, ch);
|
|
2812
|
+
if (channel) {
|
|
2813
|
+
client.channels.set(channel.id, channel);
|
|
2814
|
+
guild.channels.set(channel.id, channel);
|
|
2815
|
+
}
|
|
394
2816
|
}
|
|
395
2817
|
for (const m of g.members ?? []) {
|
|
396
2818
|
if (m?.user?.id) {
|
|
397
2819
|
const memberData = { ...m, guild_id: guild.id };
|
|
398
|
-
const member = new
|
|
2820
|
+
const member = new GuildMember(client, memberData, guild);
|
|
399
2821
|
guild.members.set(member.id, member);
|
|
400
2822
|
}
|
|
401
2823
|
}
|
|
@@ -405,11 +2827,10 @@ handlers.set("GUILD_CREATE", async (client, d) => {
|
|
|
405
2827
|
}
|
|
406
2828
|
});
|
|
407
2829
|
handlers.set("GUILD_UPDATE", async (client, d) => {
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
|
|
2830
|
+
const guildData = normalizeGuildPayload(d);
|
|
2831
|
+
if (!guildData) return;
|
|
411
2832
|
const old = client.guilds.get(guildData.id);
|
|
412
|
-
const updated = new
|
|
2833
|
+
const updated = new Guild(client, guildData);
|
|
413
2834
|
client.guilds.set(updated.id, updated);
|
|
414
2835
|
client.emit(Events.GuildUpdate, old ?? updated, updated);
|
|
415
2836
|
});
|
|
@@ -422,20 +2843,26 @@ handlers.set("GUILD_DELETE", async (client, d) => {
|
|
|
422
2843
|
}
|
|
423
2844
|
});
|
|
424
2845
|
handlers.set("CHANNEL_CREATE", async (client, d) => {
|
|
425
|
-
const
|
|
426
|
-
const ch = Channel2.from(client, d);
|
|
2846
|
+
const ch = Channel.from(client, d);
|
|
427
2847
|
if (ch) {
|
|
428
2848
|
client.channels.set(ch.id, ch);
|
|
2849
|
+
if ("guildId" in ch && ch.guildId) {
|
|
2850
|
+
const guild = client.guilds.get(ch.guildId);
|
|
2851
|
+
if (guild) guild.channels.set(ch.id, ch);
|
|
2852
|
+
}
|
|
429
2853
|
client.emit(Events.ChannelCreate, ch);
|
|
430
2854
|
}
|
|
431
2855
|
});
|
|
432
2856
|
handlers.set("CHANNEL_UPDATE", async (client, d) => {
|
|
433
|
-
const { Channel: Channel2 } = await import("./Channel-JFQXR7SZ.mjs");
|
|
434
2857
|
const ch = d;
|
|
435
2858
|
const oldCh = client.channels.get(ch.id);
|
|
436
|
-
const newCh =
|
|
2859
|
+
const newCh = Channel.from(client, ch);
|
|
437
2860
|
if (newCh) {
|
|
438
2861
|
client.channels.set(newCh.id, newCh);
|
|
2862
|
+
if ("guildId" in newCh && newCh.guildId) {
|
|
2863
|
+
const guild = client.guilds.get(newCh.guildId);
|
|
2864
|
+
if (guild) guild.channels.set(newCh.id, newCh);
|
|
2865
|
+
}
|
|
439
2866
|
client.emit(Events.ChannelUpdate, oldCh ?? newCh, newCh);
|
|
440
2867
|
}
|
|
441
2868
|
});
|
|
@@ -443,27 +2870,29 @@ handlers.set("CHANNEL_DELETE", async (client, d) => {
|
|
|
443
2870
|
const ch = d;
|
|
444
2871
|
const channel = client.channels.get(ch.id);
|
|
445
2872
|
if (channel) {
|
|
2873
|
+
if ("guildId" in channel && channel.guildId) {
|
|
2874
|
+
const guild = client.guilds.get(channel.guildId);
|
|
2875
|
+
if (guild) guild.channels.delete(channel.id);
|
|
2876
|
+
}
|
|
446
2877
|
client.channels.delete(ch.id);
|
|
447
2878
|
client.emit(Events.ChannelDelete, channel);
|
|
448
2879
|
}
|
|
449
2880
|
});
|
|
450
2881
|
handlers.set("GUILD_MEMBER_ADD", async (client, d) => {
|
|
451
|
-
const { GuildMember: GuildMember2 } = await import("./GuildMember-FSGDPKUU.mjs");
|
|
452
2882
|
const data = d;
|
|
453
2883
|
const guild = client.guilds.get(data.guild_id);
|
|
454
2884
|
if (guild) {
|
|
455
|
-
const member = new
|
|
2885
|
+
const member = new GuildMember(client, data, guild);
|
|
456
2886
|
guild.members.set(member.id, member);
|
|
457
2887
|
client.emit(Events.GuildMemberAdd, member);
|
|
458
2888
|
}
|
|
459
2889
|
});
|
|
460
2890
|
handlers.set("GUILD_MEMBER_UPDATE", async (client, d) => {
|
|
461
|
-
const { GuildMember: GuildMember2 } = await import("./GuildMember-FSGDPKUU.mjs");
|
|
462
2891
|
const data = d;
|
|
463
2892
|
const guild = client.guilds.get(data.guild_id);
|
|
464
2893
|
if (guild) {
|
|
465
2894
|
const oldM = guild.members.get(data.user.id);
|
|
466
|
-
const newM = new
|
|
2895
|
+
const newM = new GuildMember(client, data, guild);
|
|
467
2896
|
guild.members.set(newM.id, newM);
|
|
468
2897
|
client.emit(Events.GuildMemberUpdate, oldM ?? newM, newM);
|
|
469
2898
|
}
|
|
@@ -472,7 +2901,6 @@ handlers.set("GUILD_MEMBER_REMOVE", async (client, d) => {
|
|
|
472
2901
|
const data = d;
|
|
473
2902
|
const guild = client.guilds.get(data.guild_id);
|
|
474
2903
|
if (!guild || !data.user?.id) return;
|
|
475
|
-
const { GuildMember: GuildMember2 } = await import("./GuildMember-FSGDPKUU.mjs");
|
|
476
2904
|
let member = guild.members.get(data.user.id);
|
|
477
2905
|
if (member) {
|
|
478
2906
|
guild.members.delete(data.user.id);
|
|
@@ -489,7 +2917,7 @@ handlers.set("GUILD_MEMBER_REMOVE", async (client, d) => {
|
|
|
489
2917
|
joined_at: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
490
2918
|
nick: null
|
|
491
2919
|
};
|
|
492
|
-
member = new
|
|
2920
|
+
member = new GuildMember(client, memberData, guild);
|
|
493
2921
|
}
|
|
494
2922
|
client.emit(Events.GuildMemberRemove, member);
|
|
495
2923
|
});
|
|
@@ -507,17 +2935,32 @@ handlers.set("MESSAGE_DELETE_BULK", async (client, d) => {
|
|
|
507
2935
|
});
|
|
508
2936
|
handlers.set("GUILD_BAN_ADD", async (client, d) => {
|
|
509
2937
|
const data = d;
|
|
510
|
-
const
|
|
511
|
-
|
|
2938
|
+
const banData = {
|
|
2939
|
+
user: data.user,
|
|
2940
|
+
reason: data.reason ?? null,
|
|
2941
|
+
guild_id: data.guild_id
|
|
2942
|
+
};
|
|
2943
|
+
const ban = new GuildBan(client, banData, data.guild_id);
|
|
512
2944
|
client.emit(Events.GuildBanAdd, ban);
|
|
513
2945
|
});
|
|
514
2946
|
handlers.set("GUILD_BAN_REMOVE", async (client, d) => {
|
|
515
2947
|
const data = d;
|
|
516
|
-
const {
|
|
517
|
-
const ban = new GuildBan2(client, { ...data, reason: null }, data.guild_id);
|
|
2948
|
+
const ban = new GuildBan(client, { ...data, reason: null }, data.guild_id);
|
|
518
2949
|
client.emit(Events.GuildBanRemove, ban);
|
|
519
2950
|
});
|
|
520
2951
|
handlers.set("GUILD_EMOJIS_UPDATE", async (client, d) => {
|
|
2952
|
+
const data = d;
|
|
2953
|
+
const guild = client.guilds.get(data.guild_id);
|
|
2954
|
+
if (guild) {
|
|
2955
|
+
guild.emojis.clear();
|
|
2956
|
+
for (const e of data.emojis ?? []) {
|
|
2957
|
+
if (!e.id || e.name == null) continue;
|
|
2958
|
+
guild.emojis.set(
|
|
2959
|
+
e.id,
|
|
2960
|
+
new GuildEmoji(client, { id: e.id, name: e.name, animated: e.animated ?? false, guild_id: guild.id }, guild.id)
|
|
2961
|
+
);
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
521
2964
|
client.emit(Events.GuildEmojisUpdate, d);
|
|
522
2965
|
});
|
|
523
2966
|
handlers.set("GUILD_STICKERS_UPDATE", async (client, d) => {
|
|
@@ -530,8 +2973,7 @@ handlers.set("GUILD_ROLE_CREATE", async (client, d) => {
|
|
|
530
2973
|
const data = d;
|
|
531
2974
|
const guild = client.guilds.get(data.guild_id);
|
|
532
2975
|
if (guild) {
|
|
533
|
-
|
|
534
|
-
guild.roles.set(data.role.id, new Role2(client, data.role, guild.id));
|
|
2976
|
+
guild.roles.set(data.role.id, new Role(client, data.role, guild.id));
|
|
535
2977
|
}
|
|
536
2978
|
client.emit(Events.GuildRoleCreate, data);
|
|
537
2979
|
});
|
|
@@ -543,8 +2985,7 @@ handlers.set("GUILD_ROLE_UPDATE", async (client, d) => {
|
|
|
543
2985
|
if (existing) {
|
|
544
2986
|
existing._patch(data.role);
|
|
545
2987
|
} else {
|
|
546
|
-
|
|
547
|
-
guild.roles.set(data.role.id, new Role2(client, data.role, guild.id));
|
|
2988
|
+
guild.roles.set(data.role.id, new Role(client, data.role, guild.id));
|
|
548
2989
|
}
|
|
549
2990
|
}
|
|
550
2991
|
client.emit(Events.GuildRoleUpdate, data);
|
|
@@ -569,8 +3010,7 @@ handlers.set("CHANNEL_PINS_UPDATE", async (client, d) => {
|
|
|
569
3010
|
});
|
|
570
3011
|
handlers.set("INVITE_CREATE", async (client, d) => {
|
|
571
3012
|
const data = d;
|
|
572
|
-
|
|
573
|
-
client.emit(Events.InviteCreate, new Invite2(client, data));
|
|
3013
|
+
client.emit(Events.InviteCreate, new Invite(client, data));
|
|
574
3014
|
});
|
|
575
3015
|
handlers.set("INVITE_DELETE", async (client, d) => {
|
|
576
3016
|
client.emit(Events.InviteDelete, d);
|
|
@@ -608,7 +3048,7 @@ function createEventMethods(client) {
|
|
|
608
3048
|
}
|
|
609
3049
|
return result;
|
|
610
3050
|
}
|
|
611
|
-
var Client = class extends
|
|
3051
|
+
var Client = class extends EventEmitter3 {
|
|
612
3052
|
/** @param options - Token, REST config, WebSocket, presence, etc. */
|
|
613
3053
|
constructor(options = {}) {
|
|
614
3054
|
super();
|
|
@@ -669,11 +3109,11 @@ var Client = class extends EventEmitter {
|
|
|
669
3109
|
}
|
|
670
3110
|
return formatEmoji(parsed);
|
|
671
3111
|
}
|
|
672
|
-
if (!/^\w+$/.test(parsed.name)) return
|
|
3112
|
+
if (!/^\w+$/.test(parsed.name)) return parsed.name;
|
|
673
3113
|
const unicodeFromShortcode = getUnicodeFromShortcode(parsed.name);
|
|
674
|
-
if (unicodeFromShortcode) return
|
|
3114
|
+
if (unicodeFromShortcode) return unicodeFromShortcode;
|
|
675
3115
|
if (guildId) {
|
|
676
|
-
const emojis = await this.rest.get(
|
|
3116
|
+
const emojis = await this.rest.get(Routes20.guildEmojis(guildId));
|
|
677
3117
|
const list = Array.isArray(emojis) ? emojis : Object.values(emojis ?? {});
|
|
678
3118
|
const found = list.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
679
3119
|
if (found) return formatEmoji({ ...parsed, id: found.id, animated: found.animated });
|
|
@@ -686,7 +3126,7 @@ var Client = class extends EventEmitter {
|
|
|
686
3126
|
`Custom emoji ":${parsed.name}:" requires guild context. Use message.react() in a guild channel, or pass guildId to client.resolveEmoji().`
|
|
687
3127
|
);
|
|
688
3128
|
}
|
|
689
|
-
return
|
|
3129
|
+
return parsed.name;
|
|
690
3130
|
}
|
|
691
3131
|
/**
|
|
692
3132
|
* Asserts that a custom emoji (by id) belongs to the given guild.
|
|
@@ -694,7 +3134,7 @@ var Client = class extends EventEmitter {
|
|
|
694
3134
|
* @throws FluxerError with EMOJI_NOT_IN_GUILD if the emoji is not in the guild
|
|
695
3135
|
*/
|
|
696
3136
|
async assertEmojiInGuild(emojiId, guildId) {
|
|
697
|
-
const emojis = await this.rest.get(
|
|
3137
|
+
const emojis = await this.rest.get(Routes20.guildEmojis(guildId));
|
|
698
3138
|
const list = Array.isArray(emojis) ? emojis : Object.values(emojis ?? {});
|
|
699
3139
|
const found = list.some((e) => e.id === emojiId);
|
|
700
3140
|
if (!found) {
|
|
@@ -708,7 +3148,7 @@ var Client = class extends EventEmitter {
|
|
|
708
3148
|
* Does not require authentication.
|
|
709
3149
|
*/
|
|
710
3150
|
async fetchInstance() {
|
|
711
|
-
return this.rest.get(
|
|
3151
|
+
return this.rest.get(Routes20.instance(), { auth: false });
|
|
712
3152
|
}
|
|
713
3153
|
/**
|
|
714
3154
|
* Fetch a message by channel and message ID. Use when you have IDs (e.g. from a DB).
|
|
@@ -716,15 +3156,15 @@ var Client = class extends EventEmitter {
|
|
|
716
3156
|
* @param messageId - Snowflake of the message
|
|
717
3157
|
* @returns The message
|
|
718
3158
|
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
719
|
-
* @deprecated Use channel.messages.fetch(messageId). For IDs-only: (await client.channels.
|
|
3159
|
+
* @deprecated Use channel.messages.fetch(messageId). For IDs-only: (await client.channels.resolve(channelId))?.messages?.fetch(messageId)
|
|
720
3160
|
* @example
|
|
721
|
-
* const channel = await client.channels.
|
|
3161
|
+
* const channel = await client.channels.resolve(channelId);
|
|
722
3162
|
* const message = await channel?.messages?.fetch(messageId);
|
|
723
3163
|
*/
|
|
724
3164
|
async fetchMessage(channelId, messageId) {
|
|
725
|
-
|
|
3165
|
+
emitDeprecationWarning3(
|
|
726
3166
|
"Client.fetchMessage()",
|
|
727
|
-
"Use channel.messages.fetch(messageId). For IDs-only: (await client.channels.
|
|
3167
|
+
"Use channel.messages.fetch(messageId). For IDs-only: (await client.channels.resolve(channelId))?.messages?.fetch(messageId)"
|
|
728
3168
|
);
|
|
729
3169
|
return this.channels.fetchMessage(channelId, messageId);
|
|
730
3170
|
}
|
|
@@ -785,12 +3225,14 @@ var Client = class extends EventEmitter {
|
|
|
785
3225
|
this.rest.setToken(token);
|
|
786
3226
|
let intents = this.options.intents ?? 0;
|
|
787
3227
|
if (intents !== 0) {
|
|
788
|
-
if (
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
3228
|
+
if (!this.options.suppressIntentWarning) {
|
|
3229
|
+
if (typeof process !== "undefined" && process.emitWarning) {
|
|
3230
|
+
process.emitWarning("Fluxer does not support intents yet. Value has been set to 0.", {
|
|
3231
|
+
type: "FluxerIntents"
|
|
3232
|
+
});
|
|
3233
|
+
} else {
|
|
3234
|
+
console.warn("Fluxer does not support intents yet. Value has been set to 0.");
|
|
3235
|
+
}
|
|
794
3236
|
}
|
|
795
3237
|
intents = 0;
|
|
796
3238
|
}
|
|
@@ -812,21 +3254,19 @@ var Client = class extends EventEmitter {
|
|
|
812
3254
|
async ({
|
|
813
3255
|
data
|
|
814
3256
|
}) => {
|
|
815
|
-
|
|
816
|
-
const { Guild: Guild2 } = await import("./Guild-3PLQFT2I.mjs");
|
|
817
|
-
const { Channel: Channel2 } = await import("./Channel-JFQXR7SZ.mjs");
|
|
818
|
-
this.user = new ClientUser2(this, data.user);
|
|
3257
|
+
this.user = new ClientUser(this, data.user);
|
|
819
3258
|
for (const g of data.guilds ?? []) {
|
|
820
|
-
const guildData = g
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
} : g;
|
|
824
|
-
const guild = new Guild2(this, guildData);
|
|
3259
|
+
const guildData = normalizeGuildPayload(g);
|
|
3260
|
+
if (!guildData) continue;
|
|
3261
|
+
const guild = new Guild(this, guildData);
|
|
825
3262
|
this.guilds.set(guild.id, guild);
|
|
826
3263
|
const withCh = g;
|
|
827
3264
|
for (const ch of withCh.channels ?? []) {
|
|
828
|
-
const channel =
|
|
829
|
-
if (channel)
|
|
3265
|
+
const channel = Channel.from(this, ch);
|
|
3266
|
+
if (channel) {
|
|
3267
|
+
this.channels.set(channel.id, channel);
|
|
3268
|
+
guild.channels.set(channel.id, channel);
|
|
3269
|
+
}
|
|
830
3270
|
}
|
|
831
3271
|
if (withCh.voice_states?.length) {
|
|
832
3272
|
this.emit(Events.VoiceStatesSync, {
|
|
@@ -861,19 +3301,33 @@ var Client = class extends EventEmitter {
|
|
|
861
3301
|
isReady() {
|
|
862
3302
|
return this.readyAt !== null && this.user !== null;
|
|
863
3303
|
}
|
|
3304
|
+
/**
|
|
3305
|
+
* Throws if the client is not ready. Use before accessing client.user or other post-ready state.
|
|
3306
|
+
* @throws FluxerError with CLIENT_NOT_READY if client has not received Ready yet
|
|
3307
|
+
*/
|
|
3308
|
+
assertReady() {
|
|
3309
|
+
if (!this.isReady()) {
|
|
3310
|
+
throw new FluxerError(
|
|
3311
|
+
"Client is not ready yet. Wait for the Ready event before accessing client.user.",
|
|
3312
|
+
{
|
|
3313
|
+
code: ErrorCodes.ClientNotReady
|
|
3314
|
+
}
|
|
3315
|
+
);
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
864
3318
|
static get Routes() {
|
|
865
|
-
return
|
|
3319
|
+
return Routes20;
|
|
866
3320
|
}
|
|
867
3321
|
};
|
|
868
3322
|
|
|
869
3323
|
// src/index.ts
|
|
870
|
-
import { EmbedBuilder, MessagePayload, AttachmentBuilder } from "@fluxerjs/builders";
|
|
871
|
-
import { Routes as
|
|
872
|
-
import { resolveTenorToImageUrl } from "@fluxerjs/util";
|
|
3324
|
+
import { EmbedBuilder as EmbedBuilder3, MessagePayload, AttachmentBuilder } from "@fluxerjs/builders";
|
|
3325
|
+
import { Routes as Routes21, GatewayOpcodes, MessageAttachmentFlags } from "@fluxerjs/types";
|
|
3326
|
+
import { resolveTenorToImageUrl, parseUserMention, parsePrefixCommand } from "@fluxerjs/util";
|
|
873
3327
|
import {
|
|
874
3328
|
PermissionsBitField,
|
|
875
|
-
PermissionFlags,
|
|
876
|
-
resolvePermissionsToBitfield,
|
|
3329
|
+
PermissionFlags as PermissionFlags2,
|
|
3330
|
+
resolvePermissionsToBitfield as resolvePermissionsToBitfield3,
|
|
877
3331
|
UserFlagsBitField,
|
|
878
3332
|
UserFlagsBits
|
|
879
3333
|
} from "@fluxerjs/util";
|
|
@@ -887,7 +3341,7 @@ export {
|
|
|
887
3341
|
Client,
|
|
888
3342
|
ClientUser,
|
|
889
3343
|
DMChannel,
|
|
890
|
-
EmbedBuilder,
|
|
3344
|
+
EmbedBuilder3 as EmbedBuilder,
|
|
891
3345
|
ErrorCodes,
|
|
892
3346
|
Events,
|
|
893
3347
|
FluxerError,
|
|
@@ -898,6 +3352,7 @@ export {
|
|
|
898
3352
|
GuildEmoji,
|
|
899
3353
|
GuildMember,
|
|
900
3354
|
GuildMemberManager,
|
|
3355
|
+
GuildMemberRoleManager,
|
|
901
3356
|
GuildSticker,
|
|
902
3357
|
Invite,
|
|
903
3358
|
LinkChannel,
|
|
@@ -907,11 +3362,11 @@ export {
|
|
|
907
3362
|
MessageManager,
|
|
908
3363
|
MessagePayload,
|
|
909
3364
|
MessageReaction,
|
|
910
|
-
PermissionFlags,
|
|
3365
|
+
PermissionFlags2 as PermissionFlags,
|
|
911
3366
|
PermissionsBitField,
|
|
912
3367
|
ReactionCollector,
|
|
913
3368
|
Role,
|
|
914
|
-
|
|
3369
|
+
Routes21 as Routes,
|
|
915
3370
|
STATIC_CDN_URL,
|
|
916
3371
|
TextChannel,
|
|
917
3372
|
User,
|
|
@@ -926,6 +3381,8 @@ export {
|
|
|
926
3381
|
cdnDisplayAvatarURL,
|
|
927
3382
|
cdnMemberAvatarURL,
|
|
928
3383
|
cdnMemberBannerURL,
|
|
929
|
-
|
|
3384
|
+
parsePrefixCommand,
|
|
3385
|
+
parseUserMention,
|
|
3386
|
+
resolvePermissionsToBitfield3 as resolvePermissionsToBitfield,
|
|
930
3387
|
resolveTenorToImageUrl
|
|
931
3388
|
};
|