revbot.js 0.0.13 → 0.0.15-build-test
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/chunk-35BYGFDX.js +25 -0
- package/dist/chunk-35BYGFDX.js.map +1 -0
- package/dist/chunk-3ANNOYXY.js +30 -0
- package/dist/chunk-3ANNOYXY.js.map +1 -0
- package/dist/chunk-3GLQHMWL.js +39 -0
- package/dist/chunk-3GLQHMWL.js.map +1 -0
- package/dist/chunk-43CUB3NP.js +30 -0
- package/dist/chunk-43CUB3NP.js.map +1 -0
- package/dist/chunk-55PAATU6.js +101 -0
- package/dist/chunk-55PAATU6.js.map +1 -0
- package/dist/chunk-5RK7FEID.js +47 -0
- package/dist/chunk-5RK7FEID.js.map +1 -0
- package/dist/chunk-6V6HPZ33.js +27 -0
- package/dist/chunk-6V6HPZ33.js.map +1 -0
- package/dist/chunk-6WJXGICC.js +25 -0
- package/dist/chunk-6WJXGICC.js.map +1 -0
- package/dist/chunk-7PA5MDKS.js +157 -0
- package/dist/chunk-7PA5MDKS.js.map +1 -0
- package/dist/chunk-7XUN3OQT.js +1 -0
- package/dist/chunk-7XUN3OQT.js.map +1 -0
- package/dist/chunk-AOKM5TCP.js +37 -0
- package/dist/chunk-AOKM5TCP.js.map +1 -0
- package/dist/chunk-BQS6ZLNY.js +80 -0
- package/dist/chunk-BQS6ZLNY.js.map +1 -0
- package/dist/chunk-CQ4AJZQD.js +51 -0
- package/dist/chunk-CQ4AJZQD.js.map +1 -0
- package/dist/chunk-DSM44DGO.js +156 -0
- package/dist/chunk-DSM44DGO.js.map +1 -0
- package/dist/chunk-E2P4PIDH.js +35 -0
- package/dist/chunk-E2P4PIDH.js.map +1 -0
- package/dist/chunk-EOZ7QHOH.js +151 -0
- package/dist/chunk-EOZ7QHOH.js.map +1 -0
- package/dist/chunk-FKNQEJE7.js +20 -0
- package/dist/chunk-FKNQEJE7.js.map +1 -0
- package/dist/chunk-G7DLVJKH.js +34 -0
- package/dist/chunk-G7DLVJKH.js.map +1 -0
- package/dist/chunk-GCIV7PRI.js +30 -0
- package/dist/chunk-GCIV7PRI.js.map +1 -0
- package/dist/chunk-GNQQG7EP.js +88 -0
- package/dist/chunk-GNQQG7EP.js.map +1 -0
- package/dist/chunk-H4SZEZP2.js +38 -0
- package/dist/chunk-H4SZEZP2.js.map +1 -0
- package/dist/chunk-HETUKFLM.js +7 -0
- package/dist/chunk-HETUKFLM.js.map +1 -0
- package/dist/chunk-HKLTWZSB.js +112 -0
- package/dist/chunk-HKLTWZSB.js.map +1 -0
- package/dist/chunk-ICANLKGX.js +97 -0
- package/dist/chunk-ICANLKGX.js.map +1 -0
- package/dist/chunk-J2RF7D67.js +105 -0
- package/dist/chunk-J2RF7D67.js.map +1 -0
- package/dist/chunk-K4VAG5ZU.js +16 -0
- package/dist/chunk-K4VAG5ZU.js.map +1 -0
- package/dist/chunk-LAL23AQK.js +105 -0
- package/dist/chunk-LAL23AQK.js.map +1 -0
- package/dist/chunk-LQUZ7Q7D.js +29 -0
- package/dist/chunk-LQUZ7Q7D.js.map +1 -0
- package/dist/chunk-LUDTY3LL.js +103 -0
- package/dist/chunk-LUDTY3LL.js.map +1 -0
- package/dist/chunk-LY7OFI25.js +26 -0
- package/dist/chunk-LY7OFI25.js.map +1 -0
- package/dist/chunk-MLKHJGSQ.js +68 -0
- package/dist/chunk-MLKHJGSQ.js.map +1 -0
- package/dist/chunk-MSJCRRXO.js +32 -0
- package/dist/chunk-MSJCRRXO.js.map +1 -0
- package/dist/chunk-O2IN5OZI.js +27 -0
- package/dist/chunk-O2IN5OZI.js.map +1 -0
- package/dist/chunk-OETI5C5L.js +30 -0
- package/dist/chunk-OETI5C5L.js.map +1 -0
- package/dist/chunk-OK227BBS.js +38 -0
- package/dist/chunk-OK227BBS.js.map +1 -0
- package/dist/chunk-R2PF552K.js +67 -0
- package/dist/chunk-R2PF552K.js.map +1 -0
- package/dist/chunk-RMACMP4R.js +26 -0
- package/dist/chunk-RMACMP4R.js.map +1 -0
- package/dist/chunk-SYXHGCHU.js +26 -0
- package/dist/chunk-SYXHGCHU.js.map +1 -0
- package/dist/chunk-VELIOWTX.js +25 -0
- package/dist/chunk-VELIOWTX.js.map +1 -0
- package/dist/chunk-VU3XNPDE.js +37 -0
- package/dist/chunk-VU3XNPDE.js.map +1 -0
- package/dist/chunk-W4XDXSOK.js +32 -0
- package/dist/chunk-W4XDXSOK.js.map +1 -0
- package/dist/chunk-WMWOEYVA.js +26 -0
- package/dist/chunk-WMWOEYVA.js.map +1 -0
- package/dist/chunk-X7VEORVS.js +43 -0
- package/dist/chunk-X7VEORVS.js.map +1 -0
- package/dist/chunk-XMS4UTPG.js +49 -0
- package/dist/chunk-XMS4UTPG.js.map +1 -0
- package/dist/chunk-XQEYCTYC.js +2601 -0
- package/dist/chunk-XQEYCTYC.js.map +1 -0
- package/dist/chunk-YLSAAPO4.js +79 -0
- package/dist/chunk-YLSAAPO4.js.map +1 -0
- package/dist/chunk-YXX4DJB3.js +27 -0
- package/dist/chunk-YXX4DJB3.js.map +1 -0
- package/dist/client/baseClient.cjs +799 -0
- package/dist/client/baseClient.cjs.map +1 -0
- package/dist/client/baseClient.d.cts +10 -0
- package/dist/client/baseClient.d.ts +10 -0
- package/dist/client/baseClient.js +18 -0
- package/dist/client/baseClient.js.map +1 -0
- package/dist/client/client.cjs +4286 -0
- package/dist/client/client.cjs.map +1 -0
- package/dist/client/client.d.cts +10 -0
- package/dist/client/client.d.ts +10 -0
- package/dist/client/client.js +53 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/events/bulkMessageDelete.cjs +104 -0
- package/dist/client/events/bulkMessageDelete.cjs.map +1 -0
- package/dist/client/events/bulkMessageDelete.d.cts +28 -0
- package/dist/client/events/bulkMessageDelete.d.ts +28 -0
- package/dist/client/events/bulkMessageDelete.js +11 -0
- package/dist/client/events/bulkMessageDelete.js.map +1 -0
- package/dist/client/events/channelCreate.cjs +136 -0
- package/dist/client/events/channelCreate.cjs.map +1 -0
- package/dist/client/events/channelCreate.d.cts +27 -0
- package/dist/client/events/channelCreate.d.ts +27 -0
- package/dist/client/events/channelCreate.js +11 -0
- package/dist/client/events/channelCreate.js.map +1 -0
- package/dist/client/events/channelDelete.cjs +113 -0
- package/dist/client/events/channelDelete.cjs.map +1 -0
- package/dist/client/events/channelDelete.d.cts +29 -0
- package/dist/client/events/channelDelete.d.ts +29 -0
- package/dist/client/events/channelDelete.js +11 -0
- package/dist/client/events/channelDelete.js.map +1 -0
- package/dist/client/events/channelGroupJoin.cjs +133 -0
- package/dist/client/events/channelGroupJoin.cjs.map +1 -0
- package/dist/client/events/channelGroupJoin.d.cts +30 -0
- package/dist/client/events/channelGroupJoin.d.ts +30 -0
- package/dist/client/events/channelGroupJoin.js +11 -0
- package/dist/client/events/channelGroupJoin.js.map +1 -0
- package/dist/client/events/channelGroupLeave.cjs +133 -0
- package/dist/client/events/channelGroupLeave.cjs.map +1 -0
- package/dist/client/events/channelGroupLeave.d.cts +30 -0
- package/dist/client/events/channelGroupLeave.d.ts +30 -0
- package/dist/client/events/channelGroupLeave.js +11 -0
- package/dist/client/events/channelGroupLeave.js.map +1 -0
- package/dist/client/events/channelStarttyping.cjs +110 -0
- package/dist/client/events/channelStarttyping.cjs.map +1 -0
- package/dist/client/events/channelStarttyping.d.cts +30 -0
- package/dist/client/events/channelStarttyping.d.ts +30 -0
- package/dist/client/events/channelStarttyping.js +11 -0
- package/dist/client/events/channelStarttyping.js.map +1 -0
- package/dist/client/events/channelStopTyping.cjs +110 -0
- package/dist/client/events/channelStopTyping.cjs.map +1 -0
- package/dist/client/events/channelStopTyping.d.cts +30 -0
- package/dist/client/events/channelStopTyping.d.ts +30 -0
- package/dist/client/events/channelStopTyping.js +11 -0
- package/dist/client/events/channelStopTyping.js.map +1 -0
- package/dist/client/events/channelUpdate.cjs +109 -0
- package/dist/client/events/channelUpdate.cjs.map +1 -0
- package/dist/client/events/channelUpdate.d.cts +31 -0
- package/dist/client/events/channelUpdate.d.ts +31 -0
- package/dist/client/events/channelUpdate.js +11 -0
- package/dist/client/events/channelUpdate.js.map +1 -0
- package/dist/client/events/event.cjs +124 -0
- package/dist/client/events/event.cjs.map +1 -0
- package/dist/client/events/event.d.cts +11 -0
- package/dist/client/events/event.d.ts +11 -0
- package/dist/client/events/event.js +13 -0
- package/dist/client/events/event.js.map +1 -0
- package/dist/client/events/eventManager.cjs +657 -0
- package/dist/client/events/eventManager.cjs.map +1 -0
- package/dist/client/events/eventManager.d.cts +10 -0
- package/dist/client/events/eventManager.d.ts +10 -0
- package/dist/client/events/eventManager.js +34 -0
- package/dist/client/events/eventManager.js.map +1 -0
- package/dist/client/events/index.cjs +629 -0
- package/dist/client/events/index.cjs.map +1 -0
- package/dist/client/events/index.d.cts +32 -0
- package/dist/client/events/index.d.ts +32 -0
- package/dist/client/events/index.js +96 -0
- package/dist/client/events/index.js.map +1 -0
- package/dist/client/events/message.cjs +136 -0
- package/dist/client/events/message.cjs.map +1 -0
- package/dist/client/events/message.d.cts +27 -0
- package/dist/client/events/message.d.ts +27 -0
- package/dist/client/events/message.js +11 -0
- package/dist/client/events/message.js.map +1 -0
- package/dist/client/events/messageDelete.cjs +114 -0
- package/dist/client/events/messageDelete.cjs.map +1 -0
- package/dist/client/events/messageDelete.d.cts +30 -0
- package/dist/client/events/messageDelete.d.ts +30 -0
- package/dist/client/events/messageDelete.js +11 -0
- package/dist/client/events/messageDelete.js.map +1 -0
- package/dist/client/events/messageReact.cjs +138 -0
- package/dist/client/events/messageReact.cjs.map +1 -0
- package/dist/client/events/messageReact.d.cts +40 -0
- package/dist/client/events/messageReact.d.ts +40 -0
- package/dist/client/events/messageReact.js +11 -0
- package/dist/client/events/messageReact.js.map +1 -0
- package/dist/client/events/messageUnreact.cjs +144 -0
- package/dist/client/events/messageUnreact.cjs.map +1 -0
- package/dist/client/events/messageUnreact.d.cts +28 -0
- package/dist/client/events/messageUnreact.d.ts +28 -0
- package/dist/client/events/messageUnreact.js +11 -0
- package/dist/client/events/messageUnreact.js.map +1 -0
- package/dist/client/events/messageUpdate.cjs +111 -0
- package/dist/client/events/messageUpdate.cjs.map +1 -0
- package/dist/client/events/messageUpdate.d.cts +31 -0
- package/dist/client/events/messageUpdate.d.ts +31 -0
- package/dist/client/events/messageUpdate.js +11 -0
- package/dist/client/events/messageUpdate.js.map +1 -0
- package/dist/client/events/serverCreate.cjs +131 -0
- package/dist/client/events/serverCreate.cjs.map +1 -0
- package/dist/client/events/serverCreate.d.cts +27 -0
- package/dist/client/events/serverCreate.d.ts +27 -0
- package/dist/client/events/serverCreate.js +11 -0
- package/dist/client/events/serverCreate.js.map +1 -0
- package/dist/client/events/serverDelete.cjs +110 -0
- package/dist/client/events/serverDelete.cjs.map +1 -0
- package/dist/client/events/serverDelete.d.cts +27 -0
- package/dist/client/events/serverDelete.d.ts +27 -0
- package/dist/client/events/serverDelete.js +11 -0
- package/dist/client/events/serverDelete.js.map +1 -0
- package/dist/client/events/serverMemberJoin.cjs +135 -0
- package/dist/client/events/serverMemberJoin.cjs.map +1 -0
- package/dist/client/events/serverMemberJoin.d.cts +30 -0
- package/dist/client/events/serverMemberJoin.d.ts +30 -0
- package/dist/client/events/serverMemberJoin.js +11 -0
- package/dist/client/events/serverMemberJoin.js.map +1 -0
- package/dist/client/events/serverMemberLeave.cjs +114 -0
- package/dist/client/events/serverMemberLeave.cjs.map +1 -0
- package/dist/client/events/serverMemberLeave.d.cts +30 -0
- package/dist/client/events/serverMemberLeave.d.ts +30 -0
- package/dist/client/events/serverMemberLeave.js +11 -0
- package/dist/client/events/serverMemberLeave.js.map +1 -0
- package/dist/client/events/serverMemberUpdate.cjs +135 -0
- package/dist/client/events/serverMemberUpdate.cjs.map +1 -0
- package/dist/client/events/serverMemberUpdate.d.cts +33 -0
- package/dist/client/events/serverMemberUpdate.d.ts +33 -0
- package/dist/client/events/serverMemberUpdate.js +11 -0
- package/dist/client/events/serverMemberUpdate.js.map +1 -0
- package/dist/client/events/serverRoleDelete.cjs +114 -0
- package/dist/client/events/serverRoleDelete.cjs.map +1 -0
- package/dist/client/events/serverRoleDelete.d.cts +30 -0
- package/dist/client/events/serverRoleDelete.d.ts +30 -0
- package/dist/client/events/serverRoleDelete.js +11 -0
- package/dist/client/events/serverRoleDelete.js.map +1 -0
- package/dist/client/events/serverRoleUpdate.cjs +111 -0
- package/dist/client/events/serverRoleUpdate.cjs.map +1 -0
- package/dist/client/events/serverRoleUpdate.d.cts +34 -0
- package/dist/client/events/serverRoleUpdate.d.ts +34 -0
- package/dist/client/events/serverRoleUpdate.js +11 -0
- package/dist/client/events/serverRoleUpdate.js.map +1 -0
- package/dist/client/events/serverupdate.cjs +109 -0
- package/dist/client/events/serverupdate.cjs.map +1 -0
- package/dist/client/events/serverupdate.d.cts +31 -0
- package/dist/client/events/serverupdate.d.ts +31 -0
- package/dist/client/events/serverupdate.js +11 -0
- package/dist/client/events/serverupdate.js.map +1 -0
- package/dist/client/events/userUpdate.cjs +109 -0
- package/dist/client/events/userUpdate.cjs.map +1 -0
- package/dist/client/events/userUpdate.d.cts +31 -0
- package/dist/client/events/userUpdate.d.ts +31 -0
- package/dist/client/events/userUpdate.js +11 -0
- package/dist/client/events/userUpdate.js.map +1 -0
- package/dist/client/webSocket.cjs +1018 -0
- package/dist/client/webSocket.cjs.map +1 -0
- package/dist/client/webSocket.d.cts +10 -0
- package/dist/client/webSocket.d.ts +10 -0
- package/dist/client/webSocket.js +53 -0
- package/dist/client/webSocket.js.map +1 -0
- package/dist/{index.d.mts → index-D44PqKGb.d.ts} +4 -242
- package/dist/index-XkxTx7UU.d.cts +2386 -0
- package/dist/{index.mjs → index.cjs} +112 -36
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -2624
- package/dist/index.js +111 -4535
- package/dist/index.js.map +1 -0
- package/dist/managers/baseManager.cjs +63 -0
- package/dist/managers/baseManager.cjs.map +1 -0
- package/dist/managers/baseManager.d.cts +10 -0
- package/dist/managers/baseManager.d.ts +10 -0
- package/dist/managers/baseManager.js +8 -0
- package/dist/managers/baseManager.js.map +1 -0
- package/dist/managers/channelManager.cjs +1978 -0
- package/dist/managers/channelManager.cjs.map +1 -0
- package/dist/managers/channelManager.d.cts +10 -0
- package/dist/managers/channelManager.d.ts +10 -0
- package/dist/managers/channelManager.js +53 -0
- package/dist/managers/channelManager.js.map +1 -0
- package/dist/managers/index.cjs +2992 -0
- package/dist/managers/index.cjs.map +1 -0
- package/dist/managers/index.d.cts +10 -0
- package/dist/managers/index.d.ts +10 -0
- package/dist/managers/index.js +68 -0
- package/dist/managers/index.js.map +1 -0
- package/dist/managers/messageManager.cjs +1153 -0
- package/dist/managers/messageManager.cjs.map +1 -0
- package/dist/managers/messageManager.d.cts +10 -0
- package/dist/managers/messageManager.d.ts +10 -0
- package/dist/managers/messageManager.js +53 -0
- package/dist/managers/messageManager.js.map +1 -0
- package/dist/managers/roleManager.cjs +700 -0
- package/dist/managers/roleManager.cjs.map +1 -0
- package/dist/managers/roleManager.d.cts +10 -0
- package/dist/managers/roleManager.d.ts +10 -0
- package/dist/managers/roleManager.js +53 -0
- package/dist/managers/roleManager.js.map +1 -0
- package/dist/managers/serverChannelManager.cjs +1622 -0
- package/dist/managers/serverChannelManager.cjs.map +1 -0
- package/dist/managers/serverChannelManager.d.cts +10 -0
- package/dist/managers/serverChannelManager.d.ts +10 -0
- package/dist/managers/serverChannelManager.js +53 -0
- package/dist/managers/serverChannelManager.js.map +1 -0
- package/dist/managers/serverManager.cjs +2508 -0
- package/dist/managers/serverManager.cjs.map +1 -0
- package/dist/managers/serverManager.d.cts +10 -0
- package/dist/managers/serverManager.d.ts +10 -0
- package/dist/managers/serverManager.js +53 -0
- package/dist/managers/serverManager.js.map +1 -0
- package/dist/managers/serverMemberManager.cjs +1037 -0
- package/dist/managers/serverMemberManager.cjs.map +1 -0
- package/dist/managers/serverMemberManager.d.cts +10 -0
- package/dist/managers/serverMemberManager.d.ts +10 -0
- package/dist/managers/serverMemberManager.js +53 -0
- package/dist/managers/serverMemberManager.js.map +1 -0
- package/dist/managers/userManager.cjs +1103 -0
- package/dist/managers/userManager.cjs.map +1 -0
- package/dist/managers/userManager.d.cts +10 -0
- package/dist/managers/userManager.d.ts +10 -0
- package/dist/managers/userManager.js +53 -0
- package/dist/managers/userManager.js.map +1 -0
- package/dist/rest/CDNClient.cjs +608 -0
- package/dist/rest/CDNClient.cjs.map +1 -0
- package/dist/rest/CDNClient.d.cts +10 -0
- package/dist/rest/CDNClient.d.ts +10 -0
- package/dist/rest/CDNClient.js +16 -0
- package/dist/rest/CDNClient.js.map +1 -0
- package/dist/rest/restClient.cjs +652 -0
- package/dist/rest/restClient.cjs.map +1 -0
- package/dist/rest/restClient.d.cts +10 -0
- package/dist/rest/restClient.d.ts +10 -0
- package/dist/rest/restClient.js +16 -0
- package/dist/rest/restClient.js.map +1 -0
- package/dist/rest/restUtils/rateLimitQueue.cjs +138 -0
- package/dist/rest/restUtils/rateLimitQueue.cjs.map +1 -0
- package/dist/rest/restUtils/rateLimitQueue.d.cts +13 -0
- package/dist/rest/restUtils/rateLimitQueue.d.ts +13 -0
- package/dist/rest/restUtils/rateLimitQueue.js +8 -0
- package/dist/rest/restUtils/rateLimitQueue.js.map +1 -0
- package/dist/struct/attachment.cjs +263 -0
- package/dist/struct/attachment.cjs.map +1 -0
- package/dist/struct/attachment.d.cts +10 -0
- package/dist/struct/attachment.d.ts +10 -0
- package/dist/struct/attachment.js +10 -0
- package/dist/struct/attachment.js.map +1 -0
- package/dist/struct/base.cjs +234 -0
- package/dist/struct/base.cjs.map +1 -0
- package/dist/struct/base.d.cts +10 -0
- package/dist/struct/base.d.ts +10 -0
- package/dist/struct/base.js +9 -0
- package/dist/struct/base.js.map +1 -0
- package/dist/struct/category.cjs +532 -0
- package/dist/struct/category.cjs.map +1 -0
- package/dist/struct/category.d.cts +10 -0
- package/dist/struct/category.d.ts +10 -0
- package/dist/struct/category.js +53 -0
- package/dist/struct/category.js.map +1 -0
- package/dist/struct/channel.cjs +539 -0
- package/dist/struct/channel.cjs.map +1 -0
- package/dist/struct/channel.d.cts +10 -0
- package/dist/struct/channel.d.ts +10 -0
- package/dist/struct/channel.js +15 -0
- package/dist/struct/channel.js.map +1 -0
- package/dist/struct/clientUser.cjs +741 -0
- package/dist/struct/clientUser.cjs.map +1 -0
- package/dist/struct/clientUser.d.cts +10 -0
- package/dist/struct/clientUser.d.ts +10 -0
- package/dist/struct/clientUser.js +53 -0
- package/dist/struct/clientUser.js.map +1 -0
- package/dist/struct/dmChannel.cjs +1320 -0
- package/dist/struct/dmChannel.cjs.map +1 -0
- package/dist/struct/dmChannel.d.cts +10 -0
- package/dist/struct/dmChannel.d.ts +10 -0
- package/dist/struct/dmChannel.js +53 -0
- package/dist/struct/dmChannel.js.map +1 -0
- package/dist/struct/emoji.cjs +273 -0
- package/dist/struct/emoji.cjs.map +1 -0
- package/dist/struct/emoji.d.cts +10 -0
- package/dist/struct/emoji.d.ts +10 -0
- package/dist/struct/emoji.js +10 -0
- package/dist/struct/emoji.js.map +1 -0
- package/dist/struct/groupChannel.cjs +1519 -0
- package/dist/struct/groupChannel.cjs.map +1 -0
- package/dist/struct/groupChannel.d.cts +10 -0
- package/dist/struct/groupChannel.d.ts +10 -0
- package/dist/struct/groupChannel.js +53 -0
- package/dist/struct/groupChannel.js.map +1 -0
- package/dist/struct/index.cjs +2970 -0
- package/dist/struct/index.cjs.map +1 -0
- package/dist/struct/index.d.cts +10 -0
- package/dist/struct/index.d.ts +10 -0
- package/dist/struct/index.js +101 -0
- package/dist/struct/index.js.map +1 -0
- package/dist/struct/interfaces/baseChannel.cjs +19 -0
- package/dist/struct/interfaces/baseChannel.cjs.map +1 -0
- package/dist/struct/interfaces/baseChannel.d.cts +10 -0
- package/dist/struct/interfaces/baseChannel.d.ts +10 -0
- package/dist/struct/interfaces/baseChannel.js +1 -0
- package/dist/struct/interfaces/baseChannel.js.map +1 -0
- package/dist/struct/invite.cjs +293 -0
- package/dist/struct/invite.cjs.map +1 -0
- package/dist/struct/invite.d.cts +10 -0
- package/dist/struct/invite.d.ts +10 -0
- package/dist/struct/invite.js +10 -0
- package/dist/struct/invite.js.map +1 -0
- package/dist/struct/mentions.cjs +104 -0
- package/dist/struct/mentions.cjs.map +1 -0
- package/dist/struct/mentions.d.cts +10 -0
- package/dist/struct/mentions.d.ts +10 -0
- package/dist/struct/mentions.js +8 -0
- package/dist/struct/mentions.js.map +1 -0
- package/dist/struct/message.cjs +817 -0
- package/dist/struct/message.cjs.map +1 -0
- package/dist/struct/message.d.cts +10 -0
- package/dist/struct/message.d.ts +10 -0
- package/dist/struct/message.js +53 -0
- package/dist/struct/message.js.map +1 -0
- package/dist/struct/messageEmbed.cjs +205 -0
- package/dist/struct/messageEmbed.cjs.map +1 -0
- package/dist/struct/messageEmbed.d.cts +10 -0
- package/dist/struct/messageEmbed.d.ts +10 -0
- package/dist/struct/messageEmbed.js +8 -0
- package/dist/struct/messageEmbed.js.map +1 -0
- package/dist/struct/notesChannel.cjs +1327 -0
- package/dist/struct/notesChannel.cjs.map +1 -0
- package/dist/struct/notesChannel.d.cts +10 -0
- package/dist/struct/notesChannel.d.ts +10 -0
- package/dist/struct/notesChannel.js +53 -0
- package/dist/struct/notesChannel.js.map +1 -0
- package/dist/struct/presence.cjs +254 -0
- package/dist/struct/presence.cjs.map +1 -0
- package/dist/struct/presence.d.cts +10 -0
- package/dist/struct/presence.d.ts +10 -0
- package/dist/struct/presence.js +12 -0
- package/dist/struct/presence.js.map +1 -0
- package/dist/struct/role.cjs +572 -0
- package/dist/struct/role.cjs.map +1 -0
- package/dist/struct/role.d.cts +10 -0
- package/dist/struct/role.d.ts +10 -0
- package/dist/struct/role.js +53 -0
- package/dist/struct/role.js.map +1 -0
- package/dist/struct/server.cjs +2454 -0
- package/dist/struct/server.cjs.map +1 -0
- package/dist/struct/server.d.cts +10 -0
- package/dist/struct/server.d.ts +10 -0
- package/dist/struct/server.js +53 -0
- package/dist/struct/server.js.map +1 -0
- package/dist/struct/serverChannel.cjs +776 -0
- package/dist/struct/serverChannel.cjs.map +1 -0
- package/dist/struct/serverChannel.d.cts +10 -0
- package/dist/struct/serverChannel.d.ts +10 -0
- package/dist/struct/serverChannel.js +53 -0
- package/dist/struct/serverChannel.js.map +1 -0
- package/dist/struct/serverMember.cjs +711 -0
- package/dist/struct/serverMember.cjs.map +1 -0
- package/dist/struct/serverMember.d.cts +10 -0
- package/dist/struct/serverMember.d.ts +10 -0
- package/dist/struct/serverMember.js +53 -0
- package/dist/struct/serverMember.js.map +1 -0
- package/dist/struct/textChannel.cjs +1502 -0
- package/dist/struct/textChannel.cjs.map +1 -0
- package/dist/struct/textChannel.d.cts +10 -0
- package/dist/struct/textChannel.d.ts +10 -0
- package/dist/struct/textChannel.js +53 -0
- package/dist/struct/textChannel.js.map +1 -0
- package/dist/struct/user.cjs +690 -0
- package/dist/struct/user.cjs.map +1 -0
- package/dist/struct/user.d.cts +10 -0
- package/dist/struct/user.d.ts +10 -0
- package/dist/struct/user.js +53 -0
- package/dist/struct/user.js.map +1 -0
- package/dist/struct/voiceChannels.cjs +820 -0
- package/dist/struct/voiceChannels.cjs.map +1 -0
- package/dist/struct/voiceChannels.d.cts +10 -0
- package/dist/struct/voiceChannels.d.ts +10 -0
- package/dist/struct/voiceChannels.js +53 -0
- package/dist/struct/voiceChannels.js.map +1 -0
- package/dist/utils/UUID.cjs +75 -0
- package/dist/utils/UUID.cjs.map +1 -0
- package/dist/utils/UUID.d.cts +14 -0
- package/dist/utils/UUID.d.ts +14 -0
- package/dist/utils/UUID.js +8 -0
- package/dist/utils/UUID.js.map +1 -0
- package/dist/utils/badges.cjs +181 -0
- package/dist/utils/badges.cjs.map +1 -0
- package/dist/utils/badges.d.cts +25 -0
- package/dist/utils/badges.d.ts +25 -0
- package/dist/utils/badges.js +9 -0
- package/dist/utils/badges.js.map +1 -0
- package/dist/utils/bitField.cjs +161 -0
- package/dist/utils/bitField.cjs.map +1 -0
- package/dist/utils/bitField.d.cts +51 -0
- package/dist/utils/bitField.d.ts +51 -0
- package/dist/utils/bitField.js +8 -0
- package/dist/utils/bitField.js.map +1 -0
- package/dist/utils/constants.cjs +179 -0
- package/dist/utils/constants.cjs.map +1 -0
- package/dist/utils/constants.d.cts +10 -0
- package/dist/utils/constants.d.ts +10 -0
- package/dist/utils/constants.js +23 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/index.cjs +489 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +11 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +47 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/permissions.cjs +314 -0
- package/dist/utils/permissions.cjs.map +1 -0
- package/dist/utils/permissions.d.cts +110 -0
- package/dist/utils/permissions.d.ts +110 -0
- package/dist/utils/permissions.js +17 -0
- package/dist/utils/permissions.js.map +1 -0
- package/dist/utils/types.cjs +19 -0
- package/dist/utils/types.cjs.map +1 -0
- package/dist/utils/types.d.cts +60 -0
- package/dist/utils/types.d.ts +60 -0
- package/dist/utils/types.js +1 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +16 -5
|
@@ -0,0 +1,2601 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EventManager
|
|
3
|
+
} from "./chunk-XMS4UTPG.js";
|
|
4
|
+
import {
|
|
5
|
+
Presence,
|
|
6
|
+
Status
|
|
7
|
+
} from "./chunk-YXX4DJB3.js";
|
|
8
|
+
import {
|
|
9
|
+
Channel
|
|
10
|
+
} from "./chunk-J2RF7D67.js";
|
|
11
|
+
import {
|
|
12
|
+
Emoji
|
|
13
|
+
} from "./chunk-5RK7FEID.js";
|
|
14
|
+
import {
|
|
15
|
+
Invite
|
|
16
|
+
} from "./chunk-R2PF552K.js";
|
|
17
|
+
import {
|
|
18
|
+
Mentions
|
|
19
|
+
} from "./chunk-BQS6ZLNY.js";
|
|
20
|
+
import {
|
|
21
|
+
Attachment
|
|
22
|
+
} from "./chunk-VU3XNPDE.js";
|
|
23
|
+
import {
|
|
24
|
+
Base
|
|
25
|
+
} from "./chunk-YLSAAPO4.js";
|
|
26
|
+
import {
|
|
27
|
+
BaseClient
|
|
28
|
+
} from "./chunk-MLKHJGSQ.js";
|
|
29
|
+
import {
|
|
30
|
+
ChannelPermissions,
|
|
31
|
+
DEFAULT_PERMISSION_DM,
|
|
32
|
+
FullPermissions
|
|
33
|
+
} from "./chunk-7PA5MDKS.js";
|
|
34
|
+
import {
|
|
35
|
+
Badges
|
|
36
|
+
} from "./chunk-LY7OFI25.js";
|
|
37
|
+
import {
|
|
38
|
+
cdnUrl,
|
|
39
|
+
wsUrl
|
|
40
|
+
} from "./chunk-LUDTY3LL.js";
|
|
41
|
+
import {
|
|
42
|
+
UUID
|
|
43
|
+
} from "./chunk-CQ4AJZQD.js";
|
|
44
|
+
import {
|
|
45
|
+
BaseManager
|
|
46
|
+
} from "./chunk-3GLQHMWL.js";
|
|
47
|
+
import {
|
|
48
|
+
__async,
|
|
49
|
+
__spreadProps,
|
|
50
|
+
__spreadValues
|
|
51
|
+
} from "./chunk-ICANLKGX.js";
|
|
52
|
+
|
|
53
|
+
// src/struct/message.ts
|
|
54
|
+
var Message = class extends Base {
|
|
55
|
+
/**
|
|
56
|
+
* Creates a new Message instance.
|
|
57
|
+
*
|
|
58
|
+
* @param {client} client - The client instance.
|
|
59
|
+
* @param {APIMessage} data - The raw data for the message from the API.
|
|
60
|
+
*/
|
|
61
|
+
constructor(client3, data) {
|
|
62
|
+
super(client3);
|
|
63
|
+
/** The type of the message (e.g., TEXT, SYSTEM). */
|
|
64
|
+
this.type = "TEXT";
|
|
65
|
+
/** The content of the message. */
|
|
66
|
+
this.content = "";
|
|
67
|
+
/** The ID of the channel where the message was sent. */
|
|
68
|
+
this.channelId = "";
|
|
69
|
+
/** The ID of the user who authored the message. */
|
|
70
|
+
this.authorId = "";
|
|
71
|
+
/** An array of embeds included in the message. */
|
|
72
|
+
this.embeds = [];
|
|
73
|
+
/** An array of file attachments included in the message. */
|
|
74
|
+
this.attachments = [];
|
|
75
|
+
/** Mentions included in the message. */
|
|
76
|
+
this.mentions = new Mentions(this, []);
|
|
77
|
+
/** The timestamp of when the message was last edited, or `null` if not edited. */
|
|
78
|
+
this.editedTimestamp = null;
|
|
79
|
+
/** the reactions and count on a message */
|
|
80
|
+
this.reactions = /* @__PURE__ */ new Map();
|
|
81
|
+
this._patch(data);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Updates the message instance with new data from the API.
|
|
85
|
+
*
|
|
86
|
+
* @param {APIMessage} data - The raw data for the message from the API.
|
|
87
|
+
* @returns {this} The updated message instance.
|
|
88
|
+
* @protected
|
|
89
|
+
*/
|
|
90
|
+
_patch(data) {
|
|
91
|
+
super._patch(data);
|
|
92
|
+
if (Array.isArray(data.embeds)) {
|
|
93
|
+
this.embeds = data.embeds;
|
|
94
|
+
}
|
|
95
|
+
if (Array.isArray(data.attachments)) {
|
|
96
|
+
this.attachments = data.attachments;
|
|
97
|
+
}
|
|
98
|
+
if (Array.isArray(data.mentions)) {
|
|
99
|
+
this.mentions = new Mentions(this, data.mentions);
|
|
100
|
+
}
|
|
101
|
+
if (data.author) {
|
|
102
|
+
this.authorId = data.author;
|
|
103
|
+
}
|
|
104
|
+
if (data.channel) {
|
|
105
|
+
this.channelId = data.channel;
|
|
106
|
+
}
|
|
107
|
+
if (typeof data.content === "string") {
|
|
108
|
+
this.content = data.content;
|
|
109
|
+
}
|
|
110
|
+
if (data.system) {
|
|
111
|
+
this.type = data.system.type.toUpperCase();
|
|
112
|
+
}
|
|
113
|
+
if (data.edited) {
|
|
114
|
+
this.editedTimestamp = Date.parse(data.edited);
|
|
115
|
+
}
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Gets the creation date of the message.
|
|
120
|
+
*
|
|
121
|
+
* @returns {Date} The date when the message was created.
|
|
122
|
+
*/
|
|
123
|
+
get createdAt() {
|
|
124
|
+
return UUID.timestampOf(this.id);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Gets the creation timestamp of the message in milliseconds.
|
|
128
|
+
*
|
|
129
|
+
* @returns {number} The timestamp of when the message was created.
|
|
130
|
+
*/
|
|
131
|
+
get createdTimestamp() {
|
|
132
|
+
return this.createdAt.getTime();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Gets the date when the message was last edited.
|
|
136
|
+
*
|
|
137
|
+
* @returns {Date | null} The date of the last edit, or `null` if not edited.
|
|
138
|
+
*/
|
|
139
|
+
get editedAt() {
|
|
140
|
+
return this.editedTimestamp ? new Date(this.editedTimestamp) : null;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Checks if the message is a system message.
|
|
144
|
+
*
|
|
145
|
+
* @returns {boolean} `true` if the message is a system message, otherwise `false`.
|
|
146
|
+
*/
|
|
147
|
+
get system() {
|
|
148
|
+
return this.type !== "TEXT";
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Retrieves the author of the message.
|
|
152
|
+
*
|
|
153
|
+
* @returns {User | null} The user who authored the message, or `null` if not found.
|
|
154
|
+
*/
|
|
155
|
+
get author() {
|
|
156
|
+
var _a;
|
|
157
|
+
return (_a = this.client.users.cache.get(this.authorId)) != null ? _a : null;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Retrieves the channel where the message was sent.
|
|
161
|
+
*
|
|
162
|
+
* @returns {TextChannel | DMChannel | GroupChannel} The channel instance.
|
|
163
|
+
*/
|
|
164
|
+
get channel() {
|
|
165
|
+
return this.client.channels.cache.get(this.channelId);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Retrieves the server ID associated with the message, if any.
|
|
169
|
+
*
|
|
170
|
+
* @returns {string | null} The server ID, or `null` if the message is not in a server.
|
|
171
|
+
*/
|
|
172
|
+
get serverId() {
|
|
173
|
+
const channel = this.channel;
|
|
174
|
+
return channel.inServer() ? channel.serverId : null;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Retrieves the server associated with the message, if any.
|
|
178
|
+
*
|
|
179
|
+
* @returns {Server | null} The server instance, or `null` if not found.
|
|
180
|
+
*/
|
|
181
|
+
get server() {
|
|
182
|
+
var _a;
|
|
183
|
+
return (_a = this.client.servers.cache.get(this.serverId)) != null ? _a : null;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Retrieves the server member who authored the message, if any.
|
|
187
|
+
*
|
|
188
|
+
* @returns {ServerMember | null} The server member instance, or `null` if not found.
|
|
189
|
+
*/
|
|
190
|
+
get member() {
|
|
191
|
+
var _a, _b;
|
|
192
|
+
return (_b = (_a = this.server) == null ? void 0 : _a.members.cache.get(this.authorId)) != null ? _b : null;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Gets the URL of the message.
|
|
196
|
+
*
|
|
197
|
+
* @returns {string} The URL of the message.
|
|
198
|
+
*/
|
|
199
|
+
get url() {
|
|
200
|
+
return `https://app.revolt.chat/${this.serverId ? `server/${this.serverId}` : ""}/channel/${this.channelId}/${this.id}`;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Acknowledges the message.
|
|
204
|
+
*
|
|
205
|
+
* @returns {Promise<void>} A promise that resolves when the message is acknowledged.
|
|
206
|
+
*/
|
|
207
|
+
ack() {
|
|
208
|
+
return this.channel.messages.ack(this);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Deletes the message.
|
|
212
|
+
*
|
|
213
|
+
* @returns {Promise<void>} A promise that resolves when the message is deleted.
|
|
214
|
+
*/
|
|
215
|
+
delete() {
|
|
216
|
+
return this.channel.messages.delete(this);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Replies to the message.
|
|
220
|
+
*
|
|
221
|
+
* @param {string} content - The content of the reply.
|
|
222
|
+
* @param {boolean} [mention=true] - Whether to mention the original message author.
|
|
223
|
+
* @returns {Promise<Message>} A promise that resolves with the sent reply message.
|
|
224
|
+
*/
|
|
225
|
+
reply(content, mention = true) {
|
|
226
|
+
return this.channel.messages.send(__spreadProps(__spreadValues({}, typeof content === "object" ? content : { content }), {
|
|
227
|
+
replies: [{ id: this.id, mention }]
|
|
228
|
+
}));
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Edits the message.
|
|
232
|
+
*
|
|
233
|
+
* @param {MessageEditOptions | string} options - The new content or edit options.
|
|
234
|
+
* @returns {Promise<void>} A promise that resolves when the message is edited.
|
|
235
|
+
*/
|
|
236
|
+
edit(options) {
|
|
237
|
+
return this.channel.messages.edit(this, options);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Fetches the latest data for the message.
|
|
241
|
+
*
|
|
242
|
+
* @returns {Promise<Message>} A promise that resolves with the updated message instance.
|
|
243
|
+
*/
|
|
244
|
+
fetch() {
|
|
245
|
+
return this.channel.messages.fetch(this.id);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Adds a reaction to the message.
|
|
249
|
+
*
|
|
250
|
+
* @param {string} emoji - The emoji to react with.
|
|
251
|
+
* @returns {Promise<void>} A promise that resolves when the reaction is added.
|
|
252
|
+
*/
|
|
253
|
+
addReaction(emoji) {
|
|
254
|
+
return this.channel.messages.addReaction(this, emoji);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Removes a reaction from the message.
|
|
258
|
+
*
|
|
259
|
+
* @param {string} emoji - The emoji to remove the reaction for.
|
|
260
|
+
* @param {object} [options] - Options for removing the reaction.
|
|
261
|
+
* @param {string} [options.user_id] - The user ID to remove the reaction for. If not provided, removes the reaction for the current user.
|
|
262
|
+
* @param {boolean} [options.remove_all=false] - Whether to remove all of the specified reaction for the message.
|
|
263
|
+
* @returns {Promise<void>} A promise that resolves when the reaction is removed.
|
|
264
|
+
*/
|
|
265
|
+
removeReaction(emoji, options) {
|
|
266
|
+
var _a, _b;
|
|
267
|
+
return this.channel.messages.removeReaction(
|
|
268
|
+
this,
|
|
269
|
+
emoji,
|
|
270
|
+
(_a = options == null ? void 0 : options.user_id) != null ? _a : void 0,
|
|
271
|
+
(_b = options == null ? void 0 : options.remove_all) != null ? _b : false
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Removes all reactions from the message.
|
|
276
|
+
*
|
|
277
|
+
* @returns {Promise<void>} A promise that resolves when all reactions are removed.
|
|
278
|
+
*/
|
|
279
|
+
removeAllReactions() {
|
|
280
|
+
return this.channel.messages.removeAllReactions(this);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Checks if the message is in a server.
|
|
284
|
+
*
|
|
285
|
+
* @returns {boolean} `true` if the message is in a server, otherwise `false`.
|
|
286
|
+
*/
|
|
287
|
+
inServer() {
|
|
288
|
+
return this.channel.inServer();
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Converts the message to a string representation.
|
|
292
|
+
*
|
|
293
|
+
* @returns {string} The content of the message.
|
|
294
|
+
*/
|
|
295
|
+
toString() {
|
|
296
|
+
return this.content;
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// src/managers/channelManager.ts
|
|
301
|
+
var ChannelManager = class extends BaseManager {
|
|
302
|
+
constructor() {
|
|
303
|
+
super(...arguments);
|
|
304
|
+
this.holds = null;
|
|
305
|
+
}
|
|
306
|
+
_add(data) {
|
|
307
|
+
let channel;
|
|
308
|
+
switch (data.channel_type) {
|
|
309
|
+
case "TextChannel":
|
|
310
|
+
channel = new TextChannel2(this.client, data);
|
|
311
|
+
break;
|
|
312
|
+
case "VoiceChannel":
|
|
313
|
+
channel = new VoiceChannel(this.client, data);
|
|
314
|
+
break;
|
|
315
|
+
case "DirectMessage":
|
|
316
|
+
channel = new DMChannel2(this.client, data);
|
|
317
|
+
break;
|
|
318
|
+
case "Group":
|
|
319
|
+
channel = new GroupChannel2(this.client, data);
|
|
320
|
+
break;
|
|
321
|
+
case "SavedMessages":
|
|
322
|
+
channel = new NotesChannel(this.client, data);
|
|
323
|
+
if (this.client.user) this.client.user.notes = channel;
|
|
324
|
+
break;
|
|
325
|
+
default:
|
|
326
|
+
throw new Error(`Unknown Channel Type: ${data}`);
|
|
327
|
+
}
|
|
328
|
+
this.cache.set(channel.id, channel);
|
|
329
|
+
return channel;
|
|
330
|
+
}
|
|
331
|
+
_remove(id) {
|
|
332
|
+
var _a;
|
|
333
|
+
const channel = this.cache.get(id);
|
|
334
|
+
if (channel == null ? void 0 : channel.inServer()) {
|
|
335
|
+
(_a = channel.server) == null ? void 0 : _a.channels.cache.delete(id);
|
|
336
|
+
}
|
|
337
|
+
super._remove(id);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* used to delete a channel
|
|
341
|
+
*
|
|
342
|
+
* @param channel The channel to delete
|
|
343
|
+
* @returns A promise that resolves when the channel is deleted
|
|
344
|
+
*/
|
|
345
|
+
delete(channel) {
|
|
346
|
+
return __async(this, null, function* () {
|
|
347
|
+
const id = this.resolveId(channel);
|
|
348
|
+
if (!id) {
|
|
349
|
+
throw new TypeError("INVALID_TYPE");
|
|
350
|
+
}
|
|
351
|
+
yield this.client.api.delete(`/channels/${id}`);
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* used to fetch a channel
|
|
356
|
+
*
|
|
357
|
+
* @param channel The channel to fetch
|
|
358
|
+
* @param force Whether to force fetch the channel using the api or return it form cache if able
|
|
359
|
+
* @returns A promise that resolves with the fetched channel
|
|
360
|
+
*/
|
|
361
|
+
fetch(_0) {
|
|
362
|
+
return __async(this, arguments, function* (channel, { force = true } = {}) {
|
|
363
|
+
const id = this.resolveId(channel);
|
|
364
|
+
if (!id) {
|
|
365
|
+
throw new TypeError("INVALID_TYPE");
|
|
366
|
+
}
|
|
367
|
+
if (!force) {
|
|
368
|
+
const channel2 = this.cache.get(id);
|
|
369
|
+
if (channel2) return channel2;
|
|
370
|
+
}
|
|
371
|
+
const data = yield this.client.api.get(`/channels/${id}`);
|
|
372
|
+
return this._add(data);
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* resolves a channel from a string or a channel object
|
|
377
|
+
* @param channel The channel to resolve
|
|
378
|
+
* @returns the resolved channel or null if not found
|
|
379
|
+
*/
|
|
380
|
+
resolve(channel) {
|
|
381
|
+
if (channel instanceof Channel) return channel;
|
|
382
|
+
return super.resolve(channel);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* resolves a channel id from a string or a channel object
|
|
386
|
+
* @param channel The channel to resolve
|
|
387
|
+
* @returns the resolved channel id or null if not found
|
|
388
|
+
*/
|
|
389
|
+
resolveId(channel) {
|
|
390
|
+
if (channel instanceof Channel) return channel.id;
|
|
391
|
+
return super.resolveId(channel);
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
// src/managers/serverManager.ts
|
|
396
|
+
var ServerManager = class extends BaseManager {
|
|
397
|
+
constructor() {
|
|
398
|
+
super(...arguments);
|
|
399
|
+
this.holds = Server2;
|
|
400
|
+
}
|
|
401
|
+
_remove(id) {
|
|
402
|
+
var _a;
|
|
403
|
+
const server = this.cache.get(id);
|
|
404
|
+
for (const id2 of (_a = server == null ? void 0 : server.channels.cache.keys()) != null ? _a : []) {
|
|
405
|
+
this.client.channels._remove(id2);
|
|
406
|
+
}
|
|
407
|
+
return super._remove(id);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* edits a server
|
|
411
|
+
* @param server The server to edit
|
|
412
|
+
* @param options The options to edit the server with
|
|
413
|
+
* @param options.name The name of the server
|
|
414
|
+
* @param options.description The description of the server
|
|
415
|
+
* @returns A promise that resolves when the server is edited
|
|
416
|
+
*/
|
|
417
|
+
edit(server, options) {
|
|
418
|
+
return __async(this, null, function* () {
|
|
419
|
+
const id = this.resolveId(server);
|
|
420
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
421
|
+
yield this.client.api.patch(`/servers/${id}`, { body: options });
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* leaves a server
|
|
426
|
+
* @param server the server to leave
|
|
427
|
+
*/
|
|
428
|
+
delete(server) {
|
|
429
|
+
return __async(this, null, function* () {
|
|
430
|
+
const id = this.resolveId(server);
|
|
431
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
432
|
+
yield this.client.api.delete(`/servers/${id}`);
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
fetch(_0) {
|
|
436
|
+
return __async(this, arguments, function* (server, { force = true } = {}) {
|
|
437
|
+
const id = this.resolveId(server);
|
|
438
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
439
|
+
if (!force) {
|
|
440
|
+
const server2 = this.cache.get(id);
|
|
441
|
+
if (server2) return server2;
|
|
442
|
+
}
|
|
443
|
+
const data = yield this.client.api.get(`/servers/${id}`);
|
|
444
|
+
return this._add(data);
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
// src/managers/userManager.ts
|
|
450
|
+
var UserManager = class extends BaseManager {
|
|
451
|
+
constructor() {
|
|
452
|
+
super(...arguments);
|
|
453
|
+
this.holds = User2;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
*
|
|
457
|
+
* @param user The user to fetch
|
|
458
|
+
* @returns A promise that resolves when the user is fetched
|
|
459
|
+
*/
|
|
460
|
+
fetch(_0) {
|
|
461
|
+
return __async(this, arguments, function* (user, { force = false } = {}) {
|
|
462
|
+
const id = this.resolveId(user);
|
|
463
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
464
|
+
if (!force) {
|
|
465
|
+
const user2 = this.cache.get(id);
|
|
466
|
+
if (user2) return user2;
|
|
467
|
+
}
|
|
468
|
+
const data = yield this.client.api.get(`/users/${id}`);
|
|
469
|
+
return this._add(data);
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
resolve(resolvable) {
|
|
473
|
+
if (resolvable instanceof Message) return resolvable.author;
|
|
474
|
+
return super.resolve(resolvable);
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* get a user id form cache
|
|
478
|
+
* @param resolvable The user to resolve
|
|
479
|
+
* @returns The user id or null if it cannot be resolved
|
|
480
|
+
*/
|
|
481
|
+
resolveId(resolvable) {
|
|
482
|
+
if (resolvable instanceof Message) return resolvable.authorId;
|
|
483
|
+
return super.resolveId(resolvable);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// src/managers/messageManager.ts
|
|
488
|
+
import { File } from "node:buffer";
|
|
489
|
+
import { Readable } from "stream";
|
|
490
|
+
import FormData from "form-data";
|
|
491
|
+
import axios from "axios";
|
|
492
|
+
var MessageManager = class extends BaseManager {
|
|
493
|
+
constructor(channel) {
|
|
494
|
+
super(channel.client);
|
|
495
|
+
this.channel = channel;
|
|
496
|
+
this.holds = Message;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
*
|
|
500
|
+
* @param content The content to send. Can be a string or an object with the following properties:
|
|
501
|
+
* - content: The content of the message
|
|
502
|
+
* - replies: An array of message IDs to reply to
|
|
503
|
+
* - attachments: An array of attachment URLs, Files, or ReadStreams
|
|
504
|
+
* - embeds: An array of MessageEmbed objects
|
|
505
|
+
* @returns Promise that resolves to the sent message
|
|
506
|
+
*/
|
|
507
|
+
send(content) {
|
|
508
|
+
return __async(this, null, function* () {
|
|
509
|
+
if (typeof content === "string") content = { content };
|
|
510
|
+
let attachments = [];
|
|
511
|
+
let embeds = [];
|
|
512
|
+
if (Array.isArray(content.attachments)) {
|
|
513
|
+
const promises = content.attachments.map((att) => __async(this, null, function* () {
|
|
514
|
+
const data = new FormData();
|
|
515
|
+
if (typeof att === "string") {
|
|
516
|
+
const readableStream = yield axios.get(att, {
|
|
517
|
+
responseType: "stream"
|
|
518
|
+
});
|
|
519
|
+
data.append("file", readableStream.data, {
|
|
520
|
+
filename: att.split("/").pop()
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
if (att instanceof Readable) {
|
|
524
|
+
data.append("file", att);
|
|
525
|
+
}
|
|
526
|
+
if (att instanceof File) {
|
|
527
|
+
const buffer = Buffer.from(yield att.arrayBuffer());
|
|
528
|
+
data.append("file", buffer, { filename: att.name });
|
|
529
|
+
}
|
|
530
|
+
yield this.client.cdn.post("/attachments", data).then((attachment) => {
|
|
531
|
+
const { id } = attachment;
|
|
532
|
+
attachments.push(id);
|
|
533
|
+
});
|
|
534
|
+
}));
|
|
535
|
+
yield Promise.all(promises);
|
|
536
|
+
}
|
|
537
|
+
if (Array.isArray(content.embeds)) {
|
|
538
|
+
const promises = content.embeds.map((embed) => __async(this, null, function* () {
|
|
539
|
+
const json = yield embed.toJSONWithMedia(this.client);
|
|
540
|
+
embeds.push(json);
|
|
541
|
+
}));
|
|
542
|
+
yield Promise.all(promises);
|
|
543
|
+
}
|
|
544
|
+
const resp = yield this.client.api.post(
|
|
545
|
+
`/channels/${this.channel.id}/messages`,
|
|
546
|
+
{
|
|
547
|
+
body: __spreadProps(__spreadValues({}, content), { attachments, embeds, nonce: UUID.generate() })
|
|
548
|
+
}
|
|
549
|
+
);
|
|
550
|
+
return this._add(resp);
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* acknowledge a message to mark it as read (not important for bots)
|
|
555
|
+
* @param message The message to acknowledge
|
|
556
|
+
* @returns Promise that resolves when the message is acknowledged
|
|
557
|
+
*/
|
|
558
|
+
ack(message) {
|
|
559
|
+
return __async(this, null, function* () {
|
|
560
|
+
const id = this.resolveId(message);
|
|
561
|
+
if (!id) {
|
|
562
|
+
throw new TypeError("INVALID_TYPE");
|
|
563
|
+
}
|
|
564
|
+
yield this.client.api.put(`/channels/${this.channel.id}/ack/${id}`);
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* bulk delete messages from the channel
|
|
569
|
+
* @param messages The messages to delete. Can be an array of message IDs or a Map of message IDs to Message objects.
|
|
570
|
+
* @returns Promise that resolves when the messages are deleted
|
|
571
|
+
*/
|
|
572
|
+
bulkDelete(messages) {
|
|
573
|
+
return __async(this, null, function* () {
|
|
574
|
+
let ids = [];
|
|
575
|
+
if (typeof messages === "number") {
|
|
576
|
+
messages = yield this.fetch(messages);
|
|
577
|
+
ids = messages instanceof Map ? [...messages.keys()] : [];
|
|
578
|
+
} else if (messages instanceof Map) {
|
|
579
|
+
ids = [...messages.keys()];
|
|
580
|
+
} else {
|
|
581
|
+
ids = messages.map((m) => this.resolveId(m)).filter(Boolean);
|
|
582
|
+
}
|
|
583
|
+
yield this.client.api.delete(`/channels/${this.channel.id}/messages/bulk`, {
|
|
584
|
+
body: JSON.stringify({ ids })
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* delete a message from the channel
|
|
590
|
+
* @param message The message to delete. Can be a Message object or a message ID.
|
|
591
|
+
* @returns Promise that resolves when the message is deleted
|
|
592
|
+
*/
|
|
593
|
+
delete(message) {
|
|
594
|
+
return __async(this, null, function* () {
|
|
595
|
+
const id = this.resolveId(message);
|
|
596
|
+
if (!id) {
|
|
597
|
+
throw new TypeError("INVALID_TYPE");
|
|
598
|
+
}
|
|
599
|
+
yield this.client.api.delete(`/channels/${this.channel.id}/messages/${id}`);
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* edit a message in the channel
|
|
604
|
+
* @param message The message to edit. Can be a Message object or a message ID.
|
|
605
|
+
* @param options The options to edit the message with. Can be a string or an object with the following properties:
|
|
606
|
+
* - content: The new content of the message
|
|
607
|
+
* - attachments: An array of attachment URLs
|
|
608
|
+
* - embeds: An array of MessageEmbed objects
|
|
609
|
+
* @returns Promise that resolves when the message is edited
|
|
610
|
+
*/
|
|
611
|
+
edit(message, options) {
|
|
612
|
+
return __async(this, null, function* () {
|
|
613
|
+
const id = this.resolveId(message);
|
|
614
|
+
if (!id) {
|
|
615
|
+
throw new TypeError("INVALID_TYPE");
|
|
616
|
+
}
|
|
617
|
+
if (typeof options === "string") options = { content: options };
|
|
618
|
+
yield this.client.api.patch(`/channels/${this.channel.id}/messages/${id}`, {
|
|
619
|
+
body: options
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* search for messages in the channel
|
|
625
|
+
* @param query The query to search for. Can be a string or an object with the following properties:
|
|
626
|
+
* - query: The query to search for
|
|
627
|
+
* - limit: The maximum number of messages to return
|
|
628
|
+
* - before: The message ID to start searching from (exclusive)
|
|
629
|
+
* - after: The message ID to stop searching at (exclusive)
|
|
630
|
+
* - sort: The sort order of the results (asc or desc)
|
|
631
|
+
* @returns Promise that resolves to a Map of message IDs to Message objects
|
|
632
|
+
*/
|
|
633
|
+
search(query) {
|
|
634
|
+
return __async(this, null, function* () {
|
|
635
|
+
if (typeof query === "string") query = { query };
|
|
636
|
+
const response = yield this.client.api.post(
|
|
637
|
+
`/channels/${this.channel.id}/search`,
|
|
638
|
+
{
|
|
639
|
+
query
|
|
640
|
+
}
|
|
641
|
+
);
|
|
642
|
+
return response.reduce((coll, cur) => {
|
|
643
|
+
const msg = this._add(cur);
|
|
644
|
+
coll.set(msg.id, msg);
|
|
645
|
+
return coll;
|
|
646
|
+
}, /* @__PURE__ */ new Map());
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
fetch(query) {
|
|
650
|
+
return __async(this, null, function* () {
|
|
651
|
+
const id = this.resolveId(query);
|
|
652
|
+
if (id) {
|
|
653
|
+
const data = yield this.client.api.get(
|
|
654
|
+
`/channels/${this.channel.id}/messages/${id}`
|
|
655
|
+
);
|
|
656
|
+
return this._add(data);
|
|
657
|
+
}
|
|
658
|
+
if (typeof query === "number") query = { limit: query };
|
|
659
|
+
else if (typeof query === "undefined") query = { limit: 100 };
|
|
660
|
+
const messages = yield this.client.api.get(
|
|
661
|
+
`/channels/${this.channel.id}/messages`,
|
|
662
|
+
{ query: JSON.stringify(query) }
|
|
663
|
+
);
|
|
664
|
+
return messages.reduce((coll, cur) => {
|
|
665
|
+
const msg = this._add(cur);
|
|
666
|
+
coll.set(msg.id, msg);
|
|
667
|
+
return coll;
|
|
668
|
+
}, /* @__PURE__ */ new Map());
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* add a reaction to a message
|
|
673
|
+
* @param message The message to react to. Can be a Message object or a message ID.
|
|
674
|
+
* @param emoji emoji to react with. Can be a string or an Emoji object.
|
|
675
|
+
* @returns Promise that resolves when the reaction is added
|
|
676
|
+
*/
|
|
677
|
+
addReaction(message, emoji) {
|
|
678
|
+
return __async(this, null, function* () {
|
|
679
|
+
const id = this.resolveId(message);
|
|
680
|
+
if (!id) {
|
|
681
|
+
throw new TypeError("INVALID_TYPE");
|
|
682
|
+
}
|
|
683
|
+
if (emoji instanceof Emoji) emoji = emoji.id;
|
|
684
|
+
else if (typeof emoji !== "string") {
|
|
685
|
+
throw new TypeError("INVALID_TYPE");
|
|
686
|
+
}
|
|
687
|
+
yield this.client.api.put(
|
|
688
|
+
`/channels/${this.channel.id}/messages/${id}/reactions/${emoji}`
|
|
689
|
+
);
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
*
|
|
694
|
+
* @param message The message to unreact. Can be a Message object or a message ID.
|
|
695
|
+
* @param emoji the emoji to unreact with. Can be a string or an Emoji object.
|
|
696
|
+
* @param user_id The user ID to remove the reaction for. If not provided, removes the reaction for the current user.
|
|
697
|
+
* @param remove_all Whether to remove all of the specified reaction for the message. Defaults to false.
|
|
698
|
+
* @returns Promise that resolves when the reaction is removed
|
|
699
|
+
*/
|
|
700
|
+
removeReaction(message, emoji, user_id, remove_all = false) {
|
|
701
|
+
return __async(this, null, function* () {
|
|
702
|
+
const id = this.resolveId(message);
|
|
703
|
+
if (!id) {
|
|
704
|
+
throw new TypeError("INVALID_TYPE");
|
|
705
|
+
}
|
|
706
|
+
if (emoji instanceof Emoji) emoji = emoji.id;
|
|
707
|
+
else if (typeof emoji !== "string") {
|
|
708
|
+
throw new TypeError("INVALID_TYPE");
|
|
709
|
+
}
|
|
710
|
+
const queryString = user_id ? `?user_id=${user_id}&remove_all=${remove_all}` : `?remove_all=${remove_all}`;
|
|
711
|
+
yield this.client.api.delete(
|
|
712
|
+
`/channels/${this.channel.id}/messages/${id}/reactions/${emoji}${queryString}`
|
|
713
|
+
);
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* remove all reactions from a message
|
|
718
|
+
* @param message The message to remove reactions from. Can be a Message object or a message ID.
|
|
719
|
+
* @returns Promise that resolves when the reactions are removed
|
|
720
|
+
*/
|
|
721
|
+
removeAllReactions(message) {
|
|
722
|
+
return __async(this, null, function* () {
|
|
723
|
+
const id = this.resolveId(message);
|
|
724
|
+
if (!id) {
|
|
725
|
+
throw new TypeError("INVALID_TYPE");
|
|
726
|
+
}
|
|
727
|
+
yield this.client.api.delete(
|
|
728
|
+
`/channels/${this.channel.id}/messages/${id}/reactions`
|
|
729
|
+
);
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
// src/managers/roleManager.ts
|
|
735
|
+
var RoleManager = class extends BaseManager {
|
|
736
|
+
constructor(server) {
|
|
737
|
+
super(server.client);
|
|
738
|
+
this.server = server;
|
|
739
|
+
this.holds = Role;
|
|
740
|
+
}
|
|
741
|
+
_add(data) {
|
|
742
|
+
const role = new Role(this.server, data);
|
|
743
|
+
this.cache.set(role.id, role);
|
|
744
|
+
return role;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* creates a new role in the server
|
|
748
|
+
* @param name The name of the role to create
|
|
749
|
+
* @returns
|
|
750
|
+
*/
|
|
751
|
+
create(name) {
|
|
752
|
+
return __async(this, null, function* () {
|
|
753
|
+
const { id, role } = yield this.client.api.post(`/servers/${this.server.id}/roles`, { body: { name } });
|
|
754
|
+
return this._add(Object.assign(role, { id }));
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* deletes a role from the server
|
|
759
|
+
* @param role the role to delete
|
|
760
|
+
* @returns A promise that resolves when the role is deleted
|
|
761
|
+
*/
|
|
762
|
+
delete(role) {
|
|
763
|
+
return __async(this, null, function* () {
|
|
764
|
+
const id = this.resolveId(role);
|
|
765
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
766
|
+
yield this.client.api.delete(`/servers/${this.server.id}/roles/${id}`);
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
*
|
|
771
|
+
* @param role the role to edit
|
|
772
|
+
* @param data data to edit the role with
|
|
773
|
+
* @param data.permissions The permissions to set for the role, in the format { a: allow, d: deny }
|
|
774
|
+
* @param data.name The name of the role
|
|
775
|
+
* @param data.colour The color of the role, or `null` if no color is set
|
|
776
|
+
* @param data.hoist Whether the role is displayed separately in the member list
|
|
777
|
+
* @param data.rank The rank of the role, used for ordering
|
|
778
|
+
* @param data.remove Fields to remove from the role
|
|
779
|
+
* @returns Role
|
|
780
|
+
* @throws {TypeError} If the role ID is invalid
|
|
781
|
+
*/
|
|
782
|
+
edit(role, data) {
|
|
783
|
+
return __async(this, null, function* () {
|
|
784
|
+
var _a, _b;
|
|
785
|
+
const id = this.resolveId(role);
|
|
786
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
787
|
+
if (data.permissions) {
|
|
788
|
+
const permissions = {
|
|
789
|
+
allow: new FullPermissions(((_a = data.permissions) == null ? void 0 : _a.a) || []).bitfield,
|
|
790
|
+
deny: new FullPermissions(((_b = data.permissions) == null ? void 0 : _b.d) || []).bitfield
|
|
791
|
+
};
|
|
792
|
+
yield this.client.api.put(
|
|
793
|
+
`/servers/${this.server.id}/permissions/${id}`,
|
|
794
|
+
{ body: { permissions } }
|
|
795
|
+
);
|
|
796
|
+
}
|
|
797
|
+
delete data.permissions;
|
|
798
|
+
const updatedRole = yield this.client.api.patch(
|
|
799
|
+
`/servers/${this.server.id}/roles/${id}`,
|
|
800
|
+
{ body: data }
|
|
801
|
+
);
|
|
802
|
+
return this._add(Object.assign(updatedRole, { id }));
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
// src/managers/serverChannelManager.ts
|
|
808
|
+
var ServerChannelManager = class extends BaseManager {
|
|
809
|
+
constructor(server) {
|
|
810
|
+
super(server.client);
|
|
811
|
+
this.server = server;
|
|
812
|
+
this.holds = ServerChannel;
|
|
813
|
+
}
|
|
814
|
+
_add(data) {
|
|
815
|
+
let channel;
|
|
816
|
+
switch (data.channel_type) {
|
|
817
|
+
case "TextChannel":
|
|
818
|
+
channel = new TextChannel2(this.client, data);
|
|
819
|
+
break;
|
|
820
|
+
case "VoiceChannel":
|
|
821
|
+
channel = new VoiceChannel(this.client, data);
|
|
822
|
+
break;
|
|
823
|
+
default:
|
|
824
|
+
throw new Error(
|
|
825
|
+
`Unknown channel type: ${data.channel_type}`
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
this.cache.set(channel.id, channel);
|
|
829
|
+
return channel;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* creates a new channel in the server
|
|
833
|
+
* @param name The name of the channel to create
|
|
834
|
+
* @param type The type of the channel to create. Can be "Text" or "Voice". Defaults to "Text".
|
|
835
|
+
* @param description The description of the channel to create. Only used for voice channels.
|
|
836
|
+
* @returns A promise that resolves to the created channel
|
|
837
|
+
*/
|
|
838
|
+
create(_0) {
|
|
839
|
+
return __async(this, arguments, function* ({
|
|
840
|
+
name,
|
|
841
|
+
type = "Text",
|
|
842
|
+
description
|
|
843
|
+
}) {
|
|
844
|
+
const data = yield this.client.api.post(
|
|
845
|
+
`/servers/${this.server.id}/channels`,
|
|
846
|
+
{
|
|
847
|
+
body: {
|
|
848
|
+
name,
|
|
849
|
+
type,
|
|
850
|
+
description,
|
|
851
|
+
nonce: UUID.generate()
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
);
|
|
855
|
+
return this._add(data);
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* fetch a channel from the server
|
|
860
|
+
* @param channel The channel to fetch. Can be a string, a channel object, or an API channel object.
|
|
861
|
+
* @param force Whether to force fetch the channel from the API. Defaults to true.
|
|
862
|
+
* If set to false, the method will return the channel from the cache if it exists.
|
|
863
|
+
* @returns A promise that resolves to the fetched channel
|
|
864
|
+
*/
|
|
865
|
+
fetch(_0) {
|
|
866
|
+
return __async(this, arguments, function* (channel, { force = true } = {}) {
|
|
867
|
+
const id = this.resolveId(channel);
|
|
868
|
+
if (!id) {
|
|
869
|
+
throw new TypeError("INVALID_ID");
|
|
870
|
+
}
|
|
871
|
+
if (!force) {
|
|
872
|
+
const channel2 = this.cache.get(id);
|
|
873
|
+
if (channel2) return channel2;
|
|
874
|
+
}
|
|
875
|
+
const data = yield this.client.api.get(
|
|
876
|
+
`/servers/${this.server.id}/channels/${id}`
|
|
877
|
+
);
|
|
878
|
+
return this._add(data);
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
// src/managers/serverMemberManager.ts
|
|
884
|
+
var ServerMemberManager = class extends BaseManager {
|
|
885
|
+
constructor(server) {
|
|
886
|
+
super(server.client);
|
|
887
|
+
this.server = server;
|
|
888
|
+
this.holds = ServerMember2;
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* edit selected member in the server
|
|
892
|
+
* @param member The member to edit
|
|
893
|
+
* @param options The options to edit the member with
|
|
894
|
+
* @param options.nickname The nickname of the member to set
|
|
895
|
+
* @param options.avatar The avatar of the member to set
|
|
896
|
+
* @param options.roles The roles of the member to set
|
|
897
|
+
* @returns A promise that resolves when the member is edited
|
|
898
|
+
*/
|
|
899
|
+
edit(member, options) {
|
|
900
|
+
return __async(this, null, function* () {
|
|
901
|
+
const id = this.resolveId(member);
|
|
902
|
+
if (!id) {
|
|
903
|
+
throw new TypeError("INVALID_TYPE");
|
|
904
|
+
}
|
|
905
|
+
yield this.client.api.patch(`/servers/${this.server.id}/members/${id}`, {
|
|
906
|
+
body: __spreadValues({}, options)
|
|
907
|
+
});
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* ban selected member in the server
|
|
912
|
+
* @param member The member to ban
|
|
913
|
+
* @param reason the reason for the ban
|
|
914
|
+
* @returns A promise that resolves when the member is banned
|
|
915
|
+
*/
|
|
916
|
+
ban(member, reason) {
|
|
917
|
+
return __async(this, null, function* () {
|
|
918
|
+
const id = this.resolveId(member);
|
|
919
|
+
if (!id) {
|
|
920
|
+
throw new TypeError("INVALID_TYPE");
|
|
921
|
+
}
|
|
922
|
+
yield this.client.api.put(`/servers/${this.server.id}/bans/${id}`, {
|
|
923
|
+
body: { reason }
|
|
924
|
+
});
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* kick selected member in the server
|
|
929
|
+
* @param member The member to kick
|
|
930
|
+
* @returns A promise that resolves when the member is kicked
|
|
931
|
+
*/
|
|
932
|
+
kick(member) {
|
|
933
|
+
return __async(this, null, function* () {
|
|
934
|
+
const id = this.resolveId(member);
|
|
935
|
+
if (!id) {
|
|
936
|
+
throw new TypeError("INVALID_TYPE");
|
|
937
|
+
}
|
|
938
|
+
yield this.client.api.delete(`/servers/${this.server.id}/members/${id}`);
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* unban selected member in the server
|
|
943
|
+
* @param member The member to unban
|
|
944
|
+
* @returns A promise that resolves when the member is unbanned
|
|
945
|
+
*/
|
|
946
|
+
unban(member) {
|
|
947
|
+
return __async(this, null, function* () {
|
|
948
|
+
const id = this.resolveId(member);
|
|
949
|
+
if (!id) {
|
|
950
|
+
throw new TypeError("INVALID_TYPE");
|
|
951
|
+
}
|
|
952
|
+
yield this.client.api.delete(`/servers/${this.server.id}/bans/${id}`);
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
fetch(member) {
|
|
956
|
+
return __async(this, null, function* () {
|
|
957
|
+
if (typeof member !== "undefined") {
|
|
958
|
+
const id = this.resolveId(member);
|
|
959
|
+
if (!id) {
|
|
960
|
+
throw new TypeError("INVALID_TYPE");
|
|
961
|
+
}
|
|
962
|
+
const data = yield this.client.api.get(
|
|
963
|
+
`/servers/${this.server.id}/members/${id}`
|
|
964
|
+
);
|
|
965
|
+
return this._add(data);
|
|
966
|
+
}
|
|
967
|
+
const { users, members } = yield this.client.api.get(`/servers/${this.server.id}/members`);
|
|
968
|
+
users.reduce((coll, cur) => {
|
|
969
|
+
const user = this.client.users._add(cur);
|
|
970
|
+
coll.set(user.id, user);
|
|
971
|
+
return coll;
|
|
972
|
+
}, this.client.users.cache);
|
|
973
|
+
return members.reduce((coll, cur) => {
|
|
974
|
+
const member2 = this._add(cur);
|
|
975
|
+
coll.set(member2.id, member2);
|
|
976
|
+
return coll;
|
|
977
|
+
}, /* @__PURE__ */ new Map());
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* resolves a member from a string or a member object
|
|
982
|
+
* @param member The member to resolve
|
|
983
|
+
* @returns The id of the member or null if it cannot be resolved
|
|
984
|
+
*/
|
|
985
|
+
resolveId(member) {
|
|
986
|
+
if (member == null) return null;
|
|
987
|
+
if (member instanceof ServerMember2 || member instanceof User2) {
|
|
988
|
+
return member.id;
|
|
989
|
+
}
|
|
990
|
+
if (typeof member === "string") return member;
|
|
991
|
+
if ("_id" in member) return member._id.user;
|
|
992
|
+
return null;
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
// src/struct/server.ts
|
|
997
|
+
var Server2 = class extends Base {
|
|
998
|
+
/**
|
|
999
|
+
* Creates a new Server instance.
|
|
1000
|
+
*
|
|
1001
|
+
* @param {client} client - The client instance.
|
|
1002
|
+
* @param {APIServer} data - The raw data for the server from the API.
|
|
1003
|
+
*/
|
|
1004
|
+
constructor(client3, data) {
|
|
1005
|
+
super(client3);
|
|
1006
|
+
/** The description of the server, or `null` if none is set. */
|
|
1007
|
+
this.description = null;
|
|
1008
|
+
/** Manages the members of the server. */
|
|
1009
|
+
this.members = new ServerMemberManager(this);
|
|
1010
|
+
/** Manages the channels of the server. */
|
|
1011
|
+
this.channels = new ServerChannelManager(this);
|
|
1012
|
+
/** Manages the roles of the server. */
|
|
1013
|
+
this.roles = new RoleManager(this);
|
|
1014
|
+
/** The icon of the server, or `null` if none is set. */
|
|
1015
|
+
this.icon = null;
|
|
1016
|
+
/** The banner of the server, or `null` if none is set. */
|
|
1017
|
+
this.banner = null;
|
|
1018
|
+
/** Whether analytics are enabled for the server. */
|
|
1019
|
+
this.analytics = false;
|
|
1020
|
+
/** Whether the server is discoverable. */
|
|
1021
|
+
this.discoverable = false;
|
|
1022
|
+
/** Whether the server is marked as NSFW (Not Safe For Work). */
|
|
1023
|
+
this.nsfw = false;
|
|
1024
|
+
/** The categories in the server. */
|
|
1025
|
+
this.categories = /* @__PURE__ */ new Map();
|
|
1026
|
+
/** the emojies associated with the server */
|
|
1027
|
+
this.emojis = /* @__PURE__ */ new Map();
|
|
1028
|
+
this._patch(data);
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Updates the server instance with new data from the API.
|
|
1032
|
+
*
|
|
1033
|
+
* @param {APIServer} data - The raw data for the server from the API.
|
|
1034
|
+
* @param {FieldsServer[]} [clear=[]] - Fields to clear in the server.
|
|
1035
|
+
* @returns {this} The updated server instance.
|
|
1036
|
+
* @protected
|
|
1037
|
+
*/
|
|
1038
|
+
_patch(data, clear = []) {
|
|
1039
|
+
var _a;
|
|
1040
|
+
super._patch(data);
|
|
1041
|
+
if (Array.isArray(data.categories)) {
|
|
1042
|
+
this.categories.clear();
|
|
1043
|
+
for (const cat of data.categories) {
|
|
1044
|
+
const category = new Category(this, cat);
|
|
1045
|
+
this.categories.set(category.id, category);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
if (data.icon) {
|
|
1049
|
+
this.icon = new Attachment(this.client, data.icon);
|
|
1050
|
+
}
|
|
1051
|
+
if (data.banner) {
|
|
1052
|
+
this.banner = new Attachment(this.client, data.banner);
|
|
1053
|
+
}
|
|
1054
|
+
if (data.owner) {
|
|
1055
|
+
this.ownerId = data.owner;
|
|
1056
|
+
}
|
|
1057
|
+
if (data.name) {
|
|
1058
|
+
this.name = data.name;
|
|
1059
|
+
}
|
|
1060
|
+
if ("description" in data) {
|
|
1061
|
+
this.description = (_a = data.description) != null ? _a : null;
|
|
1062
|
+
}
|
|
1063
|
+
if (Array.isArray(data.channels)) {
|
|
1064
|
+
for (const id of data.channels) {
|
|
1065
|
+
const channel = this.client.channels.cache.get(id);
|
|
1066
|
+
if (channel == null ? void 0 : channel.inServer()) this.channels.cache.set(channel.id, channel);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
if (typeof data.roles === "object") {
|
|
1070
|
+
for (const [id, raw] of Object.entries(data.roles)) {
|
|
1071
|
+
this.roles._add(Object.assign(raw, { id }));
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
if (typeof data.default_permissions === "number") {
|
|
1075
|
+
this.permissions = new FullPermissions(data.default_permissions).freeze();
|
|
1076
|
+
}
|
|
1077
|
+
if (typeof data.analytics === "boolean") this.analytics = data.analytics;
|
|
1078
|
+
if (typeof data.discoverable === "boolean") {
|
|
1079
|
+
this.discoverable = data.discoverable;
|
|
1080
|
+
}
|
|
1081
|
+
if (typeof data.nsfw === "boolean") this.nsfw = data.nsfw;
|
|
1082
|
+
for (const field of clear) {
|
|
1083
|
+
if (field === "Icon") this.icon = null;
|
|
1084
|
+
if (field === "Description") this.description = null;
|
|
1085
|
+
if (field === "Banner") this.banner = null;
|
|
1086
|
+
}
|
|
1087
|
+
return this;
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Retrieves the current user's member instance in the server.
|
|
1091
|
+
*
|
|
1092
|
+
* @returns {ServerMember | null} The current user's member instance, or `null` if not found.
|
|
1093
|
+
*/
|
|
1094
|
+
get me() {
|
|
1095
|
+
var _a, _b;
|
|
1096
|
+
return (_b = this.members.cache.get((_a = this.client.user) == null ? void 0 : _a.id)) != null ? _b : null;
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Gets the creation date of the server.
|
|
1100
|
+
*
|
|
1101
|
+
* @returns {Date} The date when the server was created.
|
|
1102
|
+
*/
|
|
1103
|
+
get createdAt() {
|
|
1104
|
+
return UUID.timestampOf(this.id);
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Gets the creation timestamp of the server in milliseconds.
|
|
1108
|
+
*
|
|
1109
|
+
* @returns {number} The timestamp of when the server was created.
|
|
1110
|
+
*/
|
|
1111
|
+
get createdTimestamp() {
|
|
1112
|
+
return this.createdAt.getTime();
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Retrieves the owner of the server.
|
|
1116
|
+
*
|
|
1117
|
+
* @returns {User | null} The owner of the server, or `null` if not found.
|
|
1118
|
+
*/
|
|
1119
|
+
get owner() {
|
|
1120
|
+
var _a;
|
|
1121
|
+
return (_a = this.client.users.cache.get(this.ownerId)) != null ? _a : null;
|
|
1122
|
+
}
|
|
1123
|
+
// iconURL(options?: { size: number }): string | null {
|
|
1124
|
+
// return this.icon
|
|
1125
|
+
// ? this.client.api.cdn.icon(this.icon.id, options?.size)
|
|
1126
|
+
// : null;
|
|
1127
|
+
// }
|
|
1128
|
+
// bannerURL(options?: { size: number }): string | null {
|
|
1129
|
+
// return this.banner
|
|
1130
|
+
// ? this.client.api.cdn.banner(this.banner.id, options?.size)
|
|
1131
|
+
// : null;
|
|
1132
|
+
// }
|
|
1133
|
+
/**
|
|
1134
|
+
* Converts the server to a string representation.
|
|
1135
|
+
*
|
|
1136
|
+
* @returns {string} The name of the server.
|
|
1137
|
+
*/
|
|
1138
|
+
toString() {
|
|
1139
|
+
return this.name;
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
|
|
1143
|
+
// src/struct/role.ts
|
|
1144
|
+
var Role = class extends Base {
|
|
1145
|
+
/**
|
|
1146
|
+
* Creates a new Role instance.
|
|
1147
|
+
*
|
|
1148
|
+
* @param {Server} server - The server this role belongs to.
|
|
1149
|
+
* @param {APIRole & { id: string }} data - The raw data for the role from the API.
|
|
1150
|
+
*/
|
|
1151
|
+
constructor(server, data) {
|
|
1152
|
+
super(server.client);
|
|
1153
|
+
this.server = server;
|
|
1154
|
+
/** The color of the role, or `null` if no color is set. */
|
|
1155
|
+
this.color = null;
|
|
1156
|
+
/** Whether the role is displayed separately in the member list. */
|
|
1157
|
+
this.hoist = false;
|
|
1158
|
+
this._patch(data);
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Updates the role instance with new data from the API.
|
|
1162
|
+
*
|
|
1163
|
+
* @param {APIRole & { _id?: string }} data - The raw data for the role from the API.
|
|
1164
|
+
* @param {FieldsRole[]} [clear=[]] - Fields to clear in the role.
|
|
1165
|
+
* @returns {this} The updated role instance.
|
|
1166
|
+
* @protected
|
|
1167
|
+
*/
|
|
1168
|
+
_patch(data, clear = []) {
|
|
1169
|
+
var _a;
|
|
1170
|
+
super._patch(data);
|
|
1171
|
+
if (data.name) this.name = data.name;
|
|
1172
|
+
if (typeof data.hoist === "boolean") this.hoist = data.hoist;
|
|
1173
|
+
if (typeof data.rank === "number") this.rank = data.rank;
|
|
1174
|
+
if ("colour" in data) this.color = (_a = data.colour) != null ? _a : null;
|
|
1175
|
+
if (data.permissions) {
|
|
1176
|
+
const { a, d } = data.permissions;
|
|
1177
|
+
this.overwrite = {
|
|
1178
|
+
allow: new FullPermissions(a),
|
|
1179
|
+
deny: new FullPermissions(d)
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
for (const field of clear) {
|
|
1183
|
+
if (field === "Colour") this.color = null;
|
|
1184
|
+
}
|
|
1185
|
+
return this;
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Gets the date when the role was created.
|
|
1189
|
+
*
|
|
1190
|
+
* @returns {Date} The creation date of the role.
|
|
1191
|
+
*/
|
|
1192
|
+
get createdAt() {
|
|
1193
|
+
return UUID.timestampOf(this.id);
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Gets the timestamp of when the role was created.
|
|
1197
|
+
*
|
|
1198
|
+
* @returns {number} The creation timestamp of the role in milliseconds.
|
|
1199
|
+
*/
|
|
1200
|
+
get createdTimestamp() {
|
|
1201
|
+
return this.createdAt.getTime();
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Gets the permissions overwrite for the role.
|
|
1205
|
+
*
|
|
1206
|
+
* @returns {Overwrite} The permissions overwrite for the role.
|
|
1207
|
+
*/
|
|
1208
|
+
get permissions() {
|
|
1209
|
+
return this.overwrite;
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Deletes the role from the server.
|
|
1213
|
+
*
|
|
1214
|
+
* @returns {Promise<void>} A promise that resolves when the role is deleted.
|
|
1215
|
+
*
|
|
1216
|
+
* @example
|
|
1217
|
+
* ```typescript
|
|
1218
|
+
* await role.delete();
|
|
1219
|
+
* console.log("Role deleted successfully.");
|
|
1220
|
+
* ```
|
|
1221
|
+
*/
|
|
1222
|
+
delete() {
|
|
1223
|
+
return this.server.roles.delete(this);
|
|
1224
|
+
}
|
|
1225
|
+
edit(data) {
|
|
1226
|
+
return this.server.roles.edit(this, data);
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Converts the role to a string representation.
|
|
1230
|
+
*
|
|
1231
|
+
* @returns {string} A string representation of the role in the format `<@&roleId>`.
|
|
1232
|
+
*/
|
|
1233
|
+
toString() {
|
|
1234
|
+
return `<@&${this.id}>`;
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
// src/struct/clientUser.ts
|
|
1239
|
+
var ClientUser = class extends User2 {
|
|
1240
|
+
constructor() {
|
|
1241
|
+
super(...arguments);
|
|
1242
|
+
/** The notes channel associated with the client user, if any. */
|
|
1243
|
+
this.notes = null;
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* Updates the username of the client user.
|
|
1247
|
+
*
|
|
1248
|
+
* @param {string} username - The new username to set.
|
|
1249
|
+
* @param {string} [password] - The current password of the user (required for non-bot accounts).
|
|
1250
|
+
* @returns {Promise<void>} A promise that resolves when the username has been successfully updated.
|
|
1251
|
+
* @throws {Error} Throws an error if the client user is a bot and a password is provided.
|
|
1252
|
+
*
|
|
1253
|
+
* @example
|
|
1254
|
+
* ```typescript
|
|
1255
|
+
* await clientUser.setUsername("NewUsername", "CurrentPassword");
|
|
1256
|
+
* ```
|
|
1257
|
+
*/
|
|
1258
|
+
setUsername(username, password) {
|
|
1259
|
+
return __async(this, null, function* () {
|
|
1260
|
+
if (this.bot && password) {
|
|
1261
|
+
throw new Error("Bots do not have passwords");
|
|
1262
|
+
}
|
|
1263
|
+
yield this.client.api.patch("/users/@me/username", {
|
|
1264
|
+
body: { username, password }
|
|
1265
|
+
});
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Updates the status of the client user.
|
|
1270
|
+
*
|
|
1271
|
+
* @param {string | null} text - The status text to set, or `null` to clear the status.
|
|
1272
|
+
* @param {Status} [presence] - The presence status (e.g., online, idle, etc.).
|
|
1273
|
+
* @returns {Promise<void>} A promise that resolves when the status has been successfully updated.
|
|
1274
|
+
*
|
|
1275
|
+
* @example
|
|
1276
|
+
* ```typescript
|
|
1277
|
+
* await clientUser.setStatus("Available", "online");
|
|
1278
|
+
* ```
|
|
1279
|
+
*/
|
|
1280
|
+
setStatus(text, presence) {
|
|
1281
|
+
return __async(this, null, function* () {
|
|
1282
|
+
yield this.client.api.patch("/users/@me", {
|
|
1283
|
+
body: { status: { text, presence } }
|
|
1284
|
+
});
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
// src/client/webSocket.ts
|
|
1290
|
+
var WebSocketClient = class {
|
|
1291
|
+
/**
|
|
1292
|
+
* Creates a new WebSocketClient instance.
|
|
1293
|
+
*
|
|
1294
|
+
* @param {client} client - The client instance.
|
|
1295
|
+
*/
|
|
1296
|
+
constructor(client3) {
|
|
1297
|
+
this.client = client3;
|
|
1298
|
+
/** Whether the last pong acknowledgment was received. */
|
|
1299
|
+
this.lastPongAck = false;
|
|
1300
|
+
/** Whether the WebSocket client is connected. */
|
|
1301
|
+
this.connected = false;
|
|
1302
|
+
/** A promise representing the reconnecting process, or `null` if not reconnecting. */
|
|
1303
|
+
this.reconnecting = null;
|
|
1304
|
+
/** Whether the WebSocket client is ready. */
|
|
1305
|
+
this.ready = false;
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Logs a debug message.
|
|
1309
|
+
*
|
|
1310
|
+
* @param {unknown} message - The message to log.
|
|
1311
|
+
* @private
|
|
1312
|
+
*/
|
|
1313
|
+
debug(message) {
|
|
1314
|
+
this.client.debug(`[WS] ${message}`);
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Sends data through the WebSocket connection.
|
|
1318
|
+
*
|
|
1319
|
+
* @param {unknown} data - The data to send.
|
|
1320
|
+
* @returns {Promise<void>} A promise that resolves when the data is sent.
|
|
1321
|
+
* @throws {Error} Throws an error if the WebSocket is not open.
|
|
1322
|
+
*/
|
|
1323
|
+
send(data) {
|
|
1324
|
+
return __async(this, null, function* () {
|
|
1325
|
+
var _a;
|
|
1326
|
+
if (this.reconnecting) {
|
|
1327
|
+
this.debug("Reconnecting, waiting to send message.");
|
|
1328
|
+
yield this.reconnecting;
|
|
1329
|
+
}
|
|
1330
|
+
if (((_a = this.socket) == null ? void 0 : _a.readyState) === WebSocket.OPEN) {
|
|
1331
|
+
this.socket.send(JSON.stringify(data));
|
|
1332
|
+
} else {
|
|
1333
|
+
this.debug("Socket is not open, cannot send message.");
|
|
1334
|
+
throw new Error("Socket is not open");
|
|
1335
|
+
}
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Handles the WebSocket connection opening.
|
|
1340
|
+
*
|
|
1341
|
+
* @private
|
|
1342
|
+
*/
|
|
1343
|
+
onOpen() {
|
|
1344
|
+
if (!this.client.token) throw new Error("Token is required");
|
|
1345
|
+
this.send({
|
|
1346
|
+
type: "Authenticate" /* AUTHENTICATE */,
|
|
1347
|
+
token: this.client.token
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* Gets the current ping (latency) of the WebSocket connection.
|
|
1352
|
+
*
|
|
1353
|
+
* @returns {number} The ping in milliseconds, or `-0` if the WebSocket is not connected.
|
|
1354
|
+
*/
|
|
1355
|
+
get ping() {
|
|
1356
|
+
if (!this.socket) return -0;
|
|
1357
|
+
return Date.now() - this.lastPingTimestamp;
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Sets the heartbeat interval for the WebSocket connection.
|
|
1361
|
+
*
|
|
1362
|
+
* @param {number} time - The interval time in milliseconds. Use `-1` to clear the interval.
|
|
1363
|
+
*/
|
|
1364
|
+
setHeartbeatTimer(time) {
|
|
1365
|
+
this.debug(`Setting a heartbeat interval for ${time}ms.`);
|
|
1366
|
+
if (this.heartbeatInterval) {
|
|
1367
|
+
clearInterval(this.heartbeatInterval);
|
|
1368
|
+
}
|
|
1369
|
+
if (time !== -1) {
|
|
1370
|
+
this.heartbeatInterval = setInterval(() => this.sendHeartbeat(), time);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Sends a heartbeat to the server to keep the connection alive.
|
|
1375
|
+
*/
|
|
1376
|
+
sendHeartbeat() {
|
|
1377
|
+
var _a;
|
|
1378
|
+
this.debug("Sending heartbeat.");
|
|
1379
|
+
if (!this.lastPongAck) {
|
|
1380
|
+
this.debug("Did not receive a pong ack.");
|
|
1381
|
+
if ((_a = this.client.options.ws) == null ? void 0 : _a.reconnect) {
|
|
1382
|
+
this.reconnecting = this.destroy().then(() => this.connect()).then(() => this.reconnecting = null);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
const now = Date.now();
|
|
1386
|
+
this.send({ type: "Ping" /* PING */, data: now });
|
|
1387
|
+
this.lastPongAck = false;
|
|
1388
|
+
this.lastPingTimestamp = now;
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Handles WebSocket errors.
|
|
1392
|
+
*
|
|
1393
|
+
* @param {unknown} event - The error event.
|
|
1394
|
+
* @private
|
|
1395
|
+
*/
|
|
1396
|
+
onError(event) {
|
|
1397
|
+
this.client.emit("error" /* ERROR */, event);
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Handles incoming WebSocket messages.
|
|
1401
|
+
*
|
|
1402
|
+
* @param {{ data: unknown }} param0 - The message event containing the data.
|
|
1403
|
+
* @private
|
|
1404
|
+
*/
|
|
1405
|
+
onMessage({ data }) {
|
|
1406
|
+
let packet;
|
|
1407
|
+
try {
|
|
1408
|
+
packet = JSON.parse(String(data));
|
|
1409
|
+
} catch (err) {
|
|
1410
|
+
this.client.emit("error" /* ERROR */, err);
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
this.client.emit("raw" /* RAW */, packet);
|
|
1414
|
+
this.onPacket(packet).catch((e) => this.client.emit("error" /* ERROR */, e));
|
|
1415
|
+
}
|
|
1416
|
+
/**
|
|
1417
|
+
* Handles the WebSocket connection closing.
|
|
1418
|
+
*
|
|
1419
|
+
* @param {{ code: number; reason: string }} event - The close event containing the code and reason.
|
|
1420
|
+
* @private
|
|
1421
|
+
*/
|
|
1422
|
+
onClose(event) {
|
|
1423
|
+
this.debug(`Closed with reason: ${event.reason}, code: ${event.code}`);
|
|
1424
|
+
this.destroy();
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Handles incoming WebSocket packets.
|
|
1428
|
+
*
|
|
1429
|
+
* @param {any} packet - The packet data.
|
|
1430
|
+
* @private
|
|
1431
|
+
*/
|
|
1432
|
+
onPacket(packet) {
|
|
1433
|
+
return __async(this, null, function* () {
|
|
1434
|
+
var _a, _b, _c, _d;
|
|
1435
|
+
if (!packet) {
|
|
1436
|
+
this.debug(`Received broken packet: '${packet}'.`);
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
switch (packet.type) {
|
|
1440
|
+
case "Bulk" /* BULK */:
|
|
1441
|
+
yield Promise.all(packet.v.map((p) => this.onPacket(p)));
|
|
1442
|
+
break;
|
|
1443
|
+
case "Authenticated" /* AUTHENTICATED */:
|
|
1444
|
+
this.connected = true;
|
|
1445
|
+
break;
|
|
1446
|
+
case "Pong" /* PONG */:
|
|
1447
|
+
this.debug(`Received a heartbeat.`);
|
|
1448
|
+
this.lastPongAck = true;
|
|
1449
|
+
break;
|
|
1450
|
+
case "Error" /* ERROR */:
|
|
1451
|
+
this.client.emit("error" /* ERROR */, packet.error);
|
|
1452
|
+
break;
|
|
1453
|
+
case "Ready" /* READY */: {
|
|
1454
|
+
this.lastPongAck = true;
|
|
1455
|
+
const promises = [];
|
|
1456
|
+
for (const user of packet.users) {
|
|
1457
|
+
if (user.relationship === "User" && !this.client.user) {
|
|
1458
|
+
this.client.user = new ClientUser(this.client, user);
|
|
1459
|
+
} else {
|
|
1460
|
+
this.client.users._add(user);
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
for (const server of packet.servers) {
|
|
1464
|
+
const s = this.client.servers._add(server);
|
|
1465
|
+
if (this.client.options.fetchMembers) {
|
|
1466
|
+
promises.push(s.members.fetch());
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
for (const channel of packet.channels) {
|
|
1470
|
+
this.client.channels._add(channel);
|
|
1471
|
+
}
|
|
1472
|
+
for (const member of packet.members) {
|
|
1473
|
+
(_a = this.client.servers.cache.get(member._id.server)) == null ? void 0 : _a.members._add(member);
|
|
1474
|
+
}
|
|
1475
|
+
for (const emoji of packet.emojis) {
|
|
1476
|
+
(_b = this.client.servers.cache.get(emoji.parent.id)) == null ? void 0 : _b.emojis.set(emoji._id, __spreadProps(__spreadValues({}, emoji), { _id: emoji._id }));
|
|
1477
|
+
}
|
|
1478
|
+
this.setHeartbeatTimer(
|
|
1479
|
+
(_d = (_c = this.client.options.ws) == null ? void 0 : _c.heartbeatInterval) != null ? _d : 3e4
|
|
1480
|
+
);
|
|
1481
|
+
yield Promise.all(promises);
|
|
1482
|
+
this.ready = true;
|
|
1483
|
+
this.client.emit("ready" /* READY */, this.client);
|
|
1484
|
+
break;
|
|
1485
|
+
}
|
|
1486
|
+
default: {
|
|
1487
|
+
const action = this.client.events.get(packet.type);
|
|
1488
|
+
if (action) {
|
|
1489
|
+
yield action.handle(packet);
|
|
1490
|
+
} else {
|
|
1491
|
+
this.debug(`Received unknown packet "${packet.type}"`);
|
|
1492
|
+
}
|
|
1493
|
+
break;
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Connects to the WebSocket server.
|
|
1500
|
+
*
|
|
1501
|
+
* @returns {Promise<this>} A promise that resolves when the connection is established.
|
|
1502
|
+
*/
|
|
1503
|
+
connect() {
|
|
1504
|
+
return new Promise((resolve) => {
|
|
1505
|
+
var _a, _b;
|
|
1506
|
+
if (((_a = this.socket) == null ? void 0 : _a.readyState) === WebSocket.OPEN && this.ready) {
|
|
1507
|
+
return resolve(this);
|
|
1508
|
+
}
|
|
1509
|
+
if (typeof this.client.options === "undefined") {
|
|
1510
|
+
throw new Error("MISSING_CONFIGURATION_SYNC");
|
|
1511
|
+
}
|
|
1512
|
+
if (typeof this.client.token !== "string") {
|
|
1513
|
+
throw new Error("INVALID_TOKEN");
|
|
1514
|
+
}
|
|
1515
|
+
const ws = this.socket = (_b = this.socket) != null ? _b : new WebSocket(`${wsUrl}`);
|
|
1516
|
+
ws.onopen = this.onOpen.bind(this);
|
|
1517
|
+
ws.onmessage = this.onMessage.bind(this);
|
|
1518
|
+
ws.onerror = this.onError.bind(this);
|
|
1519
|
+
ws.onclose = this.onClose.bind(this);
|
|
1520
|
+
ws.addEventListener("open", () => resolve(this));
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Destroys the WebSocket connection and clears its state.
|
|
1525
|
+
*
|
|
1526
|
+
* @returns {Promise<void>} A promise that resolves when the connection is destroyed.
|
|
1527
|
+
*/
|
|
1528
|
+
destroy() {
|
|
1529
|
+
return new Promise((resolve) => {
|
|
1530
|
+
var _a;
|
|
1531
|
+
this.setHeartbeatTimer(-1);
|
|
1532
|
+
this.connected = false;
|
|
1533
|
+
this.ready = false;
|
|
1534
|
+
if (((_a = this.socket) == null ? void 0 : _a.readyState) === WebSocket.OPEN) {
|
|
1535
|
+
this.socket.addEventListener("close", () => {
|
|
1536
|
+
this.socket = null;
|
|
1537
|
+
resolve();
|
|
1538
|
+
});
|
|
1539
|
+
this.socket.close();
|
|
1540
|
+
} else {
|
|
1541
|
+
this.socket = null;
|
|
1542
|
+
resolve();
|
|
1543
|
+
}
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
// src/client/client.ts
|
|
1549
|
+
var client = class extends BaseClient {
|
|
1550
|
+
constructor() {
|
|
1551
|
+
super(...arguments);
|
|
1552
|
+
/** The WebSocket client used for real-time communication. */
|
|
1553
|
+
this.ws = new WebSocketClient(this);
|
|
1554
|
+
/** Manages the channels in the client. */
|
|
1555
|
+
this.channels = new ChannelManager(this);
|
|
1556
|
+
/** Manages the servers in the client. */
|
|
1557
|
+
this.servers = new ServerManager(this);
|
|
1558
|
+
/** Manages the users in the client. */
|
|
1559
|
+
this.users = new UserManager(this);
|
|
1560
|
+
/** Manages the events in the client. */
|
|
1561
|
+
this.events = new EventManager(this);
|
|
1562
|
+
/** The authenticated user, or `null` if not logged in. */
|
|
1563
|
+
this.user = null;
|
|
1564
|
+
/** The timestamp when the client became ready, or `null` if not ready. */
|
|
1565
|
+
this.readyAt = null;
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Gets the timestamp when the client became ready.
|
|
1569
|
+
*
|
|
1570
|
+
* @returns {number | null} The ready timestamp in milliseconds, or `null` if not ready.
|
|
1571
|
+
*/
|
|
1572
|
+
get readyTimestamp() {
|
|
1573
|
+
return this.readyAt ? this.readyAt.getTime() : null;
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* Gets the uptime of the client in milliseconds.
|
|
1577
|
+
*
|
|
1578
|
+
* @returns {number | null} The uptime in milliseconds, or `null` if the client is not ready.
|
|
1579
|
+
*/
|
|
1580
|
+
get upTime() {
|
|
1581
|
+
return this.readyAt ? Date.now() - this.readyAt.getTime() : null;
|
|
1582
|
+
}
|
|
1583
|
+
/**
|
|
1584
|
+
* Logs the client into the API using the provided token.
|
|
1585
|
+
*
|
|
1586
|
+
* @param {string} token - The authentication token.
|
|
1587
|
+
* @returns {Promise<void>} A promise that resolves when the client is logged in.
|
|
1588
|
+
* @throws {Error} Throws an error if the token is not provided or if the WebSocket connection fails.
|
|
1589
|
+
*
|
|
1590
|
+
* @example
|
|
1591
|
+
* ```typescript
|
|
1592
|
+
* await client.login("your-token-here");
|
|
1593
|
+
* ```
|
|
1594
|
+
*/
|
|
1595
|
+
login(token) {
|
|
1596
|
+
return __async(this, null, function* () {
|
|
1597
|
+
if (!token) throw new Error("Token is required");
|
|
1598
|
+
this.token = token;
|
|
1599
|
+
this.debug("Logging in...");
|
|
1600
|
+
try {
|
|
1601
|
+
yield this.ws.connect();
|
|
1602
|
+
} catch (error) {
|
|
1603
|
+
this.debug(`Error connecting to WebSocket: ${error}`);
|
|
1604
|
+
throw error;
|
|
1605
|
+
}
|
|
1606
|
+
this.readyAt = /* @__PURE__ */ new Date();
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
/**
|
|
1610
|
+
* Destroys the client, disconnecting it from the API and clearing its state.
|
|
1611
|
+
*
|
|
1612
|
+
* @returns {Promise<void>} A promise that resolves when the client is destroyed.
|
|
1613
|
+
*
|
|
1614
|
+
* @example
|
|
1615
|
+
* ```typescript
|
|
1616
|
+
* await client.destroy();
|
|
1617
|
+
* ```
|
|
1618
|
+
*/
|
|
1619
|
+
destroy() {
|
|
1620
|
+
return __async(this, null, function* () {
|
|
1621
|
+
this.token = null;
|
|
1622
|
+
this.user = null;
|
|
1623
|
+
this.readyAt = null;
|
|
1624
|
+
yield this.ws.destroy();
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Checks if the client is ready.
|
|
1629
|
+
*
|
|
1630
|
+
* @returns {boolean} `true` if the client is ready, otherwise `false`.
|
|
1631
|
+
*
|
|
1632
|
+
* @example
|
|
1633
|
+
* ```typescript
|
|
1634
|
+
* if (client.isReady()) {
|
|
1635
|
+
* console.log("Client is ready!");
|
|
1636
|
+
* }
|
|
1637
|
+
* ```
|
|
1638
|
+
*/
|
|
1639
|
+
isReady() {
|
|
1640
|
+
return this.readyAt !== null;
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
|
|
1644
|
+
// src/struct/dmChannel.ts
|
|
1645
|
+
var DMChannel2 = class extends Channel {
|
|
1646
|
+
/**
|
|
1647
|
+
* Creates a new DMChannel instance.
|
|
1648
|
+
*
|
|
1649
|
+
* @param {client} client - The client instance.
|
|
1650
|
+
* @param {APIDirectChannel} data - The raw data for the DM channel from the API.
|
|
1651
|
+
*/
|
|
1652
|
+
constructor(client3, data) {
|
|
1653
|
+
super(client3);
|
|
1654
|
+
/** The type of the channel, which is always `DM` for direct message channels. */
|
|
1655
|
+
this.type = "DM" /* DM */;
|
|
1656
|
+
/** The default permissions for the DM channel. */
|
|
1657
|
+
this.permissions = DEFAULT_PERMISSION_DM;
|
|
1658
|
+
/** Manages the messages in this DM channel. */
|
|
1659
|
+
this.messages = new MessageManager(this);
|
|
1660
|
+
/** The ID of the last message sent in this DM channel, if any. */
|
|
1661
|
+
this.lastMessageId = null;
|
|
1662
|
+
this._patch(data);
|
|
1663
|
+
}
|
|
1664
|
+
/**
|
|
1665
|
+
* Updates the DM channel instance with new data from the API.
|
|
1666
|
+
*
|
|
1667
|
+
* @param {APIDirectChannel} data - The raw data for the DM channel from the API.
|
|
1668
|
+
* @returns {this} The updated DM channel instance.
|
|
1669
|
+
* @protected
|
|
1670
|
+
*/
|
|
1671
|
+
_patch(data) {
|
|
1672
|
+
super._patch(data);
|
|
1673
|
+
if (typeof data.active === "boolean") this.active = data.active;
|
|
1674
|
+
if (data.last_message_id) this.lastMessageId = data.last_message_id;
|
|
1675
|
+
return this;
|
|
1676
|
+
}
|
|
1677
|
+
/**
|
|
1678
|
+
* Retrieves the last message sent in this DM channel.
|
|
1679
|
+
*
|
|
1680
|
+
* @returns {Message | null} The last message, or `null` if no message exists.
|
|
1681
|
+
*/
|
|
1682
|
+
get lastMessage() {
|
|
1683
|
+
var _a;
|
|
1684
|
+
if (!this.lastMessageId) return null;
|
|
1685
|
+
return (_a = this.messages.cache.get(this.lastMessageId)) != null ? _a : null;
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* Deletes multiple messages from this DM channel.
|
|
1689
|
+
*
|
|
1690
|
+
* @param {MessageResolvable[] | Map<string, Message> | number} messages - The messages to delete. This can be an array of message resolvables, a map of messages, or a number indicating how many recent messages to delete.
|
|
1691
|
+
* @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
|
|
1692
|
+
*
|
|
1693
|
+
* @example
|
|
1694
|
+
* ```typescript
|
|
1695
|
+
* await dmChannel.bulkDelete(10); // Deletes the last 10 messages.
|
|
1696
|
+
* ```
|
|
1697
|
+
*/
|
|
1698
|
+
bulkDelete(messages) {
|
|
1699
|
+
return this.messages.bulkDelete(messages);
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* Sends a message to this DM channel.
|
|
1703
|
+
*
|
|
1704
|
+
* @param {MessageOptions | string} options - The message content or options for the message.
|
|
1705
|
+
* @returns {Promise<Message>} A promise that resolves with the sent message.
|
|
1706
|
+
*
|
|
1707
|
+
* @example
|
|
1708
|
+
* ```typescript
|
|
1709
|
+
* await dmChannel.send("Hello, world!");
|
|
1710
|
+
* ```
|
|
1711
|
+
*/
|
|
1712
|
+
send(options) {
|
|
1713
|
+
return this.messages.send(options);
|
|
1714
|
+
}
|
|
1715
|
+
};
|
|
1716
|
+
|
|
1717
|
+
// src/struct/groupChannel.ts
|
|
1718
|
+
var GroupChannel2 = class extends Channel {
|
|
1719
|
+
/**
|
|
1720
|
+
* Creates a new GroupChannel instance.
|
|
1721
|
+
*
|
|
1722
|
+
* @param {client} client - The client instance.
|
|
1723
|
+
* @param {APIGroupChannel} data - The raw data for the group channel from the API.
|
|
1724
|
+
*/
|
|
1725
|
+
constructor(client3, data) {
|
|
1726
|
+
super(client3);
|
|
1727
|
+
/** The type of the channel, which is always `GROUP` for group channels. */
|
|
1728
|
+
this.type = "GROUP" /* GROUP */;
|
|
1729
|
+
/** The description of the group channel, if any. */
|
|
1730
|
+
this.description = null;
|
|
1731
|
+
/** The icon of the group channel, if any. */
|
|
1732
|
+
this.icon = null;
|
|
1733
|
+
/** Manages the messages in this group channel. */
|
|
1734
|
+
this.messages = new MessageManager(this);
|
|
1735
|
+
/** The ID of the last message sent in this group channel, if any. */
|
|
1736
|
+
this.lastMessageId = null;
|
|
1737
|
+
/** A map of user IDs to their corresponding `User` instances in the group channel. */
|
|
1738
|
+
this.users = /* @__PURE__ */ new Map();
|
|
1739
|
+
/** Whether the group channel is marked as NSFW (Not Safe For Work). */
|
|
1740
|
+
this.nsfw = false;
|
|
1741
|
+
this._patch(data);
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Updates the group channel instance with new data from the API.
|
|
1745
|
+
*
|
|
1746
|
+
* @param {APIGroupChannel} data - The raw data for the group channel from the API.
|
|
1747
|
+
* @returns {this} The updated group channel instance.
|
|
1748
|
+
* @protected
|
|
1749
|
+
*/
|
|
1750
|
+
_patch(data) {
|
|
1751
|
+
var _a;
|
|
1752
|
+
super._patch(data);
|
|
1753
|
+
if ("description" in data) {
|
|
1754
|
+
this.description = (_a = data.description) != null ? _a : null;
|
|
1755
|
+
}
|
|
1756
|
+
if (Array.isArray(data.recipients)) {
|
|
1757
|
+
this.users.clear();
|
|
1758
|
+
for (const userId of data.recipients) {
|
|
1759
|
+
const user = this.client.users.cache.get(userId);
|
|
1760
|
+
if (user) this.users.set(user.id, user);
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
if (typeof data.permissions === "number") {
|
|
1764
|
+
this.permissions = new ChannelPermissions(data.permissions).freeze();
|
|
1765
|
+
}
|
|
1766
|
+
if (data.owner) {
|
|
1767
|
+
this.ownerId = data.owner;
|
|
1768
|
+
}
|
|
1769
|
+
if (data.icon) {
|
|
1770
|
+
this.icon = new Attachment(this.client, data.icon);
|
|
1771
|
+
}
|
|
1772
|
+
if (data.name) {
|
|
1773
|
+
this.name = data.name;
|
|
1774
|
+
}
|
|
1775
|
+
if (data.last_message_id) this.lastMessageId = data.last_message_id;
|
|
1776
|
+
if (typeof data.nsfw === "boolean") this.nsfw = data.nsfw;
|
|
1777
|
+
return this;
|
|
1778
|
+
}
|
|
1779
|
+
/**
|
|
1780
|
+
* Retrieves the last message sent in this group channel.
|
|
1781
|
+
*
|
|
1782
|
+
* @returns {Message | null} The last message, or `null` if no message exists.
|
|
1783
|
+
*/
|
|
1784
|
+
get lastMessage() {
|
|
1785
|
+
var _a;
|
|
1786
|
+
if (!this.lastMessageId) return null;
|
|
1787
|
+
return (_a = this.messages.cache.get(this.lastMessageId)) != null ? _a : null;
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* Retrieves the owner of the group channel.
|
|
1791
|
+
*
|
|
1792
|
+
* @returns {User | null} The owner of the group channel, or `null` if not found.
|
|
1793
|
+
*/
|
|
1794
|
+
get owner() {
|
|
1795
|
+
var _a;
|
|
1796
|
+
return (_a = this.client.users.cache.get(this.ownerId)) != null ? _a : null;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Deletes multiple messages from this group channel.
|
|
1800
|
+
*
|
|
1801
|
+
* @param {MessageResolvable[] | Map<string, Message> | number} messages - The messages to delete. This can be an array of message resolvables, a map of messages, or a number indicating how many recent messages to delete.
|
|
1802
|
+
* @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
|
|
1803
|
+
*
|
|
1804
|
+
* @example
|
|
1805
|
+
* ```typescript
|
|
1806
|
+
* await groupChannel.bulkDelete(10); // Deletes the last 10 messages.
|
|
1807
|
+
* ```
|
|
1808
|
+
*/
|
|
1809
|
+
bulkDelete(messages) {
|
|
1810
|
+
return this.messages.bulkDelete(messages);
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Creates an invite for the group channel.
|
|
1814
|
+
*
|
|
1815
|
+
* @returns {Promise<Invite>} A promise that resolves with the created invite.
|
|
1816
|
+
*
|
|
1817
|
+
* @example
|
|
1818
|
+
* ```typescript
|
|
1819
|
+
* const invite = await groupChannel.createInvite();
|
|
1820
|
+
* console.log(`Invite created: ${invite}`);
|
|
1821
|
+
* ```
|
|
1822
|
+
*/
|
|
1823
|
+
createInvite() {
|
|
1824
|
+
return __async(this, null, function* () {
|
|
1825
|
+
const data = yield this.client.api.post(`/channels/${this.id}/invites`, {});
|
|
1826
|
+
return new Invite(
|
|
1827
|
+
this.client,
|
|
1828
|
+
data
|
|
1829
|
+
);
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Adds a user to the group channel.
|
|
1834
|
+
*
|
|
1835
|
+
* @param {UserResolvable} user - The user to add to the group channel.
|
|
1836
|
+
* @returns {Promise<void>} A promise that resolves when the user has been successfully added.
|
|
1837
|
+
*
|
|
1838
|
+
* @example
|
|
1839
|
+
* ```typescript
|
|
1840
|
+
* await groupChannel.add(user);
|
|
1841
|
+
* ```
|
|
1842
|
+
*/
|
|
1843
|
+
add(user) {
|
|
1844
|
+
return __async(this, null, function* () {
|
|
1845
|
+
const id = this.client.users.resolveId(user);
|
|
1846
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
1847
|
+
yield this.client.api.put(`/channels/${this.id}/recipients/${id}`);
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* Removes a user from the group channel.
|
|
1852
|
+
*
|
|
1853
|
+
* @param {UserResolvable} user - The user to remove from the group channel.
|
|
1854
|
+
* @returns {Promise<void>} A promise that resolves when the user has been successfully removed.
|
|
1855
|
+
*
|
|
1856
|
+
* @example
|
|
1857
|
+
* ```typescript
|
|
1858
|
+
* await groupChannel.remove(user);
|
|
1859
|
+
* ```
|
|
1860
|
+
*/
|
|
1861
|
+
remove(user) {
|
|
1862
|
+
return __async(this, null, function* () {
|
|
1863
|
+
const id = this.client.users.resolveId(user);
|
|
1864
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
1865
|
+
yield this.client.api.delete(`/channels/${this.id}/recipients/${id}`);
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
/**
|
|
1869
|
+
* Leaves the group channel.
|
|
1870
|
+
*
|
|
1871
|
+
* @returns {Promise<void>} A promise that resolves when the group channel has been successfully left.
|
|
1872
|
+
*
|
|
1873
|
+
* @example
|
|
1874
|
+
* ```typescript
|
|
1875
|
+
* await groupChannel.leave();
|
|
1876
|
+
* ```
|
|
1877
|
+
*/
|
|
1878
|
+
leave() {
|
|
1879
|
+
return super.delete();
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Sends a message to this group channel.
|
|
1883
|
+
*
|
|
1884
|
+
* @param {MessageOptions | string} options - The message content or options for the message.
|
|
1885
|
+
* @returns {Promise<Message>} A promise that resolves with the sent message.
|
|
1886
|
+
*
|
|
1887
|
+
* @example
|
|
1888
|
+
* ```typescript
|
|
1889
|
+
* await groupChannel.send("Hello, group!");
|
|
1890
|
+
* ```
|
|
1891
|
+
*/
|
|
1892
|
+
send(options) {
|
|
1893
|
+
return this.messages.send(options);
|
|
1894
|
+
}
|
|
1895
|
+
// iconURL(options?: { size: number }): string | null {
|
|
1896
|
+
// if (!this.icon) return null;
|
|
1897
|
+
// return this.client.api.cdn.icon(this.icon.id, options?.size);
|
|
1898
|
+
// }
|
|
1899
|
+
};
|
|
1900
|
+
|
|
1901
|
+
// src/struct/notesChannel.ts
|
|
1902
|
+
var NotesChannel = class extends Channel {
|
|
1903
|
+
/**
|
|
1904
|
+
* Creates a new NotesChannel instance.
|
|
1905
|
+
*
|
|
1906
|
+
* @param {client} client - The client instance.
|
|
1907
|
+
* @param {APINotesChannel} data - The raw data for the notes channel from the API.
|
|
1908
|
+
*/
|
|
1909
|
+
constructor(client3, data) {
|
|
1910
|
+
super(client3);
|
|
1911
|
+
/** The type of the channel, which is always `NOTES` for notes channels. */
|
|
1912
|
+
this.type = "NOTES" /* NOTES */;
|
|
1913
|
+
/** The ID of the last message sent in this notes channel, if any. */
|
|
1914
|
+
this.lastMessageId = null;
|
|
1915
|
+
/** Manages the messages in this notes channel. */
|
|
1916
|
+
this.messages = new MessageManager(this);
|
|
1917
|
+
this._patch(data);
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* Updates the notes channel instance with new data from the API.
|
|
1921
|
+
*
|
|
1922
|
+
* @param {APINotesChannel} data - The raw data for the notes channel from the API.
|
|
1923
|
+
* @returns {this} The updated notes channel instance.
|
|
1924
|
+
* @protected
|
|
1925
|
+
*/
|
|
1926
|
+
_patch(data) {
|
|
1927
|
+
super._patch(data);
|
|
1928
|
+
if (data.user) {
|
|
1929
|
+
this.userId = data.user;
|
|
1930
|
+
}
|
|
1931
|
+
return this;
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* Sends a message to this notes channel.
|
|
1935
|
+
*
|
|
1936
|
+
* @param {MessageOptions | string} options - The message content or options for the message.
|
|
1937
|
+
* @returns {Promise<Message>} A promise that resolves with the sent message.
|
|
1938
|
+
*
|
|
1939
|
+
* @example
|
|
1940
|
+
* ```typescript
|
|
1941
|
+
* await notesChannel.send("This is a saved message.");
|
|
1942
|
+
* ```
|
|
1943
|
+
*/
|
|
1944
|
+
send(options) {
|
|
1945
|
+
return this.messages.send(options);
|
|
1946
|
+
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Deletes multiple messages from this notes channel.
|
|
1949
|
+
*
|
|
1950
|
+
* @param {MessageResolvable[] | Map<string, Message> | number} messages - The messages to delete. This can be an array of message resolvables, a map of messages, or a number indicating how many recent messages to delete.
|
|
1951
|
+
* @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
|
|
1952
|
+
*
|
|
1953
|
+
* @example
|
|
1954
|
+
* ```typescript
|
|
1955
|
+
* await notesChannel.bulkDelete(5); // Deletes the last 5 messages.
|
|
1956
|
+
* ```
|
|
1957
|
+
*/
|
|
1958
|
+
bulkDelete(messages) {
|
|
1959
|
+
return this.messages.bulkDelete(messages);
|
|
1960
|
+
}
|
|
1961
|
+
/**
|
|
1962
|
+
* Retrieves the last message sent in this notes channel.
|
|
1963
|
+
*
|
|
1964
|
+
* @returns {Message | null} The last message, or `null` if no message exists.
|
|
1965
|
+
*/
|
|
1966
|
+
get lastMessage() {
|
|
1967
|
+
var _a;
|
|
1968
|
+
if (!this.lastMessageId) return null;
|
|
1969
|
+
return (_a = this.messages.cache.get(this.lastMessageId)) != null ? _a : null;
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Retrieves the user associated with this notes channel.
|
|
1973
|
+
*
|
|
1974
|
+
* @returns {User} The user associated with the notes channel.
|
|
1975
|
+
*/
|
|
1976
|
+
get user() {
|
|
1977
|
+
return this.client.user;
|
|
1978
|
+
}
|
|
1979
|
+
};
|
|
1980
|
+
|
|
1981
|
+
// src/struct/serverChannel.ts
|
|
1982
|
+
var ServerChannel = class extends Channel {
|
|
1983
|
+
/**
|
|
1984
|
+
* Creates a new ServerChannel instance.
|
|
1985
|
+
*
|
|
1986
|
+
* @param {client} client - The client instance.
|
|
1987
|
+
* @param {APIServerChannel} data - The raw data for the server channel from the API.
|
|
1988
|
+
*/
|
|
1989
|
+
constructor(client3, data) {
|
|
1990
|
+
super(client3);
|
|
1991
|
+
/** The description of the channel, or `null` if none is set. */
|
|
1992
|
+
this.description = null;
|
|
1993
|
+
/** The icon of the channel, or `null` if none is set. */
|
|
1994
|
+
this.icon = null;
|
|
1995
|
+
/** The permission overwrites for the channel. */
|
|
1996
|
+
this.overwrites = /* @__PURE__ */ new Map();
|
|
1997
|
+
/** Whether the channel is marked as NSFW (Not Safe For Work). */
|
|
1998
|
+
this.nsfw = false;
|
|
1999
|
+
this._patch(data);
|
|
2000
|
+
}
|
|
2001
|
+
/**
|
|
2002
|
+
* Updates the server channel instance with new data from the API.
|
|
2003
|
+
*
|
|
2004
|
+
* @param {APIServerChannel} data - The raw data for the server channel from the API.
|
|
2005
|
+
* @param {FieldsChannel[]} [clear=[]] - Fields to clear in the channel.
|
|
2006
|
+
* @returns {this} The updated server channel instance.
|
|
2007
|
+
* @protected
|
|
2008
|
+
*/
|
|
2009
|
+
_patch(data, clear = []) {
|
|
2010
|
+
var _a;
|
|
2011
|
+
super._patch(data);
|
|
2012
|
+
if (data.name) this.name = data.name;
|
|
2013
|
+
if (data.server) this.serverId = data.server;
|
|
2014
|
+
if ("description" in data) this.description = (_a = data.description) != null ? _a : null;
|
|
2015
|
+
if (data.icon) this.icon = new Attachment(this.client, data.icon);
|
|
2016
|
+
if (typeof data.nsfw === "boolean") this.nsfw = data.nsfw;
|
|
2017
|
+
if (data.role_permissions) {
|
|
2018
|
+
this.overwrites.clear();
|
|
2019
|
+
for (const [id, { a, d }] of Object.entries(data.role_permissions)) {
|
|
2020
|
+
this.overwrites.set(id, {
|
|
2021
|
+
allow: new FullPermissions(a),
|
|
2022
|
+
deny: new FullPermissions(d)
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
for (const field of clear) {
|
|
2027
|
+
if (field === "Icon") this.icon = null;
|
|
2028
|
+
if (field === "Description") this.description = null;
|
|
2029
|
+
}
|
|
2030
|
+
return this;
|
|
2031
|
+
}
|
|
2032
|
+
/**
|
|
2033
|
+
* Creates an invite for the server channel.
|
|
2034
|
+
*
|
|
2035
|
+
* @returns {Promise<Invite>} A promise that resolves with the created invite.
|
|
2036
|
+
*
|
|
2037
|
+
* @example
|
|
2038
|
+
* ```typescript
|
|
2039
|
+
* const invite = await serverChannel.createInvite();
|
|
2040
|
+
* console.log(`Invite created: ${invite}`);
|
|
2041
|
+
* ```
|
|
2042
|
+
*/
|
|
2043
|
+
createInvite() {
|
|
2044
|
+
return __async(this, null, function* () {
|
|
2045
|
+
const data = yield this.client.api.post(`/channels/${this.id}/invites`, {});
|
|
2046
|
+
return new Invite(
|
|
2047
|
+
this.client,
|
|
2048
|
+
data
|
|
2049
|
+
);
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
// iconURL(options?: { size: number }): string | null {
|
|
2053
|
+
// return this.icon
|
|
2054
|
+
// ? this.client.api.cdn.icon(this.icon.id, options?.size)
|
|
2055
|
+
// : null;
|
|
2056
|
+
// }
|
|
2057
|
+
/**
|
|
2058
|
+
* Retrieves the server this channel belongs to.
|
|
2059
|
+
*
|
|
2060
|
+
* @returns {Server} The server instance.
|
|
2061
|
+
*/
|
|
2062
|
+
get server() {
|
|
2063
|
+
return this.client.servers.cache.get(this.serverId);
|
|
2064
|
+
}
|
|
2065
|
+
/**
|
|
2066
|
+
* Retrieves the category this channel belongs to, if any.
|
|
2067
|
+
*
|
|
2068
|
+
* @returns {Category | null} The category instance, or `null` if the channel is not in a category.
|
|
2069
|
+
*/
|
|
2070
|
+
get category() {
|
|
2071
|
+
var _a;
|
|
2072
|
+
return (_a = Array.from(this.server.categories.values()).find(
|
|
2073
|
+
(cat) => cat.children.has(this.id)
|
|
2074
|
+
)) != null ? _a : null;
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
|
|
2078
|
+
// src/struct/serverMember.ts
|
|
2079
|
+
var ServerMember2 = class extends Base {
|
|
2080
|
+
/**
|
|
2081
|
+
* Creates a new ServerMember instance.
|
|
2082
|
+
*
|
|
2083
|
+
* @param {client} client - The client instance.
|
|
2084
|
+
* @param {APIMember} data - The raw data for the server member from the API.
|
|
2085
|
+
*/
|
|
2086
|
+
constructor(client3, data) {
|
|
2087
|
+
super(client3);
|
|
2088
|
+
/** The nickname of the member, or `null` if none is set. */
|
|
2089
|
+
this.nickname = null;
|
|
2090
|
+
/** The avatar of the member, or `null` if none is set. */
|
|
2091
|
+
this.avatar = null;
|
|
2092
|
+
/** roles assigned to the member */
|
|
2093
|
+
this.roles = [];
|
|
2094
|
+
this._patch(data);
|
|
2095
|
+
}
|
|
2096
|
+
/**
|
|
2097
|
+
* Updates the server member instance with new data from the API.
|
|
2098
|
+
*
|
|
2099
|
+
* @param {APIMember} data - The raw data for the server member from the API.
|
|
2100
|
+
* @param {FieldsMember[]} [clear=[]] - Fields to clear in the server member.
|
|
2101
|
+
* @returns {this} The updated server member instance.
|
|
2102
|
+
* @protected
|
|
2103
|
+
*/
|
|
2104
|
+
_patch(data, clear = []) {
|
|
2105
|
+
var _a;
|
|
2106
|
+
super._patch(data);
|
|
2107
|
+
if ("nickname" in data) {
|
|
2108
|
+
this.nickname = (_a = data.nickname) != null ? _a : null;
|
|
2109
|
+
}
|
|
2110
|
+
if (data.avatar) {
|
|
2111
|
+
this.avatar = new Attachment(this.client, data.avatar);
|
|
2112
|
+
}
|
|
2113
|
+
if (data._id) {
|
|
2114
|
+
this.serverId = data._id.server;
|
|
2115
|
+
this.id = data._id.user;
|
|
2116
|
+
}
|
|
2117
|
+
if (Array.isArray(data.roles)) {
|
|
2118
|
+
if (!data.roles.length) this.roles = [];
|
|
2119
|
+
else {
|
|
2120
|
+
this.roles = data.roles.map((roleId) => {
|
|
2121
|
+
const role = this.server.roles.cache.get(roleId);
|
|
2122
|
+
if (!role) {
|
|
2123
|
+
throw new Error(
|
|
2124
|
+
`Role with ID ${roleId} not found in server ${this.serverId}`
|
|
2125
|
+
);
|
|
2126
|
+
}
|
|
2127
|
+
return role;
|
|
2128
|
+
});
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
for (const field of clear) {
|
|
2132
|
+
if (field === "Avatar") this.avatar = null;
|
|
2133
|
+
if (field === "Nickname") this.nickname = null;
|
|
2134
|
+
}
|
|
2135
|
+
return this;
|
|
2136
|
+
}
|
|
2137
|
+
/**
|
|
2138
|
+
* Sets the nickname of the server member.
|
|
2139
|
+
*
|
|
2140
|
+
* @param {string} [nickname] - The new nickname to set, or `undefined` to clear the nickname.
|
|
2141
|
+
* @returns {Promise<this>} A promise that resolves with the updated server member instance.
|
|
2142
|
+
*
|
|
2143
|
+
* @example
|
|
2144
|
+
* ```typescript
|
|
2145
|
+
* await member.setNickname("NewNickname");
|
|
2146
|
+
* ```
|
|
2147
|
+
*/
|
|
2148
|
+
setNickname(nickname) {
|
|
2149
|
+
return __async(this, null, function* () {
|
|
2150
|
+
yield this.server.members.edit(this, { nickname });
|
|
2151
|
+
return this;
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2154
|
+
/**
|
|
2155
|
+
* adds a role to the server member.
|
|
2156
|
+
* @param roleId - The ID of the role to add to the member.
|
|
2157
|
+
* @returns
|
|
2158
|
+
*/
|
|
2159
|
+
addRole(roleId) {
|
|
2160
|
+
return __async(this, null, function* () {
|
|
2161
|
+
const currentRoles = this.roles.map((role) => role.id);
|
|
2162
|
+
if (currentRoles.includes(roleId)) {
|
|
2163
|
+
return this;
|
|
2164
|
+
}
|
|
2165
|
+
yield this.server.members.edit(this, {
|
|
2166
|
+
roles: [...currentRoles, roleId]
|
|
2167
|
+
});
|
|
2168
|
+
return this;
|
|
2169
|
+
});
|
|
2170
|
+
}
|
|
2171
|
+
/**
|
|
2172
|
+
* Removes a role from the server member.
|
|
2173
|
+
*
|
|
2174
|
+
* @param {string} roleId - The ID of the role to remove from the member.
|
|
2175
|
+
* @returns {Promise<this>} A promise that resolves with the updated server member instance.
|
|
2176
|
+
*
|
|
2177
|
+
* @example
|
|
2178
|
+
* ```typescript
|
|
2179
|
+
* await member.removeRole("roleId");
|
|
2180
|
+
* ```
|
|
2181
|
+
*/
|
|
2182
|
+
removeRole(roleId) {
|
|
2183
|
+
return __async(this, null, function* () {
|
|
2184
|
+
const currentRoles = this.roles.map((role) => role.id);
|
|
2185
|
+
if (!currentRoles.includes(roleId)) {
|
|
2186
|
+
return this;
|
|
2187
|
+
}
|
|
2188
|
+
yield this.server.members.edit(this, {
|
|
2189
|
+
roles: currentRoles.filter((id) => id !== roleId)
|
|
2190
|
+
});
|
|
2191
|
+
return this;
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
2195
|
+
* Bans the server member.
|
|
2196
|
+
*
|
|
2197
|
+
* @param {string} [reason] - The reason for the ban.
|
|
2198
|
+
* @returns {Promise<void>} A promise that resolves when the member is banned.
|
|
2199
|
+
*
|
|
2200
|
+
* @example
|
|
2201
|
+
* ```typescript
|
|
2202
|
+
* await member.ban("Violation of rules");
|
|
2203
|
+
* ```
|
|
2204
|
+
*/
|
|
2205
|
+
ban(reason) {
|
|
2206
|
+
return this.server.members.ban(this, reason);
|
|
2207
|
+
}
|
|
2208
|
+
/**
|
|
2209
|
+
* Kicks the server member.
|
|
2210
|
+
*
|
|
2211
|
+
* @returns {Promise<void>} A promise that resolves when the member is kicked.
|
|
2212
|
+
*
|
|
2213
|
+
* @example
|
|
2214
|
+
* ```typescript
|
|
2215
|
+
* await member.kick();
|
|
2216
|
+
* ```
|
|
2217
|
+
*/
|
|
2218
|
+
kick() {
|
|
2219
|
+
return this.server.members.kick(this);
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* Leaves the server.
|
|
2223
|
+
*
|
|
2224
|
+
* @returns {Promise<void>} A promise that resolves when the member leaves the server.
|
|
2225
|
+
*
|
|
2226
|
+
* @example
|
|
2227
|
+
* ```typescript
|
|
2228
|
+
* await member.leave();
|
|
2229
|
+
* ```
|
|
2230
|
+
*/
|
|
2231
|
+
leave() {
|
|
2232
|
+
return this.client.servers.delete(this.serverId);
|
|
2233
|
+
}
|
|
2234
|
+
// async displayAvatarURL(options?: { size: number }): Promise<string> {
|
|
2235
|
+
// return await this.user.displayAvatarURL(options);
|
|
2236
|
+
// }
|
|
2237
|
+
/**
|
|
2238
|
+
* Retrieves the user associated with this server member.
|
|
2239
|
+
*
|
|
2240
|
+
* @returns {User} The user instance.
|
|
2241
|
+
*/
|
|
2242
|
+
get user() {
|
|
2243
|
+
return this.client.users.cache.get(this.id);
|
|
2244
|
+
}
|
|
2245
|
+
/**
|
|
2246
|
+
* Retrieves the server this member belongs to.
|
|
2247
|
+
*
|
|
2248
|
+
* @returns {Server} The server instance.
|
|
2249
|
+
*/
|
|
2250
|
+
get server() {
|
|
2251
|
+
return this.client.servers.cache.get(this.serverId);
|
|
2252
|
+
}
|
|
2253
|
+
/**
|
|
2254
|
+
* Converts the server member to a string representation.
|
|
2255
|
+
*
|
|
2256
|
+
* @returns {string} A string representation of the server member in the format `<@userId>`.
|
|
2257
|
+
*/
|
|
2258
|
+
toString() {
|
|
2259
|
+
return `<@${this.id}>`;
|
|
2260
|
+
}
|
|
2261
|
+
};
|
|
2262
|
+
|
|
2263
|
+
// src/struct/textChannel.ts
|
|
2264
|
+
var TextChannel2 = class extends ServerChannel {
|
|
2265
|
+
/**
|
|
2266
|
+
* Creates a new TextChannel instance.
|
|
2267
|
+
*
|
|
2268
|
+
* @param {client} client - The client instance.
|
|
2269
|
+
* @param {APITextChannel} data - The raw data for the text channel from the API.
|
|
2270
|
+
*/
|
|
2271
|
+
constructor(client3, data) {
|
|
2272
|
+
super(client3, data);
|
|
2273
|
+
/** The ID of the last message sent in this text channel, if any. */
|
|
2274
|
+
this.lastMessageId = null;
|
|
2275
|
+
/** Manages the messages in this text channel. */
|
|
2276
|
+
this.messages = new MessageManager(this);
|
|
2277
|
+
/** The type of the channel, which is always `TEXT` for text channels. */
|
|
2278
|
+
this.type = "TEXT" /* TEXT */;
|
|
2279
|
+
this._patch(data);
|
|
2280
|
+
}
|
|
2281
|
+
/**
|
|
2282
|
+
* Updates the text channel instance with new data from the API.
|
|
2283
|
+
*
|
|
2284
|
+
* @param {APITextChannel} data - The raw data for the text channel from the API.
|
|
2285
|
+
* @returns {this} The updated text channel instance.
|
|
2286
|
+
* @protected
|
|
2287
|
+
*/
|
|
2288
|
+
_patch(data) {
|
|
2289
|
+
super._patch(data);
|
|
2290
|
+
if (data.last_message_id) this.lastMessageId = data.last_message_id;
|
|
2291
|
+
return this;
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* Retrieves the last message sent in this text channel.
|
|
2295
|
+
*
|
|
2296
|
+
* @returns {Message | null} The last message, or `null` if no message exists.
|
|
2297
|
+
*/
|
|
2298
|
+
get lastMessage() {
|
|
2299
|
+
var _a;
|
|
2300
|
+
if (!this.lastMessageId) return null;
|
|
2301
|
+
return (_a = this.messages.cache.get(this.lastMessageId)) != null ? _a : null;
|
|
2302
|
+
}
|
|
2303
|
+
/**
|
|
2304
|
+
* Sends a message to this text channel.
|
|
2305
|
+
*
|
|
2306
|
+
* @param {MessageOptions | string} options - The message content or options for the message.
|
|
2307
|
+
* @returns {Promise<Message>} A promise that resolves with the sent message.
|
|
2308
|
+
*
|
|
2309
|
+
* @example
|
|
2310
|
+
* ```typescript
|
|
2311
|
+
* await textChannel.send("Hello, world!");
|
|
2312
|
+
* ```
|
|
2313
|
+
*/
|
|
2314
|
+
send(options) {
|
|
2315
|
+
return this.messages.send(options);
|
|
2316
|
+
}
|
|
2317
|
+
/**
|
|
2318
|
+
* Deletes multiple messages from this text channel.
|
|
2319
|
+
*
|
|
2320
|
+
* @param {MessageResolvable[] | Map<string, Message> | number} messages - The messages to delete. This can be an array of message resolvables, a map of messages, or a number indicating how many recent messages to delete.
|
|
2321
|
+
* @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
|
|
2322
|
+
*
|
|
2323
|
+
* @example
|
|
2324
|
+
* ```typescript
|
|
2325
|
+
* await textChannel.bulkDelete(10); // Deletes the last 10 messages.
|
|
2326
|
+
* ```
|
|
2327
|
+
*/
|
|
2328
|
+
bulkDelete(messages) {
|
|
2329
|
+
return this.messages.bulkDelete(messages);
|
|
2330
|
+
}
|
|
2331
|
+
};
|
|
2332
|
+
|
|
2333
|
+
// src/struct/voiceChannels.ts
|
|
2334
|
+
var VoiceChannel = class extends ServerChannel {
|
|
2335
|
+
/**
|
|
2336
|
+
* Creates a new VoiceChannel instance.
|
|
2337
|
+
*
|
|
2338
|
+
* @param {client} client - The client instance.
|
|
2339
|
+
* @param {APIVoiceChannel} data - The raw data for the voice channel from the API.
|
|
2340
|
+
*/
|
|
2341
|
+
constructor(client3, data) {
|
|
2342
|
+
super(client3, data);
|
|
2343
|
+
/** The type of the channel, which is always `VOICE` for voice channels. */
|
|
2344
|
+
this.type = "VOICE" /* VOICE */;
|
|
2345
|
+
this._patch(data);
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Updates the voice channel instance with new data from the API.
|
|
2349
|
+
*
|
|
2350
|
+
* @param {APIVoiceChannel} data - The raw data for the voice channel from the API.
|
|
2351
|
+
* @returns {this} The updated voice channel instance.
|
|
2352
|
+
* @protected
|
|
2353
|
+
*/
|
|
2354
|
+
_patch(data) {
|
|
2355
|
+
super._patch(data);
|
|
2356
|
+
return this;
|
|
2357
|
+
}
|
|
2358
|
+
/**
|
|
2359
|
+
* Acknowledges the voice channel.
|
|
2360
|
+
*
|
|
2361
|
+
* @throws {TypeError} Throws an error because voice channels cannot be acknowledged.
|
|
2362
|
+
*
|
|
2363
|
+
* @example
|
|
2364
|
+
* ```typescript
|
|
2365
|
+
* try {
|
|
2366
|
+
* await voiceChannel.ack();
|
|
2367
|
+
* } catch (error) {
|
|
2368
|
+
* console.error(error.message); // "Cannot ack voice channel"
|
|
2369
|
+
* }
|
|
2370
|
+
* ```
|
|
2371
|
+
*/
|
|
2372
|
+
ack() {
|
|
2373
|
+
throw new TypeError("Cannot ack voice channel");
|
|
2374
|
+
}
|
|
2375
|
+
};
|
|
2376
|
+
|
|
2377
|
+
// src/struct/category.ts
|
|
2378
|
+
var Category = class extends Base {
|
|
2379
|
+
/**
|
|
2380
|
+
* Creates a new Category instance.
|
|
2381
|
+
*
|
|
2382
|
+
* @param {Server} server - The server this category belongs to.
|
|
2383
|
+
* @param {APICategory} data - The raw data for the category from the API.
|
|
2384
|
+
*/
|
|
2385
|
+
constructor(server, data) {
|
|
2386
|
+
super(server.client);
|
|
2387
|
+
this.server = server;
|
|
2388
|
+
/** An array of channel IDs that belong to this category. */
|
|
2389
|
+
this._children = [];
|
|
2390
|
+
this._patch(data);
|
|
2391
|
+
}
|
|
2392
|
+
/**
|
|
2393
|
+
* Updates the category instance with new data from the API.
|
|
2394
|
+
*
|
|
2395
|
+
* @param {APICategory} data - The raw data for the category from the API.
|
|
2396
|
+
* @returns {this} The updated category instance.
|
|
2397
|
+
* @protected
|
|
2398
|
+
*/
|
|
2399
|
+
_patch(data) {
|
|
2400
|
+
super._patch(data);
|
|
2401
|
+
if (data.title) {
|
|
2402
|
+
this.name = data.title;
|
|
2403
|
+
}
|
|
2404
|
+
if (Array.isArray(data.channels)) {
|
|
2405
|
+
this._children = data.channels;
|
|
2406
|
+
}
|
|
2407
|
+
return this;
|
|
2408
|
+
}
|
|
2409
|
+
/**
|
|
2410
|
+
* Retrieves the channels that belong to this category.
|
|
2411
|
+
*
|
|
2412
|
+
* @returns {Map<string, ServerChannel>} A map of channel IDs to their corresponding `ServerChannel` instances.
|
|
2413
|
+
*/
|
|
2414
|
+
get children() {
|
|
2415
|
+
const coll = /* @__PURE__ */ new Map();
|
|
2416
|
+
for (const childId of this._children) {
|
|
2417
|
+
const child = this.server.channels.cache.get(childId);
|
|
2418
|
+
if (child) coll.set(child.id, child);
|
|
2419
|
+
}
|
|
2420
|
+
return coll;
|
|
2421
|
+
}
|
|
2422
|
+
/**
|
|
2423
|
+
* Converts the category to a string representation.
|
|
2424
|
+
*
|
|
2425
|
+
* @returns {string} The name of the category.
|
|
2426
|
+
*/
|
|
2427
|
+
toString() {
|
|
2428
|
+
return this.name;
|
|
2429
|
+
}
|
|
2430
|
+
};
|
|
2431
|
+
|
|
2432
|
+
// src/struct/user.ts
|
|
2433
|
+
var User2 = class extends Base {
|
|
2434
|
+
/**
|
|
2435
|
+
* Creates a new User instance.
|
|
2436
|
+
*
|
|
2437
|
+
* @param {client} client - The client instance.
|
|
2438
|
+
* @param {APIUser} data - The raw data for the user from the API.
|
|
2439
|
+
*/
|
|
2440
|
+
constructor(client3, data) {
|
|
2441
|
+
super(client3);
|
|
2442
|
+
/** The avatar of the user, or `null` if none is set. */
|
|
2443
|
+
this.avatar = null;
|
|
2444
|
+
/** The presence status of the user. */
|
|
2445
|
+
this.presence = new Presence(this.client);
|
|
2446
|
+
/** Whether the user is a bot. */
|
|
2447
|
+
this.bot = false;
|
|
2448
|
+
this._patch(data);
|
|
2449
|
+
}
|
|
2450
|
+
/**
|
|
2451
|
+
* Updates the user instance with new data from the API.
|
|
2452
|
+
*
|
|
2453
|
+
* @param {APIUser} data - The raw data for the user from the API.
|
|
2454
|
+
* @param {FieldsUser[]} [clear=[]] - Fields to clear in the user.
|
|
2455
|
+
* @returns {this} The updated user instance.
|
|
2456
|
+
* @protected
|
|
2457
|
+
*/
|
|
2458
|
+
_patch(data, clear = []) {
|
|
2459
|
+
var _a, _b;
|
|
2460
|
+
super._patch(data);
|
|
2461
|
+
if (data.username) {
|
|
2462
|
+
this.username = data.username;
|
|
2463
|
+
}
|
|
2464
|
+
if (data.bot) {
|
|
2465
|
+
this.bot = true;
|
|
2466
|
+
}
|
|
2467
|
+
if (typeof data.badges === "number") {
|
|
2468
|
+
this.badges = new Badges(data.badges).freeze();
|
|
2469
|
+
}
|
|
2470
|
+
if (data.avatar) {
|
|
2471
|
+
this.avatar = new Attachment(this.client, data.avatar);
|
|
2472
|
+
}
|
|
2473
|
+
if (data.status) {
|
|
2474
|
+
this.presence.status = data.status.presence ? (_a = Status[data.status.presence]) != null ? _a : "OFFLINE" /* Invisible */ : "OFFLINE" /* Invisible */;
|
|
2475
|
+
this.presence.text = (_b = data.status.text) != null ? _b : null;
|
|
2476
|
+
}
|
|
2477
|
+
for (const field of clear) {
|
|
2478
|
+
if (field === "Avatar") this.avatar = null;
|
|
2479
|
+
if (field === "StatusText") this.presence.text = null;
|
|
2480
|
+
if (field === "StatusPresence") this.presence.status = "OFFLINE" /* Invisible */;
|
|
2481
|
+
}
|
|
2482
|
+
return this;
|
|
2483
|
+
}
|
|
2484
|
+
/**
|
|
2485
|
+
* Gets the creation date of the user.
|
|
2486
|
+
*
|
|
2487
|
+
* @returns {Date} The date when the user was created.
|
|
2488
|
+
*/
|
|
2489
|
+
get createdAt() {
|
|
2490
|
+
return UUID.timestampOf(this.id);
|
|
2491
|
+
}
|
|
2492
|
+
/**
|
|
2493
|
+
* Gets the creation timestamp of the user in milliseconds.
|
|
2494
|
+
*
|
|
2495
|
+
* @returns {number} The timestamp of when the user was created.
|
|
2496
|
+
*/
|
|
2497
|
+
get createdTimestamp() {
|
|
2498
|
+
return this.createdAt.getTime();
|
|
2499
|
+
}
|
|
2500
|
+
/**
|
|
2501
|
+
* Blocks the user.
|
|
2502
|
+
*
|
|
2503
|
+
* @returns {Promise<void>} A promise that resolves when the user is blocked.
|
|
2504
|
+
*
|
|
2505
|
+
* @example
|
|
2506
|
+
* ```typescript
|
|
2507
|
+
* await user.block();
|
|
2508
|
+
* ```
|
|
2509
|
+
*/
|
|
2510
|
+
block() {
|
|
2511
|
+
return __async(this, null, function* () {
|
|
2512
|
+
yield this.client.api.put(`/users/${this.id}/block`);
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
/**
|
|
2516
|
+
* Unblocks the user.
|
|
2517
|
+
*
|
|
2518
|
+
* @returns {Promise<void>} A promise that resolves when the user is unblocked.
|
|
2519
|
+
*
|
|
2520
|
+
* @example
|
|
2521
|
+
* ```typescript
|
|
2522
|
+
* await user.unblock();
|
|
2523
|
+
* ```
|
|
2524
|
+
*/
|
|
2525
|
+
unblock() {
|
|
2526
|
+
return __async(this, null, function* () {
|
|
2527
|
+
yield this.client.api.delete(`/users/${this.id}/block`);
|
|
2528
|
+
});
|
|
2529
|
+
}
|
|
2530
|
+
/**
|
|
2531
|
+
* Creates a direct message (DM) channel with the user.
|
|
2532
|
+
*
|
|
2533
|
+
* @returns {Promise<DMChannel>} A promise that resolves with the created DM channel.
|
|
2534
|
+
*
|
|
2535
|
+
* @example
|
|
2536
|
+
* ```typescript
|
|
2537
|
+
* const dmChannel = await user.createDM();
|
|
2538
|
+
* ```
|
|
2539
|
+
*/
|
|
2540
|
+
createDM() {
|
|
2541
|
+
return __async(this, null, function* () {
|
|
2542
|
+
const data = yield this.client.api.get(`/users/${this.id}/dm`);
|
|
2543
|
+
return this.client.channels._add(data);
|
|
2544
|
+
});
|
|
2545
|
+
}
|
|
2546
|
+
avatarURL() {
|
|
2547
|
+
var _a, _b;
|
|
2548
|
+
if (!((_a = this.avatar) == null ? void 0 : _a.id)) return void 0;
|
|
2549
|
+
return `${cdnUrl}/avatars/${(_b = this.avatar) == null ? void 0 : _b.id}`;
|
|
2550
|
+
}
|
|
2551
|
+
displayAvatarURL() {
|
|
2552
|
+
return __async(this, null, function* () {
|
|
2553
|
+
var _a;
|
|
2554
|
+
const defaultAvatar = `${cdnUrl}/users/${this.id}/default_avatar`;
|
|
2555
|
+
return (_a = this.avatarURL()) != null ? _a : defaultAvatar;
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
/**
|
|
2559
|
+
* Fetches the latest data for the user from the API.
|
|
2560
|
+
*
|
|
2561
|
+
* @param {boolean} [force=false] - Whether to force a fetch even if the user is cached.
|
|
2562
|
+
* @returns {Promise<User>} A promise that resolves with the updated user instance.
|
|
2563
|
+
*/
|
|
2564
|
+
fetch(force = false) {
|
|
2565
|
+
return this.client.users.fetch(this, { force });
|
|
2566
|
+
}
|
|
2567
|
+
/**
|
|
2568
|
+
* Converts the user to a string representation.
|
|
2569
|
+
*
|
|
2570
|
+
* @returns {string} A string representation of the user in the format `<@userId>`.
|
|
2571
|
+
*/
|
|
2572
|
+
toString() {
|
|
2573
|
+
return `<@${this.id}>`;
|
|
2574
|
+
}
|
|
2575
|
+
};
|
|
2576
|
+
|
|
2577
|
+
export {
|
|
2578
|
+
User2 as User,
|
|
2579
|
+
Message,
|
|
2580
|
+
Server2 as Server,
|
|
2581
|
+
Role,
|
|
2582
|
+
DMChannel2 as DMChannel,
|
|
2583
|
+
GroupChannel2 as GroupChannel,
|
|
2584
|
+
NotesChannel,
|
|
2585
|
+
ServerChannel,
|
|
2586
|
+
ServerMember2 as ServerMember,
|
|
2587
|
+
TextChannel2 as TextChannel,
|
|
2588
|
+
VoiceChannel,
|
|
2589
|
+
Category,
|
|
2590
|
+
ChannelManager,
|
|
2591
|
+
ServerManager,
|
|
2592
|
+
UserManager,
|
|
2593
|
+
MessageManager,
|
|
2594
|
+
RoleManager,
|
|
2595
|
+
ServerChannelManager,
|
|
2596
|
+
ServerMemberManager,
|
|
2597
|
+
ClientUser,
|
|
2598
|
+
WebSocketClient,
|
|
2599
|
+
client
|
|
2600
|
+
};
|
|
2601
|
+
//# sourceMappingURL=chunk-XQEYCTYC.js.map
|