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,2970 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
13
|
+
var __typeError = (msg) => {
|
|
14
|
+
throw TypeError(msg);
|
|
15
|
+
};
|
|
16
|
+
var __pow = Math.pow;
|
|
17
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
18
|
+
var __spreadValues = (a, b) => {
|
|
19
|
+
for (var prop in b || (b = {}))
|
|
20
|
+
if (__hasOwnProp.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
if (__getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
24
|
+
if (__propIsEnum.call(b, prop))
|
|
25
|
+
__defNormalProp(a, prop, b[prop]);
|
|
26
|
+
}
|
|
27
|
+
return a;
|
|
28
|
+
};
|
|
29
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
30
|
+
var __export = (target, all) => {
|
|
31
|
+
for (var name in all)
|
|
32
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
33
|
+
};
|
|
34
|
+
var __copyProps = (to, from, except, desc) => {
|
|
35
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
36
|
+
for (let key of __getOwnPropNames(from))
|
|
37
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
38
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
39
|
+
}
|
|
40
|
+
return to;
|
|
41
|
+
};
|
|
42
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
43
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
44
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
45
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
46
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
47
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
48
|
+
mod
|
|
49
|
+
));
|
|
50
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
51
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
52
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
53
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
54
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
55
|
+
var __async = (__this, __arguments, generator) => {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
var fulfilled = (value) => {
|
|
58
|
+
try {
|
|
59
|
+
step(generator.next(value));
|
|
60
|
+
} catch (e) {
|
|
61
|
+
reject(e);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var rejected = (value) => {
|
|
65
|
+
try {
|
|
66
|
+
step(generator.throw(value));
|
|
67
|
+
} catch (e) {
|
|
68
|
+
reject(e);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
72
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
var __await = function(promise, isYieldStar) {
|
|
76
|
+
this[0] = promise;
|
|
77
|
+
this[1] = isYieldStar;
|
|
78
|
+
};
|
|
79
|
+
var __yieldStar = (value) => {
|
|
80
|
+
var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
|
|
81
|
+
if (obj == null) {
|
|
82
|
+
obj = value[__knownSymbol("iterator")]();
|
|
83
|
+
method = (k) => it[k] = (x) => obj[k](x);
|
|
84
|
+
} else {
|
|
85
|
+
obj = obj.call(value);
|
|
86
|
+
method = (k) => it[k] = (v) => {
|
|
87
|
+
if (isAwait) {
|
|
88
|
+
isAwait = false;
|
|
89
|
+
if (k === "throw") throw v;
|
|
90
|
+
return v;
|
|
91
|
+
}
|
|
92
|
+
isAwait = true;
|
|
93
|
+
return {
|
|
94
|
+
done: false,
|
|
95
|
+
value: new __await(new Promise((resolve) => {
|
|
96
|
+
var x = obj[k](v);
|
|
97
|
+
if (!(x instanceof Object)) __typeError("Object expected");
|
|
98
|
+
resolve(x);
|
|
99
|
+
}), 1)
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
|
|
104
|
+
throw x;
|
|
105
|
+
}, "return" in obj && method("return"), it;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// src/struct/index.ts
|
|
109
|
+
var struct_exports = {};
|
|
110
|
+
__export(struct_exports, {
|
|
111
|
+
Attachment: () => Attachment,
|
|
112
|
+
Base: () => Base,
|
|
113
|
+
Category: () => Category,
|
|
114
|
+
Channel: () => Channel,
|
|
115
|
+
DMChannel: () => DMChannel3,
|
|
116
|
+
Emoji: () => Emoji,
|
|
117
|
+
GroupChannel: () => GroupChannel2,
|
|
118
|
+
Invite: () => Invite,
|
|
119
|
+
Mentions: () => Mentions,
|
|
120
|
+
Message: () => Message,
|
|
121
|
+
MessageEmbed: () => MessageEmbed2,
|
|
122
|
+
NotesChannel: () => NotesChannel,
|
|
123
|
+
Presence: () => Presence,
|
|
124
|
+
Role: () => Role,
|
|
125
|
+
Server: () => Server2,
|
|
126
|
+
ServerChannel: () => ServerChannel,
|
|
127
|
+
ServerMember: () => ServerMember2,
|
|
128
|
+
Status: () => Status,
|
|
129
|
+
TextChannel: () => TextChannel2,
|
|
130
|
+
User: () => User,
|
|
131
|
+
VoiceChannel: () => VoiceChannel
|
|
132
|
+
});
|
|
133
|
+
module.exports = __toCommonJS(struct_exports);
|
|
134
|
+
|
|
135
|
+
// src/utils/bitField.ts
|
|
136
|
+
var DEFAULT_BIT = 0;
|
|
137
|
+
var _BitField = class _BitField {
|
|
138
|
+
constructor(bits = DEFAULT_BIT) {
|
|
139
|
+
this.bitfield = DEFAULT_BIT;
|
|
140
|
+
this.bitfield = this.self.resolve(bits);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Resolves a bitfield or an array of bitfields into a single number.
|
|
144
|
+
* @param bit The bitfield or array of bitfields to resolve.
|
|
145
|
+
* @returns The resolved bitfield as a number.
|
|
146
|
+
*/
|
|
147
|
+
static resolve(bit) {
|
|
148
|
+
if (bit instanceof _BitField) return bit.bitfield;
|
|
149
|
+
if (typeof bit === "number" && bit >= DEFAULT_BIT) return bit;
|
|
150
|
+
if (Array.isArray(bit)) {
|
|
151
|
+
return bit.map((p) => this.resolve(p)).reduce((prev, p) => prev | p, DEFAULT_BIT);
|
|
152
|
+
}
|
|
153
|
+
if (typeof this.FLAGS[bit] !== "undefined") return this.FLAGS[bit];
|
|
154
|
+
throw new Error("BITFIELD_INVALID");
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Returns the class that this instance belongs to.
|
|
158
|
+
* @returns The class of the bitfield.
|
|
159
|
+
*/
|
|
160
|
+
get self() {
|
|
161
|
+
return this.constructor;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Checks if any of the bits in the bitfield are set.
|
|
165
|
+
* @param bit The bitfield or array of bitfields to check.
|
|
166
|
+
* @returns True if any bits are set, false otherwise.
|
|
167
|
+
*/
|
|
168
|
+
any(bit) {
|
|
169
|
+
bit = this.self.resolve(bit);
|
|
170
|
+
return (this.bitfield & bit) !== DEFAULT_BIT;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* checks if a specific permission is set.
|
|
174
|
+
*/
|
|
175
|
+
has(bit) {
|
|
176
|
+
bit = this.self.resolve(bit);
|
|
177
|
+
return (this.bitfield & bit) === bit;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Returns an array of all the Permissions that are set in the bitfield.
|
|
181
|
+
* @returns An array of flag names.
|
|
182
|
+
*/
|
|
183
|
+
toArray() {
|
|
184
|
+
return Object.keys(this.self.FLAGS).filter((bit) => this.has(bit));
|
|
185
|
+
}
|
|
186
|
+
add(...bits) {
|
|
187
|
+
let total = 0;
|
|
188
|
+
for (const bit of bits) {
|
|
189
|
+
total |= this.self.resolve(bit);
|
|
190
|
+
}
|
|
191
|
+
if (Object.isFrozen(this)) {
|
|
192
|
+
return new this.self(this.bitfield | total);
|
|
193
|
+
}
|
|
194
|
+
this.bitfield |= total;
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
remove(...bits) {
|
|
198
|
+
let total = 0;
|
|
199
|
+
for (const bit of bits) {
|
|
200
|
+
total |= this.self.resolve(bit);
|
|
201
|
+
}
|
|
202
|
+
if (Object.isFrozen(this)) {
|
|
203
|
+
return new this.self(this.bitfield & ~total);
|
|
204
|
+
}
|
|
205
|
+
this.bitfield &= ~total;
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
freeze() {
|
|
209
|
+
return Object.freeze(this);
|
|
210
|
+
}
|
|
211
|
+
valueOf() {
|
|
212
|
+
return this.bitfield;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
*
|
|
216
|
+
* @returns A record of all flags and their boolean values indicating whether they are set.
|
|
217
|
+
*/
|
|
218
|
+
serialize() {
|
|
219
|
+
const serialized = {};
|
|
220
|
+
for (const [flag, bit] of Object.entries(this.self.FLAGS)) {
|
|
221
|
+
serialized[flag] = this.has(bit);
|
|
222
|
+
}
|
|
223
|
+
return serialized;
|
|
224
|
+
}
|
|
225
|
+
*[Symbol.iterator]() {
|
|
226
|
+
yield* __yieldStar(this.toArray());
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
_BitField.FLAGS = {};
|
|
230
|
+
var BitField = _BitField;
|
|
231
|
+
|
|
232
|
+
// src/struct/base.ts
|
|
233
|
+
var Base = class _Base {
|
|
234
|
+
/**
|
|
235
|
+
* Creates a new Base instance.
|
|
236
|
+
*
|
|
237
|
+
* @param {client} client - The client instance.
|
|
238
|
+
*/
|
|
239
|
+
constructor(client3) {
|
|
240
|
+
this.client = client3;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Compares this object with another to determine if they are equal.
|
|
244
|
+
*
|
|
245
|
+
* @param {this | null} [obj] - The object to compare with.
|
|
246
|
+
* @returns {boolean} `true` if the objects are equal, otherwise `false`.
|
|
247
|
+
*/
|
|
248
|
+
equals(obj) {
|
|
249
|
+
if (!obj) return false;
|
|
250
|
+
for (const key in obj) {
|
|
251
|
+
const a = obj[key], b = this[key];
|
|
252
|
+
if (a instanceof _Base && !a.equals(b)) return false;
|
|
253
|
+
if (a instanceof BitField && a.bitfield !== b.bitfield)
|
|
254
|
+
return false;
|
|
255
|
+
if (typeof a === "object" && a !== null) continue;
|
|
256
|
+
if (a !== b) return false;
|
|
257
|
+
}
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Updates the object with new data and returns a clone of the object.
|
|
262
|
+
*
|
|
263
|
+
* @param {PartialObject} data - The data to update the object with.
|
|
264
|
+
* @param {string[]} [clear] - Fields to clear in the object.
|
|
265
|
+
* @returns {this} A clone of the updated object.
|
|
266
|
+
*/
|
|
267
|
+
_update(data, clear) {
|
|
268
|
+
const clone = this._clone();
|
|
269
|
+
this._patch(data, clear);
|
|
270
|
+
return clone;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Patches the object with new data.
|
|
274
|
+
*
|
|
275
|
+
* @param {PartialObject} data - The data to patch the object with.
|
|
276
|
+
* @param {string[]} [_clear] - Fields to clear in the object.
|
|
277
|
+
* @returns {this} The updated object.
|
|
278
|
+
* @protected
|
|
279
|
+
*/
|
|
280
|
+
_patch(data, _clear) {
|
|
281
|
+
if ("id" in data) this.id = data.id;
|
|
282
|
+
if ("_id" in data) {
|
|
283
|
+
if (typeof data._id === "string") this.id = data._id;
|
|
284
|
+
if (typeof data._id === "object") this.id = data._id.user;
|
|
285
|
+
}
|
|
286
|
+
return this;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Creates a deep clone of the object.
|
|
290
|
+
*
|
|
291
|
+
* @returns {this} A clone of the object.
|
|
292
|
+
*/
|
|
293
|
+
_clone() {
|
|
294
|
+
const clone = Object.assign(Object.create(this), this);
|
|
295
|
+
for (const key in clone) {
|
|
296
|
+
const prop = clone[key];
|
|
297
|
+
if (prop instanceof _Base) clone[key] = prop._clone();
|
|
298
|
+
}
|
|
299
|
+
return clone;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// src/utils/UUID.ts
|
|
304
|
+
var import_crypto = require("crypto");
|
|
305
|
+
var _UUID = class _UUID extends null {
|
|
306
|
+
static get PROG() {
|
|
307
|
+
return (0, import_crypto.randomBytes)(1).readUInt8() / 255;
|
|
308
|
+
}
|
|
309
|
+
static time(now = Date.now()) {
|
|
310
|
+
let mod, result = "";
|
|
311
|
+
for (let i = this.TIME_LENGTH; i > 0; i--) {
|
|
312
|
+
mod = now % this.ENCODING_LENGTH;
|
|
313
|
+
result = this.ENCODING.charAt(mod) + result;
|
|
314
|
+
now = (now - mod) / this.ENCODING_LENGTH;
|
|
315
|
+
}
|
|
316
|
+
return result;
|
|
317
|
+
}
|
|
318
|
+
static hash() {
|
|
319
|
+
let result = "";
|
|
320
|
+
for (let i = this.RANDOM_LENGTH; i > 0; i--) {
|
|
321
|
+
let random = Math.floor(this.PROG * this.ENCODING_LENGTH);
|
|
322
|
+
if (random === this.ENCODING_LENGTH) {
|
|
323
|
+
random = this.ENCODING_LENGTH - 1;
|
|
324
|
+
}
|
|
325
|
+
result = this.ENCODING.charAt(random) + result;
|
|
326
|
+
}
|
|
327
|
+
return result;
|
|
328
|
+
}
|
|
329
|
+
static generate(timestamp = Date.now()) {
|
|
330
|
+
return this.time(timestamp) + this.hash();
|
|
331
|
+
}
|
|
332
|
+
static timestampOf(id) {
|
|
333
|
+
const timestamp = id.slice(0, this.TIME_LENGTH).split("").reverse().reduce((carry, char, index) => {
|
|
334
|
+
const encodingIndex = this.ENCODING.indexOf(char);
|
|
335
|
+
if (encodingIndex === -1) {
|
|
336
|
+
throw new Error("invalid character found: " + char);
|
|
337
|
+
}
|
|
338
|
+
return carry += encodingIndex * Math.pow(this.ENCODING_LENGTH, index);
|
|
339
|
+
}, 0);
|
|
340
|
+
return new Date(timestamp);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
_UUID.ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
344
|
+
_UUID.ENCODING_LENGTH = _UUID.ENCODING.length;
|
|
345
|
+
_UUID.RANDOM_LENGTH = 16;
|
|
346
|
+
_UUID.TIME_LENGTH = 10;
|
|
347
|
+
_UUID.TIME_MAX = Math.pow(2, 48) - 1;
|
|
348
|
+
var UUID = _UUID;
|
|
349
|
+
|
|
350
|
+
// src/utils/constants.ts
|
|
351
|
+
var cdnUrl = "https://cdn.revoltusercontent.com";
|
|
352
|
+
var SYSTEM_USER_ID = "0".repeat(UUID.TIME_LENGTH + UUID.RANDOM_LENGTH);
|
|
353
|
+
|
|
354
|
+
// src/utils/permissions.ts
|
|
355
|
+
var ChannelPermissions = class extends BitField {
|
|
356
|
+
constructor(bits) {
|
|
357
|
+
super(bits);
|
|
358
|
+
}
|
|
359
|
+
static resolve(bit) {
|
|
360
|
+
return super.resolve(bit);
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
ChannelPermissions.FLAGS = {
|
|
364
|
+
VIEW_CHANNEL: __pow(1, 0),
|
|
365
|
+
SEND_MESSAGE: __pow(1, 22),
|
|
366
|
+
MANAGE_MESSAGE: __pow(1, 2),
|
|
367
|
+
MANAGE_CHANNEL: __pow(1, 3),
|
|
368
|
+
VOICE_CALL: __pow(1, 4),
|
|
369
|
+
INVITE_OTHERS: __pow(1, 5),
|
|
370
|
+
EMBED_LINKS: __pow(1, 6),
|
|
371
|
+
UPLOAD_FILES: __pow(1, 7)
|
|
372
|
+
};
|
|
373
|
+
var UserPermissions = class extends BitField {
|
|
374
|
+
constructor(bits) {
|
|
375
|
+
super(bits);
|
|
376
|
+
}
|
|
377
|
+
static resolve(bit) {
|
|
378
|
+
return super.resolve(bit);
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
UserPermissions.FLAGS = {
|
|
382
|
+
ACCESS: __pow(1, 0),
|
|
383
|
+
VIEW_PROFILE: __pow(1, 1),
|
|
384
|
+
SEND_MESSAGES: __pow(1, 2),
|
|
385
|
+
INVITE: __pow(1, 3)
|
|
386
|
+
};
|
|
387
|
+
var ServerPermissions = class extends BitField {
|
|
388
|
+
constructor(bits) {
|
|
389
|
+
super(bits);
|
|
390
|
+
}
|
|
391
|
+
static resolve(bit) {
|
|
392
|
+
return super.resolve(bit);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
ServerPermissions.FLAGS = {
|
|
396
|
+
VIEW_SERVER: __pow(1, 0),
|
|
397
|
+
MANAGE_ROLES: __pow(1, 1),
|
|
398
|
+
MANAGE_CHANNELS: __pow(1, 2),
|
|
399
|
+
MANAGE_SERVER: __pow(1, 3),
|
|
400
|
+
KICK_MEMBERS: __pow(1, 4),
|
|
401
|
+
BAN_MEMBERS: __pow(1, 5),
|
|
402
|
+
CHANGE_NICKNAME: __pow(1, 12),
|
|
403
|
+
MANAGE_NICKNAMES: __pow(1, 13),
|
|
404
|
+
CHANGE_AVATAR: __pow(1, 14),
|
|
405
|
+
REMOVE_AVATARS: __pow(1, 15)
|
|
406
|
+
};
|
|
407
|
+
var FullPermissions = class extends BitField {
|
|
408
|
+
constructor(bits) {
|
|
409
|
+
super(bits);
|
|
410
|
+
}
|
|
411
|
+
static resolve(bit) {
|
|
412
|
+
return super.resolve(bit);
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
FullPermissions.FLAGS = {
|
|
416
|
+
// * Generic permissions
|
|
417
|
+
/// Manage the channel or channels on the server
|
|
418
|
+
ManageChannel: __pow(2, 0),
|
|
419
|
+
/// Manage the server
|
|
420
|
+
ManageServer: __pow(2, 1),
|
|
421
|
+
/// Manage permissions on servers or channels
|
|
422
|
+
ManagePermissions: __pow(2, 2),
|
|
423
|
+
/// Manage roles on server
|
|
424
|
+
ManageRole: __pow(2, 3),
|
|
425
|
+
/// Manage server customisation (includes emoji)
|
|
426
|
+
ManageCustomisation: __pow(2, 4),
|
|
427
|
+
// * Member permissions
|
|
428
|
+
/// Kick other members below their ranking
|
|
429
|
+
KickMembers: __pow(2, 6),
|
|
430
|
+
/// Ban other members below their ranking
|
|
431
|
+
BanMembers: __pow(2, 7),
|
|
432
|
+
/// Timeout other members below their ranking
|
|
433
|
+
TimeoutMembers: __pow(2, 8),
|
|
434
|
+
/// Assign roles to members below their ranking
|
|
435
|
+
AssignRoles: __pow(2, 9),
|
|
436
|
+
/// Change own nickname
|
|
437
|
+
ChangeNickname: __pow(2, 10),
|
|
438
|
+
/// Change or remove other's nicknames below their ranking
|
|
439
|
+
ManageNicknames: __pow(2, 11),
|
|
440
|
+
/// Change own avatar
|
|
441
|
+
ChangeAvatar: __pow(2, 12),
|
|
442
|
+
/// Remove other's avatars below their ranking
|
|
443
|
+
RemoveAvatars: __pow(2, 13),
|
|
444
|
+
// * Channel permissions
|
|
445
|
+
/// View a channel
|
|
446
|
+
ViewChannel: __pow(2, 20),
|
|
447
|
+
/// Read a channel's past message history
|
|
448
|
+
ReadMessageHistory: __pow(2, 21),
|
|
449
|
+
/// Send a message in a channel
|
|
450
|
+
SendMessage: __pow(2, 22),
|
|
451
|
+
/// Delete messages in a channel
|
|
452
|
+
ManageMessages: __pow(2, 23),
|
|
453
|
+
/// Manage webhook entries on a channel
|
|
454
|
+
ManageWebhooks: __pow(2, 24),
|
|
455
|
+
/// Create invites to this channel
|
|
456
|
+
InviteOthers: __pow(2, 25),
|
|
457
|
+
/// Send embedded content in this channel
|
|
458
|
+
SendEmbeds: __pow(2, 26),
|
|
459
|
+
/// Send attachments and media in this channel
|
|
460
|
+
UploadFiles: __pow(2, 27),
|
|
461
|
+
/// Masquerade messages using custom nickname and avatar
|
|
462
|
+
Masquerade: __pow(2, 28),
|
|
463
|
+
/// React to messages with emoji
|
|
464
|
+
React: __pow(2, 29),
|
|
465
|
+
// * Voice permissions
|
|
466
|
+
/// Connect to a voice channel
|
|
467
|
+
Connect: __pow(2, 30),
|
|
468
|
+
/// Speak in a voice call
|
|
469
|
+
Speak: __pow(2, 31),
|
|
470
|
+
/// Share video in a voice call
|
|
471
|
+
Video: __pow(2, 32),
|
|
472
|
+
/// Mute other members with lower ranking in a voice call
|
|
473
|
+
MuteMembers: __pow(2, 33),
|
|
474
|
+
/// Deafen other members with lower ranking in a voice call
|
|
475
|
+
DeafenMembers: __pow(2, 34),
|
|
476
|
+
/// Move members between voice channels
|
|
477
|
+
MoveMembers: __pow(2, 35),
|
|
478
|
+
// * Mention permissions
|
|
479
|
+
/// Mention @everyone or @online
|
|
480
|
+
MentionEveryone: __pow(2, 37),
|
|
481
|
+
/// Mention a role
|
|
482
|
+
MentionRoles: __pow(2, 38),
|
|
483
|
+
// * Grant all permissions
|
|
484
|
+
/// Safely grant all permissions
|
|
485
|
+
GrantAll: 4503599627370495
|
|
486
|
+
};
|
|
487
|
+
var DEFAULT_PERMISSION_DM = new ChannelPermissions([
|
|
488
|
+
"VIEW_CHANNEL",
|
|
489
|
+
"VIEW_CHANNEL",
|
|
490
|
+
"MANAGE_CHANNEL",
|
|
491
|
+
"VOICE_CALL",
|
|
492
|
+
"EMBED_LINKS",
|
|
493
|
+
"UPLOAD_FILES"
|
|
494
|
+
]).freeze();
|
|
495
|
+
|
|
496
|
+
// src/utils/badges.ts
|
|
497
|
+
var Badges = class extends BitField {
|
|
498
|
+
constructor(bits) {
|
|
499
|
+
super(bits);
|
|
500
|
+
}
|
|
501
|
+
static resolve(bit) {
|
|
502
|
+
return super.resolve(bit);
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
Badges.FLAGS = {
|
|
506
|
+
DEVELOPER: 1 << 0,
|
|
507
|
+
TRANSLATOR: 1 << 1,
|
|
508
|
+
SUPPORTER: 1 << 2,
|
|
509
|
+
RESPONSIBLE_DISCLOSURE: 1 << 3,
|
|
510
|
+
REVOLT_TEAM: 1 << 4,
|
|
511
|
+
EARLY_ADOPTER: 1 << 8
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
// src/struct/user.ts
|
|
515
|
+
var User = class extends Base {
|
|
516
|
+
/**
|
|
517
|
+
* Creates a new User instance.
|
|
518
|
+
*
|
|
519
|
+
* @param {client} client - The client instance.
|
|
520
|
+
* @param {APIUser} data - The raw data for the user from the API.
|
|
521
|
+
*/
|
|
522
|
+
constructor(client3, data) {
|
|
523
|
+
super(client3);
|
|
524
|
+
/** The avatar of the user, or `null` if none is set. */
|
|
525
|
+
this.avatar = null;
|
|
526
|
+
/** The presence status of the user. */
|
|
527
|
+
this.presence = new Presence(this.client);
|
|
528
|
+
/** Whether the user is a bot. */
|
|
529
|
+
this.bot = false;
|
|
530
|
+
this._patch(data);
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Updates the user instance with new data from the API.
|
|
534
|
+
*
|
|
535
|
+
* @param {APIUser} data - The raw data for the user from the API.
|
|
536
|
+
* @param {FieldsUser[]} [clear=[]] - Fields to clear in the user.
|
|
537
|
+
* @returns {this} The updated user instance.
|
|
538
|
+
* @protected
|
|
539
|
+
*/
|
|
540
|
+
_patch(data, clear = []) {
|
|
541
|
+
var _a, _b;
|
|
542
|
+
super._patch(data);
|
|
543
|
+
if (data.username) {
|
|
544
|
+
this.username = data.username;
|
|
545
|
+
}
|
|
546
|
+
if (data.bot) {
|
|
547
|
+
this.bot = true;
|
|
548
|
+
}
|
|
549
|
+
if (typeof data.badges === "number") {
|
|
550
|
+
this.badges = new Badges(data.badges).freeze();
|
|
551
|
+
}
|
|
552
|
+
if (data.avatar) {
|
|
553
|
+
this.avatar = new Attachment(this.client, data.avatar);
|
|
554
|
+
}
|
|
555
|
+
if (data.status) {
|
|
556
|
+
this.presence.status = data.status.presence ? (_a = Status[data.status.presence]) != null ? _a : "OFFLINE" /* Invisible */ : "OFFLINE" /* Invisible */;
|
|
557
|
+
this.presence.text = (_b = data.status.text) != null ? _b : null;
|
|
558
|
+
}
|
|
559
|
+
for (const field of clear) {
|
|
560
|
+
if (field === "Avatar") this.avatar = null;
|
|
561
|
+
if (field === "StatusText") this.presence.text = null;
|
|
562
|
+
if (field === "StatusPresence") this.presence.status = "OFFLINE" /* Invisible */;
|
|
563
|
+
}
|
|
564
|
+
return this;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Gets the creation date of the user.
|
|
568
|
+
*
|
|
569
|
+
* @returns {Date} The date when the user was created.
|
|
570
|
+
*/
|
|
571
|
+
get createdAt() {
|
|
572
|
+
return UUID.timestampOf(this.id);
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Gets the creation timestamp of the user in milliseconds.
|
|
576
|
+
*
|
|
577
|
+
* @returns {number} The timestamp of when the user was created.
|
|
578
|
+
*/
|
|
579
|
+
get createdTimestamp() {
|
|
580
|
+
return this.createdAt.getTime();
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Blocks the user.
|
|
584
|
+
*
|
|
585
|
+
* @returns {Promise<void>} A promise that resolves when the user is blocked.
|
|
586
|
+
*
|
|
587
|
+
* @example
|
|
588
|
+
* ```typescript
|
|
589
|
+
* await user.block();
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
block() {
|
|
593
|
+
return __async(this, null, function* () {
|
|
594
|
+
yield this.client.api.put(`/users/${this.id}/block`);
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Unblocks the user.
|
|
599
|
+
*
|
|
600
|
+
* @returns {Promise<void>} A promise that resolves when the user is unblocked.
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* ```typescript
|
|
604
|
+
* await user.unblock();
|
|
605
|
+
* ```
|
|
606
|
+
*/
|
|
607
|
+
unblock() {
|
|
608
|
+
return __async(this, null, function* () {
|
|
609
|
+
yield this.client.api.delete(`/users/${this.id}/block`);
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Creates a direct message (DM) channel with the user.
|
|
614
|
+
*
|
|
615
|
+
* @returns {Promise<DMChannel>} A promise that resolves with the created DM channel.
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```typescript
|
|
619
|
+
* const dmChannel = await user.createDM();
|
|
620
|
+
* ```
|
|
621
|
+
*/
|
|
622
|
+
createDM() {
|
|
623
|
+
return __async(this, null, function* () {
|
|
624
|
+
const data = yield this.client.api.get(`/users/${this.id}/dm`);
|
|
625
|
+
return this.client.channels._add(data);
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
avatarURL() {
|
|
629
|
+
var _a, _b;
|
|
630
|
+
if (!((_a = this.avatar) == null ? void 0 : _a.id)) return void 0;
|
|
631
|
+
return `${cdnUrl}/avatars/${(_b = this.avatar) == null ? void 0 : _b.id}`;
|
|
632
|
+
}
|
|
633
|
+
displayAvatarURL() {
|
|
634
|
+
return __async(this, null, function* () {
|
|
635
|
+
var _a;
|
|
636
|
+
const defaultAvatar = `${cdnUrl}/users/${this.id}/default_avatar`;
|
|
637
|
+
return (_a = this.avatarURL()) != null ? _a : defaultAvatar;
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Fetches the latest data for the user from the API.
|
|
642
|
+
*
|
|
643
|
+
* @param {boolean} [force=false] - Whether to force a fetch even if the user is cached.
|
|
644
|
+
* @returns {Promise<User>} A promise that resolves with the updated user instance.
|
|
645
|
+
*/
|
|
646
|
+
fetch(force = false) {
|
|
647
|
+
return this.client.users.fetch(this, { force });
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Converts the user to a string representation.
|
|
651
|
+
*
|
|
652
|
+
* @returns {string} A string representation of the user in the format `<@userId>`.
|
|
653
|
+
*/
|
|
654
|
+
toString() {
|
|
655
|
+
return `<@${this.id}>`;
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
// src/struct/message.ts
|
|
660
|
+
var Message = class extends Base {
|
|
661
|
+
/**
|
|
662
|
+
* Creates a new Message instance.
|
|
663
|
+
*
|
|
664
|
+
* @param {client} client - The client instance.
|
|
665
|
+
* @param {APIMessage} data - The raw data for the message from the API.
|
|
666
|
+
*/
|
|
667
|
+
constructor(client3, data) {
|
|
668
|
+
super(client3);
|
|
669
|
+
/** The type of the message (e.g., TEXT, SYSTEM). */
|
|
670
|
+
this.type = "TEXT";
|
|
671
|
+
/** The content of the message. */
|
|
672
|
+
this.content = "";
|
|
673
|
+
/** The ID of the channel where the message was sent. */
|
|
674
|
+
this.channelId = "";
|
|
675
|
+
/** The ID of the user who authored the message. */
|
|
676
|
+
this.authorId = "";
|
|
677
|
+
/** An array of embeds included in the message. */
|
|
678
|
+
this.embeds = [];
|
|
679
|
+
/** An array of file attachments included in the message. */
|
|
680
|
+
this.attachments = [];
|
|
681
|
+
/** Mentions included in the message. */
|
|
682
|
+
this.mentions = new Mentions(this, []);
|
|
683
|
+
/** The timestamp of when the message was last edited, or `null` if not edited. */
|
|
684
|
+
this.editedTimestamp = null;
|
|
685
|
+
/** the reactions and count on a message */
|
|
686
|
+
this.reactions = /* @__PURE__ */ new Map();
|
|
687
|
+
this._patch(data);
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Updates the message instance with new data from the API.
|
|
691
|
+
*
|
|
692
|
+
* @param {APIMessage} data - The raw data for the message from the API.
|
|
693
|
+
* @returns {this} The updated message instance.
|
|
694
|
+
* @protected
|
|
695
|
+
*/
|
|
696
|
+
_patch(data) {
|
|
697
|
+
super._patch(data);
|
|
698
|
+
if (Array.isArray(data.embeds)) {
|
|
699
|
+
this.embeds = data.embeds;
|
|
700
|
+
}
|
|
701
|
+
if (Array.isArray(data.attachments)) {
|
|
702
|
+
this.attachments = data.attachments;
|
|
703
|
+
}
|
|
704
|
+
if (Array.isArray(data.mentions)) {
|
|
705
|
+
this.mentions = new Mentions(this, data.mentions);
|
|
706
|
+
}
|
|
707
|
+
if (data.author) {
|
|
708
|
+
this.authorId = data.author;
|
|
709
|
+
}
|
|
710
|
+
if (data.channel) {
|
|
711
|
+
this.channelId = data.channel;
|
|
712
|
+
}
|
|
713
|
+
if (typeof data.content === "string") {
|
|
714
|
+
this.content = data.content;
|
|
715
|
+
}
|
|
716
|
+
if (data.system) {
|
|
717
|
+
this.type = data.system.type.toUpperCase();
|
|
718
|
+
}
|
|
719
|
+
if (data.edited) {
|
|
720
|
+
this.editedTimestamp = Date.parse(data.edited);
|
|
721
|
+
}
|
|
722
|
+
return this;
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Gets the creation date of the message.
|
|
726
|
+
*
|
|
727
|
+
* @returns {Date} The date when the message was created.
|
|
728
|
+
*/
|
|
729
|
+
get createdAt() {
|
|
730
|
+
return UUID.timestampOf(this.id);
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Gets the creation timestamp of the message in milliseconds.
|
|
734
|
+
*
|
|
735
|
+
* @returns {number} The timestamp of when the message was created.
|
|
736
|
+
*/
|
|
737
|
+
get createdTimestamp() {
|
|
738
|
+
return this.createdAt.getTime();
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Gets the date when the message was last edited.
|
|
742
|
+
*
|
|
743
|
+
* @returns {Date | null} The date of the last edit, or `null` if not edited.
|
|
744
|
+
*/
|
|
745
|
+
get editedAt() {
|
|
746
|
+
return this.editedTimestamp ? new Date(this.editedTimestamp) : null;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Checks if the message is a system message.
|
|
750
|
+
*
|
|
751
|
+
* @returns {boolean} `true` if the message is a system message, otherwise `false`.
|
|
752
|
+
*/
|
|
753
|
+
get system() {
|
|
754
|
+
return this.type !== "TEXT";
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Retrieves the author of the message.
|
|
758
|
+
*
|
|
759
|
+
* @returns {User | null} The user who authored the message, or `null` if not found.
|
|
760
|
+
*/
|
|
761
|
+
get author() {
|
|
762
|
+
var _a;
|
|
763
|
+
return (_a = this.client.users.cache.get(this.authorId)) != null ? _a : null;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Retrieves the channel where the message was sent.
|
|
767
|
+
*
|
|
768
|
+
* @returns {TextChannel | DMChannel | GroupChannel} The channel instance.
|
|
769
|
+
*/
|
|
770
|
+
get channel() {
|
|
771
|
+
return this.client.channels.cache.get(this.channelId);
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Retrieves the server ID associated with the message, if any.
|
|
775
|
+
*
|
|
776
|
+
* @returns {string | null} The server ID, or `null` if the message is not in a server.
|
|
777
|
+
*/
|
|
778
|
+
get serverId() {
|
|
779
|
+
const channel = this.channel;
|
|
780
|
+
return channel.inServer() ? channel.serverId : null;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Retrieves the server associated with the message, if any.
|
|
784
|
+
*
|
|
785
|
+
* @returns {Server | null} The server instance, or `null` if not found.
|
|
786
|
+
*/
|
|
787
|
+
get server() {
|
|
788
|
+
var _a;
|
|
789
|
+
return (_a = this.client.servers.cache.get(this.serverId)) != null ? _a : null;
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Retrieves the server member who authored the message, if any.
|
|
793
|
+
*
|
|
794
|
+
* @returns {ServerMember | null} The server member instance, or `null` if not found.
|
|
795
|
+
*/
|
|
796
|
+
get member() {
|
|
797
|
+
var _a, _b;
|
|
798
|
+
return (_b = (_a = this.server) == null ? void 0 : _a.members.cache.get(this.authorId)) != null ? _b : null;
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Gets the URL of the message.
|
|
802
|
+
*
|
|
803
|
+
* @returns {string} The URL of the message.
|
|
804
|
+
*/
|
|
805
|
+
get url() {
|
|
806
|
+
return `https://app.revolt.chat/${this.serverId ? `server/${this.serverId}` : ""}/channel/${this.channelId}/${this.id}`;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Acknowledges the message.
|
|
810
|
+
*
|
|
811
|
+
* @returns {Promise<void>} A promise that resolves when the message is acknowledged.
|
|
812
|
+
*/
|
|
813
|
+
ack() {
|
|
814
|
+
return this.channel.messages.ack(this);
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Deletes the message.
|
|
818
|
+
*
|
|
819
|
+
* @returns {Promise<void>} A promise that resolves when the message is deleted.
|
|
820
|
+
*/
|
|
821
|
+
delete() {
|
|
822
|
+
return this.channel.messages.delete(this);
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Replies to the message.
|
|
826
|
+
*
|
|
827
|
+
* @param {string} content - The content of the reply.
|
|
828
|
+
* @param {boolean} [mention=true] - Whether to mention the original message author.
|
|
829
|
+
* @returns {Promise<Message>} A promise that resolves with the sent reply message.
|
|
830
|
+
*/
|
|
831
|
+
reply(content, mention = true) {
|
|
832
|
+
return this.channel.messages.send(__spreadProps(__spreadValues({}, typeof content === "object" ? content : { content }), {
|
|
833
|
+
replies: [{ id: this.id, mention }]
|
|
834
|
+
}));
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Edits the message.
|
|
838
|
+
*
|
|
839
|
+
* @param {MessageEditOptions | string} options - The new content or edit options.
|
|
840
|
+
* @returns {Promise<void>} A promise that resolves when the message is edited.
|
|
841
|
+
*/
|
|
842
|
+
edit(options) {
|
|
843
|
+
return this.channel.messages.edit(this, options);
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Fetches the latest data for the message.
|
|
847
|
+
*
|
|
848
|
+
* @returns {Promise<Message>} A promise that resolves with the updated message instance.
|
|
849
|
+
*/
|
|
850
|
+
fetch() {
|
|
851
|
+
return this.channel.messages.fetch(this.id);
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Adds a reaction to the message.
|
|
855
|
+
*
|
|
856
|
+
* @param {string} emoji - The emoji to react with.
|
|
857
|
+
* @returns {Promise<void>} A promise that resolves when the reaction is added.
|
|
858
|
+
*/
|
|
859
|
+
addReaction(emoji) {
|
|
860
|
+
return this.channel.messages.addReaction(this, emoji);
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Removes a reaction from the message.
|
|
864
|
+
*
|
|
865
|
+
* @param {string} emoji - The emoji to remove the reaction for.
|
|
866
|
+
* @param {object} [options] - Options for removing the reaction.
|
|
867
|
+
* @param {string} [options.user_id] - The user ID to remove the reaction for. If not provided, removes the reaction for the current user.
|
|
868
|
+
* @param {boolean} [options.remove_all=false] - Whether to remove all of the specified reaction for the message.
|
|
869
|
+
* @returns {Promise<void>} A promise that resolves when the reaction is removed.
|
|
870
|
+
*/
|
|
871
|
+
removeReaction(emoji, options) {
|
|
872
|
+
var _a, _b;
|
|
873
|
+
return this.channel.messages.removeReaction(
|
|
874
|
+
this,
|
|
875
|
+
emoji,
|
|
876
|
+
(_a = options == null ? void 0 : options.user_id) != null ? _a : void 0,
|
|
877
|
+
(_b = options == null ? void 0 : options.remove_all) != null ? _b : false
|
|
878
|
+
);
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Removes all reactions from the message.
|
|
882
|
+
*
|
|
883
|
+
* @returns {Promise<void>} A promise that resolves when all reactions are removed.
|
|
884
|
+
*/
|
|
885
|
+
removeAllReactions() {
|
|
886
|
+
return this.channel.messages.removeAllReactions(this);
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Checks if the message is in a server.
|
|
890
|
+
*
|
|
891
|
+
* @returns {boolean} `true` if the message is in a server, otherwise `false`.
|
|
892
|
+
*/
|
|
893
|
+
inServer() {
|
|
894
|
+
return this.channel.inServer();
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Converts the message to a string representation.
|
|
898
|
+
*
|
|
899
|
+
* @returns {string} The content of the message.
|
|
900
|
+
*/
|
|
901
|
+
toString() {
|
|
902
|
+
return this.content;
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
// src/struct/attachment.ts
|
|
907
|
+
var Attachment = class extends Base {
|
|
908
|
+
/**
|
|
909
|
+
* Creates a new Attachment instance.
|
|
910
|
+
*
|
|
911
|
+
* @param {client} client - The client instance.
|
|
912
|
+
* @param {File} data - The raw data for the attachment from the API.
|
|
913
|
+
*/
|
|
914
|
+
constructor(client3, data) {
|
|
915
|
+
super(client3);
|
|
916
|
+
this._patch(data);
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Updates the attachment instance with new data from the API.
|
|
920
|
+
*
|
|
921
|
+
* @param {File} data - The raw data for the attachment from the API.
|
|
922
|
+
* @returns {this} The updated attachment instance.
|
|
923
|
+
* @protected
|
|
924
|
+
*/
|
|
925
|
+
_patch(data) {
|
|
926
|
+
super._patch(data);
|
|
927
|
+
if (data.filename) this.filename = data.filename;
|
|
928
|
+
if (data.content_type) this.type = data.content_type;
|
|
929
|
+
if (typeof data.size === "number") this.size = data.size;
|
|
930
|
+
if (data.metadata) this.metadata = data.metadata;
|
|
931
|
+
return this;
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
// src/struct/presence.ts
|
|
936
|
+
var Status = /* @__PURE__ */ ((Status3) => {
|
|
937
|
+
Status3["Online"] = "ONLINE";
|
|
938
|
+
Status3["Idle"] = "IDLE";
|
|
939
|
+
Status3["Busy"] = "DND";
|
|
940
|
+
Status3["Invisible"] = "OFFLINE";
|
|
941
|
+
return Status3;
|
|
942
|
+
})(Status || {});
|
|
943
|
+
var Presence = class extends Base {
|
|
944
|
+
constructor() {
|
|
945
|
+
super(...arguments);
|
|
946
|
+
/** The custom status text of the user, or `null` if none is set. */
|
|
947
|
+
this.text = null;
|
|
948
|
+
/** The current status of the user (e.g., Online, Idle, Busy, Invisible). */
|
|
949
|
+
this.status = "OFFLINE" /* Invisible */;
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
// src/managers/baseManager.ts
|
|
954
|
+
var BaseManager = class {
|
|
955
|
+
constructor(client3) {
|
|
956
|
+
this.client = client3;
|
|
957
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
958
|
+
}
|
|
959
|
+
_add(raw) {
|
|
960
|
+
if (!this.holds) throw new Error("Holds is not defined");
|
|
961
|
+
const obj = new this.holds(this.client, raw);
|
|
962
|
+
this.cache.set(obj.id, obj);
|
|
963
|
+
return obj;
|
|
964
|
+
}
|
|
965
|
+
_remove(id) {
|
|
966
|
+
this.cache.delete(id);
|
|
967
|
+
}
|
|
968
|
+
resolve(resolvable) {
|
|
969
|
+
var _a;
|
|
970
|
+
const id = this.resolveId(resolvable);
|
|
971
|
+
if (id) return (_a = this.cache.get(id)) != null ? _a : null;
|
|
972
|
+
return null;
|
|
973
|
+
}
|
|
974
|
+
resolveId(resolvable) {
|
|
975
|
+
var _a;
|
|
976
|
+
if (resolvable == null) return null;
|
|
977
|
+
if (typeof resolvable === "string") return resolvable;
|
|
978
|
+
if (this.holds && resolvable instanceof this.holds) return resolvable.id;
|
|
979
|
+
const raw = resolvable;
|
|
980
|
+
if (typeof raw === "object" && "_id" in raw) (_a = raw._id) != null ? _a : null;
|
|
981
|
+
return null;
|
|
982
|
+
}
|
|
983
|
+
valueOf() {
|
|
984
|
+
return this.cache;
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
// src/managers/messageManager.ts
|
|
989
|
+
var import_node_buffer = require("buffer");
|
|
990
|
+
var import_stream = require("stream");
|
|
991
|
+
var import_form_data = __toESM(require("form-data"), 1);
|
|
992
|
+
var import_axios = __toESM(require("axios"), 1);
|
|
993
|
+
var MessageManager = class extends BaseManager {
|
|
994
|
+
constructor(channel) {
|
|
995
|
+
super(channel.client);
|
|
996
|
+
this.channel = channel;
|
|
997
|
+
this.holds = Message;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
*
|
|
1001
|
+
* @param content The content to send. Can be a string or an object with the following properties:
|
|
1002
|
+
* - content: The content of the message
|
|
1003
|
+
* - replies: An array of message IDs to reply to
|
|
1004
|
+
* - attachments: An array of attachment URLs, Files, or ReadStreams
|
|
1005
|
+
* - embeds: An array of MessageEmbed objects
|
|
1006
|
+
* @returns Promise that resolves to the sent message
|
|
1007
|
+
*/
|
|
1008
|
+
send(content) {
|
|
1009
|
+
return __async(this, null, function* () {
|
|
1010
|
+
if (typeof content === "string") content = { content };
|
|
1011
|
+
let attachments = [];
|
|
1012
|
+
let embeds = [];
|
|
1013
|
+
if (Array.isArray(content.attachments)) {
|
|
1014
|
+
const promises = content.attachments.map((att) => __async(this, null, function* () {
|
|
1015
|
+
const data = new import_form_data.default();
|
|
1016
|
+
if (typeof att === "string") {
|
|
1017
|
+
const readableStream = yield import_axios.default.get(att, {
|
|
1018
|
+
responseType: "stream"
|
|
1019
|
+
});
|
|
1020
|
+
data.append("file", readableStream.data, {
|
|
1021
|
+
filename: att.split("/").pop()
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
if (att instanceof import_stream.Readable) {
|
|
1025
|
+
data.append("file", att);
|
|
1026
|
+
}
|
|
1027
|
+
if (att instanceof import_node_buffer.File) {
|
|
1028
|
+
const buffer = Buffer.from(yield att.arrayBuffer());
|
|
1029
|
+
data.append("file", buffer, { filename: att.name });
|
|
1030
|
+
}
|
|
1031
|
+
yield this.client.cdn.post("/attachments", data).then((attachment) => {
|
|
1032
|
+
const { id } = attachment;
|
|
1033
|
+
attachments.push(id);
|
|
1034
|
+
});
|
|
1035
|
+
}));
|
|
1036
|
+
yield Promise.all(promises);
|
|
1037
|
+
}
|
|
1038
|
+
if (Array.isArray(content.embeds)) {
|
|
1039
|
+
const promises = content.embeds.map((embed) => __async(this, null, function* () {
|
|
1040
|
+
const json = yield embed.toJSONWithMedia(this.client);
|
|
1041
|
+
embeds.push(json);
|
|
1042
|
+
}));
|
|
1043
|
+
yield Promise.all(promises);
|
|
1044
|
+
}
|
|
1045
|
+
const resp = yield this.client.api.post(
|
|
1046
|
+
`/channels/${this.channel.id}/messages`,
|
|
1047
|
+
{
|
|
1048
|
+
body: __spreadProps(__spreadValues({}, content), { attachments, embeds, nonce: UUID.generate() })
|
|
1049
|
+
}
|
|
1050
|
+
);
|
|
1051
|
+
return this._add(resp);
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* acknowledge a message to mark it as read (not important for bots)
|
|
1056
|
+
* @param message The message to acknowledge
|
|
1057
|
+
* @returns Promise that resolves when the message is acknowledged
|
|
1058
|
+
*/
|
|
1059
|
+
ack(message) {
|
|
1060
|
+
return __async(this, null, function* () {
|
|
1061
|
+
const id = this.resolveId(message);
|
|
1062
|
+
if (!id) {
|
|
1063
|
+
throw new TypeError("INVALID_TYPE");
|
|
1064
|
+
}
|
|
1065
|
+
yield this.client.api.put(`/channels/${this.channel.id}/ack/${id}`);
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* bulk delete messages from the channel
|
|
1070
|
+
* @param messages The messages to delete. Can be an array of message IDs or a Map of message IDs to Message objects.
|
|
1071
|
+
* @returns Promise that resolves when the messages are deleted
|
|
1072
|
+
*/
|
|
1073
|
+
bulkDelete(messages) {
|
|
1074
|
+
return __async(this, null, function* () {
|
|
1075
|
+
let ids = [];
|
|
1076
|
+
if (typeof messages === "number") {
|
|
1077
|
+
messages = yield this.fetch(messages);
|
|
1078
|
+
ids = messages instanceof Map ? [...messages.keys()] : [];
|
|
1079
|
+
} else if (messages instanceof Map) {
|
|
1080
|
+
ids = [...messages.keys()];
|
|
1081
|
+
} else {
|
|
1082
|
+
ids = messages.map((m) => this.resolveId(m)).filter(Boolean);
|
|
1083
|
+
}
|
|
1084
|
+
yield this.client.api.delete(`/channels/${this.channel.id}/messages/bulk`, {
|
|
1085
|
+
body: JSON.stringify({ ids })
|
|
1086
|
+
});
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* delete a message from the channel
|
|
1091
|
+
* @param message The message to delete. Can be a Message object or a message ID.
|
|
1092
|
+
* @returns Promise that resolves when the message is deleted
|
|
1093
|
+
*/
|
|
1094
|
+
delete(message) {
|
|
1095
|
+
return __async(this, null, function* () {
|
|
1096
|
+
const id = this.resolveId(message);
|
|
1097
|
+
if (!id) {
|
|
1098
|
+
throw new TypeError("INVALID_TYPE");
|
|
1099
|
+
}
|
|
1100
|
+
yield this.client.api.delete(`/channels/${this.channel.id}/messages/${id}`);
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* edit a message in the channel
|
|
1105
|
+
* @param message The message to edit. Can be a Message object or a message ID.
|
|
1106
|
+
* @param options The options to edit the message with. Can be a string or an object with the following properties:
|
|
1107
|
+
* - content: The new content of the message
|
|
1108
|
+
* - attachments: An array of attachment URLs
|
|
1109
|
+
* - embeds: An array of MessageEmbed objects
|
|
1110
|
+
* @returns Promise that resolves when the message is edited
|
|
1111
|
+
*/
|
|
1112
|
+
edit(message, options) {
|
|
1113
|
+
return __async(this, null, function* () {
|
|
1114
|
+
const id = this.resolveId(message);
|
|
1115
|
+
if (!id) {
|
|
1116
|
+
throw new TypeError("INVALID_TYPE");
|
|
1117
|
+
}
|
|
1118
|
+
if (typeof options === "string") options = { content: options };
|
|
1119
|
+
yield this.client.api.patch(`/channels/${this.channel.id}/messages/${id}`, {
|
|
1120
|
+
body: options
|
|
1121
|
+
});
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* search for messages in the channel
|
|
1126
|
+
* @param query The query to search for. Can be a string or an object with the following properties:
|
|
1127
|
+
* - query: The query to search for
|
|
1128
|
+
* - limit: The maximum number of messages to return
|
|
1129
|
+
* - before: The message ID to start searching from (exclusive)
|
|
1130
|
+
* - after: The message ID to stop searching at (exclusive)
|
|
1131
|
+
* - sort: The sort order of the results (asc or desc)
|
|
1132
|
+
* @returns Promise that resolves to a Map of message IDs to Message objects
|
|
1133
|
+
*/
|
|
1134
|
+
search(query) {
|
|
1135
|
+
return __async(this, null, function* () {
|
|
1136
|
+
if (typeof query === "string") query = { query };
|
|
1137
|
+
const response = yield this.client.api.post(
|
|
1138
|
+
`/channels/${this.channel.id}/search`,
|
|
1139
|
+
{
|
|
1140
|
+
query
|
|
1141
|
+
}
|
|
1142
|
+
);
|
|
1143
|
+
return response.reduce((coll, cur) => {
|
|
1144
|
+
const msg = this._add(cur);
|
|
1145
|
+
coll.set(msg.id, msg);
|
|
1146
|
+
return coll;
|
|
1147
|
+
}, /* @__PURE__ */ new Map());
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
fetch(query) {
|
|
1151
|
+
return __async(this, null, function* () {
|
|
1152
|
+
const id = this.resolveId(query);
|
|
1153
|
+
if (id) {
|
|
1154
|
+
const data = yield this.client.api.get(
|
|
1155
|
+
`/channels/${this.channel.id}/messages/${id}`
|
|
1156
|
+
);
|
|
1157
|
+
return this._add(data);
|
|
1158
|
+
}
|
|
1159
|
+
if (typeof query === "number") query = { limit: query };
|
|
1160
|
+
else if (typeof query === "undefined") query = { limit: 100 };
|
|
1161
|
+
const messages = yield this.client.api.get(
|
|
1162
|
+
`/channels/${this.channel.id}/messages`,
|
|
1163
|
+
{ query: JSON.stringify(query) }
|
|
1164
|
+
);
|
|
1165
|
+
return messages.reduce((coll, cur) => {
|
|
1166
|
+
const msg = this._add(cur);
|
|
1167
|
+
coll.set(msg.id, msg);
|
|
1168
|
+
return coll;
|
|
1169
|
+
}, /* @__PURE__ */ new Map());
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* add a reaction to a message
|
|
1174
|
+
* @param message The message to react to. Can be a Message object or a message ID.
|
|
1175
|
+
* @param emoji emoji to react with. Can be a string or an Emoji object.
|
|
1176
|
+
* @returns Promise that resolves when the reaction is added
|
|
1177
|
+
*/
|
|
1178
|
+
addReaction(message, emoji) {
|
|
1179
|
+
return __async(this, null, function* () {
|
|
1180
|
+
const id = this.resolveId(message);
|
|
1181
|
+
if (!id) {
|
|
1182
|
+
throw new TypeError("INVALID_TYPE");
|
|
1183
|
+
}
|
|
1184
|
+
if (emoji instanceof Emoji) emoji = emoji.id;
|
|
1185
|
+
else if (typeof emoji !== "string") {
|
|
1186
|
+
throw new TypeError("INVALID_TYPE");
|
|
1187
|
+
}
|
|
1188
|
+
yield this.client.api.put(
|
|
1189
|
+
`/channels/${this.channel.id}/messages/${id}/reactions/${emoji}`
|
|
1190
|
+
);
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
*
|
|
1195
|
+
* @param message The message to unreact. Can be a Message object or a message ID.
|
|
1196
|
+
* @param emoji the emoji to unreact with. Can be a string or an Emoji object.
|
|
1197
|
+
* @param user_id The user ID to remove the reaction for. If not provided, removes the reaction for the current user.
|
|
1198
|
+
* @param remove_all Whether to remove all of the specified reaction for the message. Defaults to false.
|
|
1199
|
+
* @returns Promise that resolves when the reaction is removed
|
|
1200
|
+
*/
|
|
1201
|
+
removeReaction(message, emoji, user_id, remove_all = false) {
|
|
1202
|
+
return __async(this, null, function* () {
|
|
1203
|
+
const id = this.resolveId(message);
|
|
1204
|
+
if (!id) {
|
|
1205
|
+
throw new TypeError("INVALID_TYPE");
|
|
1206
|
+
}
|
|
1207
|
+
if (emoji instanceof Emoji) emoji = emoji.id;
|
|
1208
|
+
else if (typeof emoji !== "string") {
|
|
1209
|
+
throw new TypeError("INVALID_TYPE");
|
|
1210
|
+
}
|
|
1211
|
+
const queryString = user_id ? `?user_id=${user_id}&remove_all=${remove_all}` : `?remove_all=${remove_all}`;
|
|
1212
|
+
yield this.client.api.delete(
|
|
1213
|
+
`/channels/${this.channel.id}/messages/${id}/reactions/${emoji}${queryString}`
|
|
1214
|
+
);
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* remove all reactions from a message
|
|
1219
|
+
* @param message The message to remove reactions from. Can be a Message object or a message ID.
|
|
1220
|
+
* @returns Promise that resolves when the reactions are removed
|
|
1221
|
+
*/
|
|
1222
|
+
removeAllReactions(message) {
|
|
1223
|
+
return __async(this, null, function* () {
|
|
1224
|
+
const id = this.resolveId(message);
|
|
1225
|
+
if (!id) {
|
|
1226
|
+
throw new TypeError("INVALID_TYPE");
|
|
1227
|
+
}
|
|
1228
|
+
yield this.client.api.delete(
|
|
1229
|
+
`/channels/${this.channel.id}/messages/${id}/reactions`
|
|
1230
|
+
);
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
};
|
|
1234
|
+
|
|
1235
|
+
// src/managers/roleManager.ts
|
|
1236
|
+
var RoleManager = class extends BaseManager {
|
|
1237
|
+
constructor(server) {
|
|
1238
|
+
super(server.client);
|
|
1239
|
+
this.server = server;
|
|
1240
|
+
this.holds = Role;
|
|
1241
|
+
}
|
|
1242
|
+
_add(data) {
|
|
1243
|
+
const role = new Role(this.server, data);
|
|
1244
|
+
this.cache.set(role.id, role);
|
|
1245
|
+
return role;
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* creates a new role in the server
|
|
1249
|
+
* @param name The name of the role to create
|
|
1250
|
+
* @returns
|
|
1251
|
+
*/
|
|
1252
|
+
create(name) {
|
|
1253
|
+
return __async(this, null, function* () {
|
|
1254
|
+
const { id, role } = yield this.client.api.post(`/servers/${this.server.id}/roles`, { body: { name } });
|
|
1255
|
+
return this._add(Object.assign(role, { id }));
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* deletes a role from the server
|
|
1260
|
+
* @param role the role to delete
|
|
1261
|
+
* @returns A promise that resolves when the role is deleted
|
|
1262
|
+
*/
|
|
1263
|
+
delete(role) {
|
|
1264
|
+
return __async(this, null, function* () {
|
|
1265
|
+
const id = this.resolveId(role);
|
|
1266
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
1267
|
+
yield this.client.api.delete(`/servers/${this.server.id}/roles/${id}`);
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
*
|
|
1272
|
+
* @param role the role to edit
|
|
1273
|
+
* @param data data to edit the role with
|
|
1274
|
+
* @param data.permissions The permissions to set for the role, in the format { a: allow, d: deny }
|
|
1275
|
+
* @param data.name The name of the role
|
|
1276
|
+
* @param data.colour The color of the role, or `null` if no color is set
|
|
1277
|
+
* @param data.hoist Whether the role is displayed separately in the member list
|
|
1278
|
+
* @param data.rank The rank of the role, used for ordering
|
|
1279
|
+
* @param data.remove Fields to remove from the role
|
|
1280
|
+
* @returns Role
|
|
1281
|
+
* @throws {TypeError} If the role ID is invalid
|
|
1282
|
+
*/
|
|
1283
|
+
edit(role, data) {
|
|
1284
|
+
return __async(this, null, function* () {
|
|
1285
|
+
var _a, _b;
|
|
1286
|
+
const id = this.resolveId(role);
|
|
1287
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
1288
|
+
if (data.permissions) {
|
|
1289
|
+
const permissions = {
|
|
1290
|
+
allow: new FullPermissions(((_a = data.permissions) == null ? void 0 : _a.a) || []).bitfield,
|
|
1291
|
+
deny: new FullPermissions(((_b = data.permissions) == null ? void 0 : _b.d) || []).bitfield
|
|
1292
|
+
};
|
|
1293
|
+
yield this.client.api.put(
|
|
1294
|
+
`/servers/${this.server.id}/permissions/${id}`,
|
|
1295
|
+
{ body: { permissions } }
|
|
1296
|
+
);
|
|
1297
|
+
}
|
|
1298
|
+
delete data.permissions;
|
|
1299
|
+
const updatedRole = yield this.client.api.patch(
|
|
1300
|
+
`/servers/${this.server.id}/roles/${id}`,
|
|
1301
|
+
{ body: data }
|
|
1302
|
+
);
|
|
1303
|
+
return this._add(Object.assign(updatedRole, { id }));
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1308
|
+
// src/managers/serverChannelManager.ts
|
|
1309
|
+
var ServerChannelManager = class extends BaseManager {
|
|
1310
|
+
constructor(server) {
|
|
1311
|
+
super(server.client);
|
|
1312
|
+
this.server = server;
|
|
1313
|
+
this.holds = ServerChannel;
|
|
1314
|
+
}
|
|
1315
|
+
_add(data) {
|
|
1316
|
+
let channel;
|
|
1317
|
+
switch (data.channel_type) {
|
|
1318
|
+
case "TextChannel":
|
|
1319
|
+
channel = new TextChannel2(this.client, data);
|
|
1320
|
+
break;
|
|
1321
|
+
case "VoiceChannel":
|
|
1322
|
+
channel = new VoiceChannel(this.client, data);
|
|
1323
|
+
break;
|
|
1324
|
+
default:
|
|
1325
|
+
throw new Error(
|
|
1326
|
+
`Unknown channel type: ${data.channel_type}`
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
this.cache.set(channel.id, channel);
|
|
1330
|
+
return channel;
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* creates a new channel in the server
|
|
1334
|
+
* @param name The name of the channel to create
|
|
1335
|
+
* @param type The type of the channel to create. Can be "Text" or "Voice". Defaults to "Text".
|
|
1336
|
+
* @param description The description of the channel to create. Only used for voice channels.
|
|
1337
|
+
* @returns A promise that resolves to the created channel
|
|
1338
|
+
*/
|
|
1339
|
+
create(_0) {
|
|
1340
|
+
return __async(this, arguments, function* ({
|
|
1341
|
+
name,
|
|
1342
|
+
type = "Text",
|
|
1343
|
+
description
|
|
1344
|
+
}) {
|
|
1345
|
+
const data = yield this.client.api.post(
|
|
1346
|
+
`/servers/${this.server.id}/channels`,
|
|
1347
|
+
{
|
|
1348
|
+
body: {
|
|
1349
|
+
name,
|
|
1350
|
+
type,
|
|
1351
|
+
description,
|
|
1352
|
+
nonce: UUID.generate()
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
);
|
|
1356
|
+
return this._add(data);
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* fetch a channel from the server
|
|
1361
|
+
* @param channel The channel to fetch. Can be a string, a channel object, or an API channel object.
|
|
1362
|
+
* @param force Whether to force fetch the channel from the API. Defaults to true.
|
|
1363
|
+
* If set to false, the method will return the channel from the cache if it exists.
|
|
1364
|
+
* @returns A promise that resolves to the fetched channel
|
|
1365
|
+
*/
|
|
1366
|
+
fetch(_0) {
|
|
1367
|
+
return __async(this, arguments, function* (channel, { force = true } = {}) {
|
|
1368
|
+
const id = this.resolveId(channel);
|
|
1369
|
+
if (!id) {
|
|
1370
|
+
throw new TypeError("INVALID_ID");
|
|
1371
|
+
}
|
|
1372
|
+
if (!force) {
|
|
1373
|
+
const channel2 = this.cache.get(id);
|
|
1374
|
+
if (channel2) return channel2;
|
|
1375
|
+
}
|
|
1376
|
+
const data = yield this.client.api.get(
|
|
1377
|
+
`/servers/${this.server.id}/channels/${id}`
|
|
1378
|
+
);
|
|
1379
|
+
return this._add(data);
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
|
|
1384
|
+
// src/managers/serverMemberManager.ts
|
|
1385
|
+
var ServerMemberManager = class extends BaseManager {
|
|
1386
|
+
constructor(server) {
|
|
1387
|
+
super(server.client);
|
|
1388
|
+
this.server = server;
|
|
1389
|
+
this.holds = ServerMember2;
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* edit selected member in the server
|
|
1393
|
+
* @param member The member to edit
|
|
1394
|
+
* @param options The options to edit the member with
|
|
1395
|
+
* @param options.nickname The nickname of the member to set
|
|
1396
|
+
* @param options.avatar The avatar of the member to set
|
|
1397
|
+
* @param options.roles The roles of the member to set
|
|
1398
|
+
* @returns A promise that resolves when the member is edited
|
|
1399
|
+
*/
|
|
1400
|
+
edit(member, options) {
|
|
1401
|
+
return __async(this, null, function* () {
|
|
1402
|
+
const id = this.resolveId(member);
|
|
1403
|
+
if (!id) {
|
|
1404
|
+
throw new TypeError("INVALID_TYPE");
|
|
1405
|
+
}
|
|
1406
|
+
yield this.client.api.patch(`/servers/${this.server.id}/members/${id}`, {
|
|
1407
|
+
body: __spreadValues({}, options)
|
|
1408
|
+
});
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
/**
|
|
1412
|
+
* ban selected member in the server
|
|
1413
|
+
* @param member The member to ban
|
|
1414
|
+
* @param reason the reason for the ban
|
|
1415
|
+
* @returns A promise that resolves when the member is banned
|
|
1416
|
+
*/
|
|
1417
|
+
ban(member, reason) {
|
|
1418
|
+
return __async(this, null, function* () {
|
|
1419
|
+
const id = this.resolveId(member);
|
|
1420
|
+
if (!id) {
|
|
1421
|
+
throw new TypeError("INVALID_TYPE");
|
|
1422
|
+
}
|
|
1423
|
+
yield this.client.api.put(`/servers/${this.server.id}/bans/${id}`, {
|
|
1424
|
+
body: { reason }
|
|
1425
|
+
});
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
/**
|
|
1429
|
+
* kick selected member in the server
|
|
1430
|
+
* @param member The member to kick
|
|
1431
|
+
* @returns A promise that resolves when the member is kicked
|
|
1432
|
+
*/
|
|
1433
|
+
kick(member) {
|
|
1434
|
+
return __async(this, null, function* () {
|
|
1435
|
+
const id = this.resolveId(member);
|
|
1436
|
+
if (!id) {
|
|
1437
|
+
throw new TypeError("INVALID_TYPE");
|
|
1438
|
+
}
|
|
1439
|
+
yield this.client.api.delete(`/servers/${this.server.id}/members/${id}`);
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* unban selected member in the server
|
|
1444
|
+
* @param member The member to unban
|
|
1445
|
+
* @returns A promise that resolves when the member is unbanned
|
|
1446
|
+
*/
|
|
1447
|
+
unban(member) {
|
|
1448
|
+
return __async(this, null, function* () {
|
|
1449
|
+
const id = this.resolveId(member);
|
|
1450
|
+
if (!id) {
|
|
1451
|
+
throw new TypeError("INVALID_TYPE");
|
|
1452
|
+
}
|
|
1453
|
+
yield this.client.api.delete(`/servers/${this.server.id}/bans/${id}`);
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
fetch(member) {
|
|
1457
|
+
return __async(this, null, function* () {
|
|
1458
|
+
if (typeof member !== "undefined") {
|
|
1459
|
+
const id = this.resolveId(member);
|
|
1460
|
+
if (!id) {
|
|
1461
|
+
throw new TypeError("INVALID_TYPE");
|
|
1462
|
+
}
|
|
1463
|
+
const data = yield this.client.api.get(
|
|
1464
|
+
`/servers/${this.server.id}/members/${id}`
|
|
1465
|
+
);
|
|
1466
|
+
return this._add(data);
|
|
1467
|
+
}
|
|
1468
|
+
const { users, members } = yield this.client.api.get(`/servers/${this.server.id}/members`);
|
|
1469
|
+
users.reduce((coll, cur) => {
|
|
1470
|
+
const user = this.client.users._add(cur);
|
|
1471
|
+
coll.set(user.id, user);
|
|
1472
|
+
return coll;
|
|
1473
|
+
}, this.client.users.cache);
|
|
1474
|
+
return members.reduce((coll, cur) => {
|
|
1475
|
+
const member2 = this._add(cur);
|
|
1476
|
+
coll.set(member2.id, member2);
|
|
1477
|
+
return coll;
|
|
1478
|
+
}, /* @__PURE__ */ new Map());
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* resolves a member from a string or a member object
|
|
1483
|
+
* @param member The member to resolve
|
|
1484
|
+
* @returns The id of the member or null if it cannot be resolved
|
|
1485
|
+
*/
|
|
1486
|
+
resolveId(member) {
|
|
1487
|
+
if (member == null) return null;
|
|
1488
|
+
if (member instanceof ServerMember2 || member instanceof User) {
|
|
1489
|
+
return member.id;
|
|
1490
|
+
}
|
|
1491
|
+
if (typeof member === "string") return member;
|
|
1492
|
+
if ("_id" in member) return member._id.user;
|
|
1493
|
+
return null;
|
|
1494
|
+
}
|
|
1495
|
+
};
|
|
1496
|
+
|
|
1497
|
+
// src/struct/server.ts
|
|
1498
|
+
var Server2 = class extends Base {
|
|
1499
|
+
/**
|
|
1500
|
+
* Creates a new Server instance.
|
|
1501
|
+
*
|
|
1502
|
+
* @param {client} client - The client instance.
|
|
1503
|
+
* @param {APIServer} data - The raw data for the server from the API.
|
|
1504
|
+
*/
|
|
1505
|
+
constructor(client3, data) {
|
|
1506
|
+
super(client3);
|
|
1507
|
+
/** The description of the server, or `null` if none is set. */
|
|
1508
|
+
this.description = null;
|
|
1509
|
+
/** Manages the members of the server. */
|
|
1510
|
+
this.members = new ServerMemberManager(this);
|
|
1511
|
+
/** Manages the channels of the server. */
|
|
1512
|
+
this.channels = new ServerChannelManager(this);
|
|
1513
|
+
/** Manages the roles of the server. */
|
|
1514
|
+
this.roles = new RoleManager(this);
|
|
1515
|
+
/** The icon of the server, or `null` if none is set. */
|
|
1516
|
+
this.icon = null;
|
|
1517
|
+
/** The banner of the server, or `null` if none is set. */
|
|
1518
|
+
this.banner = null;
|
|
1519
|
+
/** Whether analytics are enabled for the server. */
|
|
1520
|
+
this.analytics = false;
|
|
1521
|
+
/** Whether the server is discoverable. */
|
|
1522
|
+
this.discoverable = false;
|
|
1523
|
+
/** Whether the server is marked as NSFW (Not Safe For Work). */
|
|
1524
|
+
this.nsfw = false;
|
|
1525
|
+
/** The categories in the server. */
|
|
1526
|
+
this.categories = /* @__PURE__ */ new Map();
|
|
1527
|
+
/** the emojies associated with the server */
|
|
1528
|
+
this.emojis = /* @__PURE__ */ new Map();
|
|
1529
|
+
this._patch(data);
|
|
1530
|
+
}
|
|
1531
|
+
/**
|
|
1532
|
+
* Updates the server instance with new data from the API.
|
|
1533
|
+
*
|
|
1534
|
+
* @param {APIServer} data - The raw data for the server from the API.
|
|
1535
|
+
* @param {FieldsServer[]} [clear=[]] - Fields to clear in the server.
|
|
1536
|
+
* @returns {this} The updated server instance.
|
|
1537
|
+
* @protected
|
|
1538
|
+
*/
|
|
1539
|
+
_patch(data, clear = []) {
|
|
1540
|
+
var _a;
|
|
1541
|
+
super._patch(data);
|
|
1542
|
+
if (Array.isArray(data.categories)) {
|
|
1543
|
+
this.categories.clear();
|
|
1544
|
+
for (const cat of data.categories) {
|
|
1545
|
+
const category = new Category(this, cat);
|
|
1546
|
+
this.categories.set(category.id, category);
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
if (data.icon) {
|
|
1550
|
+
this.icon = new Attachment(this.client, data.icon);
|
|
1551
|
+
}
|
|
1552
|
+
if (data.banner) {
|
|
1553
|
+
this.banner = new Attachment(this.client, data.banner);
|
|
1554
|
+
}
|
|
1555
|
+
if (data.owner) {
|
|
1556
|
+
this.ownerId = data.owner;
|
|
1557
|
+
}
|
|
1558
|
+
if (data.name) {
|
|
1559
|
+
this.name = data.name;
|
|
1560
|
+
}
|
|
1561
|
+
if ("description" in data) {
|
|
1562
|
+
this.description = (_a = data.description) != null ? _a : null;
|
|
1563
|
+
}
|
|
1564
|
+
if (Array.isArray(data.channels)) {
|
|
1565
|
+
for (const id of data.channels) {
|
|
1566
|
+
const channel = this.client.channels.cache.get(id);
|
|
1567
|
+
if (channel == null ? void 0 : channel.inServer()) this.channels.cache.set(channel.id, channel);
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
if (typeof data.roles === "object") {
|
|
1571
|
+
for (const [id, raw] of Object.entries(data.roles)) {
|
|
1572
|
+
this.roles._add(Object.assign(raw, { id }));
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
if (typeof data.default_permissions === "number") {
|
|
1576
|
+
this.permissions = new FullPermissions(data.default_permissions).freeze();
|
|
1577
|
+
}
|
|
1578
|
+
if (typeof data.analytics === "boolean") this.analytics = data.analytics;
|
|
1579
|
+
if (typeof data.discoverable === "boolean") {
|
|
1580
|
+
this.discoverable = data.discoverable;
|
|
1581
|
+
}
|
|
1582
|
+
if (typeof data.nsfw === "boolean") this.nsfw = data.nsfw;
|
|
1583
|
+
for (const field of clear) {
|
|
1584
|
+
if (field === "Icon") this.icon = null;
|
|
1585
|
+
if (field === "Description") this.description = null;
|
|
1586
|
+
if (field === "Banner") this.banner = null;
|
|
1587
|
+
}
|
|
1588
|
+
return this;
|
|
1589
|
+
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Retrieves the current user's member instance in the server.
|
|
1592
|
+
*
|
|
1593
|
+
* @returns {ServerMember | null} The current user's member instance, or `null` if not found.
|
|
1594
|
+
*/
|
|
1595
|
+
get me() {
|
|
1596
|
+
var _a, _b;
|
|
1597
|
+
return (_b = this.members.cache.get((_a = this.client.user) == null ? void 0 : _a.id)) != null ? _b : null;
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* Gets the creation date of the server.
|
|
1601
|
+
*
|
|
1602
|
+
* @returns {Date} The date when the server was created.
|
|
1603
|
+
*/
|
|
1604
|
+
get createdAt() {
|
|
1605
|
+
return UUID.timestampOf(this.id);
|
|
1606
|
+
}
|
|
1607
|
+
/**
|
|
1608
|
+
* Gets the creation timestamp of the server in milliseconds.
|
|
1609
|
+
*
|
|
1610
|
+
* @returns {number} The timestamp of when the server was created.
|
|
1611
|
+
*/
|
|
1612
|
+
get createdTimestamp() {
|
|
1613
|
+
return this.createdAt.getTime();
|
|
1614
|
+
}
|
|
1615
|
+
/**
|
|
1616
|
+
* Retrieves the owner of the server.
|
|
1617
|
+
*
|
|
1618
|
+
* @returns {User | null} The owner of the server, or `null` if not found.
|
|
1619
|
+
*/
|
|
1620
|
+
get owner() {
|
|
1621
|
+
var _a;
|
|
1622
|
+
return (_a = this.client.users.cache.get(this.ownerId)) != null ? _a : null;
|
|
1623
|
+
}
|
|
1624
|
+
// iconURL(options?: { size: number }): string | null {
|
|
1625
|
+
// return this.icon
|
|
1626
|
+
// ? this.client.api.cdn.icon(this.icon.id, options?.size)
|
|
1627
|
+
// : null;
|
|
1628
|
+
// }
|
|
1629
|
+
// bannerURL(options?: { size: number }): string | null {
|
|
1630
|
+
// return this.banner
|
|
1631
|
+
// ? this.client.api.cdn.banner(this.banner.id, options?.size)
|
|
1632
|
+
// : null;
|
|
1633
|
+
// }
|
|
1634
|
+
/**
|
|
1635
|
+
* Converts the server to a string representation.
|
|
1636
|
+
*
|
|
1637
|
+
* @returns {string} The name of the server.
|
|
1638
|
+
*/
|
|
1639
|
+
toString() {
|
|
1640
|
+
return this.name;
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
|
|
1644
|
+
// src/struct/role.ts
|
|
1645
|
+
var Role = class extends Base {
|
|
1646
|
+
/**
|
|
1647
|
+
* Creates a new Role instance.
|
|
1648
|
+
*
|
|
1649
|
+
* @param {Server} server - The server this role belongs to.
|
|
1650
|
+
* @param {APIRole & { id: string }} data - The raw data for the role from the API.
|
|
1651
|
+
*/
|
|
1652
|
+
constructor(server, data) {
|
|
1653
|
+
super(server.client);
|
|
1654
|
+
this.server = server;
|
|
1655
|
+
/** The color of the role, or `null` if no color is set. */
|
|
1656
|
+
this.color = null;
|
|
1657
|
+
/** Whether the role is displayed separately in the member list. */
|
|
1658
|
+
this.hoist = false;
|
|
1659
|
+
this._patch(data);
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Updates the role instance with new data from the API.
|
|
1663
|
+
*
|
|
1664
|
+
* @param {APIRole & { _id?: string }} data - The raw data for the role from the API.
|
|
1665
|
+
* @param {FieldsRole[]} [clear=[]] - Fields to clear in the role.
|
|
1666
|
+
* @returns {this} The updated role instance.
|
|
1667
|
+
* @protected
|
|
1668
|
+
*/
|
|
1669
|
+
_patch(data, clear = []) {
|
|
1670
|
+
var _a;
|
|
1671
|
+
super._patch(data);
|
|
1672
|
+
if (data.name) this.name = data.name;
|
|
1673
|
+
if (typeof data.hoist === "boolean") this.hoist = data.hoist;
|
|
1674
|
+
if (typeof data.rank === "number") this.rank = data.rank;
|
|
1675
|
+
if ("colour" in data) this.color = (_a = data.colour) != null ? _a : null;
|
|
1676
|
+
if (data.permissions) {
|
|
1677
|
+
const { a, d } = data.permissions;
|
|
1678
|
+
this.overwrite = {
|
|
1679
|
+
allow: new FullPermissions(a),
|
|
1680
|
+
deny: new FullPermissions(d)
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
for (const field of clear) {
|
|
1684
|
+
if (field === "Colour") this.color = null;
|
|
1685
|
+
}
|
|
1686
|
+
return this;
|
|
1687
|
+
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Gets the date when the role was created.
|
|
1690
|
+
*
|
|
1691
|
+
* @returns {Date} The creation date of the role.
|
|
1692
|
+
*/
|
|
1693
|
+
get createdAt() {
|
|
1694
|
+
return UUID.timestampOf(this.id);
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* Gets the timestamp of when the role was created.
|
|
1698
|
+
*
|
|
1699
|
+
* @returns {number} The creation timestamp of the role in milliseconds.
|
|
1700
|
+
*/
|
|
1701
|
+
get createdTimestamp() {
|
|
1702
|
+
return this.createdAt.getTime();
|
|
1703
|
+
}
|
|
1704
|
+
/**
|
|
1705
|
+
* Gets the permissions overwrite for the role.
|
|
1706
|
+
*
|
|
1707
|
+
* @returns {Overwrite} The permissions overwrite for the role.
|
|
1708
|
+
*/
|
|
1709
|
+
get permissions() {
|
|
1710
|
+
return this.overwrite;
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Deletes the role from the server.
|
|
1714
|
+
*
|
|
1715
|
+
* @returns {Promise<void>} A promise that resolves when the role is deleted.
|
|
1716
|
+
*
|
|
1717
|
+
* @example
|
|
1718
|
+
* ```typescript
|
|
1719
|
+
* await role.delete();
|
|
1720
|
+
* console.log("Role deleted successfully.");
|
|
1721
|
+
* ```
|
|
1722
|
+
*/
|
|
1723
|
+
delete() {
|
|
1724
|
+
return this.server.roles.delete(this);
|
|
1725
|
+
}
|
|
1726
|
+
edit(data) {
|
|
1727
|
+
return this.server.roles.edit(this, data);
|
|
1728
|
+
}
|
|
1729
|
+
/**
|
|
1730
|
+
* Converts the role to a string representation.
|
|
1731
|
+
*
|
|
1732
|
+
* @returns {string} A string representation of the role in the format `<@&roleId>`.
|
|
1733
|
+
*/
|
|
1734
|
+
toString() {
|
|
1735
|
+
return `<@&${this.id}>`;
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
|
|
1739
|
+
// src/struct/channel.ts
|
|
1740
|
+
var Channel = class extends Base {
|
|
1741
|
+
constructor() {
|
|
1742
|
+
super(...arguments);
|
|
1743
|
+
this.type = "UNKNOWN";
|
|
1744
|
+
}
|
|
1745
|
+
/**
|
|
1746
|
+
* Gets the timestamp (in milliseconds) when the channel was created.
|
|
1747
|
+
*
|
|
1748
|
+
* @returns {number} The timestamp of the channel's creation.
|
|
1749
|
+
*/
|
|
1750
|
+
get createdTimestamp() {
|
|
1751
|
+
return this.createdAt.getTime();
|
|
1752
|
+
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Gets the date and time when the channel was created.
|
|
1755
|
+
*
|
|
1756
|
+
* @returns {Date} The creation date of the channel.
|
|
1757
|
+
*/
|
|
1758
|
+
get createdAt() {
|
|
1759
|
+
return UUID.timestampOf(this.id);
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Deletes the current channel instance from the client's channel collection.
|
|
1763
|
+
*
|
|
1764
|
+
* This method interacts with the client's channel management system to remove
|
|
1765
|
+
* the channel. Once deleted, the channel will no longer be accessible through
|
|
1766
|
+
* the client.
|
|
1767
|
+
*
|
|
1768
|
+
* @returns {Promise<void>} A promise that resolves when the channel has been successfully deleted.
|
|
1769
|
+
*
|
|
1770
|
+
* @example
|
|
1771
|
+
* ```typescript
|
|
1772
|
+
* const channel = client.channels.get('1234567890');
|
|
1773
|
+
* if (channel) {
|
|
1774
|
+
* await channel.delete();
|
|
1775
|
+
* console.log('Channel deleted successfully.');
|
|
1776
|
+
* }
|
|
1777
|
+
* ```
|
|
1778
|
+
*/
|
|
1779
|
+
delete() {
|
|
1780
|
+
return this.client.channels.delete(this);
|
|
1781
|
+
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Checks if the channel is a text-based channel.
|
|
1784
|
+
*
|
|
1785
|
+
* @returns {boolean} True if the channel is a text-based channel, otherwise false.
|
|
1786
|
+
*/
|
|
1787
|
+
isText() {
|
|
1788
|
+
return "messages" in this;
|
|
1789
|
+
}
|
|
1790
|
+
/**
|
|
1791
|
+
* Checks if the channel is a voice channel.
|
|
1792
|
+
*
|
|
1793
|
+
* @returns {boolean} True if the channel is a voice channel, otherwise false.
|
|
1794
|
+
*/
|
|
1795
|
+
isVoice() {
|
|
1796
|
+
return this.type === "VOICE" /* VOICE */;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Checks if the channel is a group channel.
|
|
1800
|
+
*
|
|
1801
|
+
* @returns {boolean} True if the channel is a group channel, otherwise false.
|
|
1802
|
+
*/
|
|
1803
|
+
isGroup() {
|
|
1804
|
+
return this.type === "GROUP" /* GROUP */;
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* Checks if the channel is part of a server.
|
|
1808
|
+
*
|
|
1809
|
+
* @returns {boolean} True if the channel is a server channel, otherwise false.
|
|
1810
|
+
*/
|
|
1811
|
+
inServer() {
|
|
1812
|
+
return "serverId" in this;
|
|
1813
|
+
}
|
|
1814
|
+
/**
|
|
1815
|
+
* Converts the channel to a string representation.
|
|
1816
|
+
*
|
|
1817
|
+
* @returns {string} A string representation of the channel in the format `<#channelId>`.
|
|
1818
|
+
*/
|
|
1819
|
+
toString() {
|
|
1820
|
+
return `<#${this.id}>`;
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Fetches the latest data for the channel from the client's channel collection.
|
|
1824
|
+
*
|
|
1825
|
+
* @param {boolean} [force=true] - Whether to force a fetch even if the channel is cached.
|
|
1826
|
+
* @returns {Promise<Channel>} A promise that resolves with the updated channel instance.
|
|
1827
|
+
*/
|
|
1828
|
+
fetch(force = true) {
|
|
1829
|
+
return this.client.channels.fetch(this, { force });
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
|
|
1833
|
+
// src/client/baseClient.ts
|
|
1834
|
+
var import_node_events = require("events");
|
|
1835
|
+
|
|
1836
|
+
// src/rest/restClient.ts
|
|
1837
|
+
var import_axios3 = require("axios");
|
|
1838
|
+
|
|
1839
|
+
// src/rest/restUtils/rateLimitQueue.ts
|
|
1840
|
+
var import_axios2 = __toESM(require("axios"), 1);
|
|
1841
|
+
|
|
1842
|
+
// src/rest/CDNClient.ts
|
|
1843
|
+
var import_axios4 = require("axios");
|
|
1844
|
+
|
|
1845
|
+
// src/struct/dmChannel.ts
|
|
1846
|
+
var DMChannel3 = class extends Channel {
|
|
1847
|
+
/**
|
|
1848
|
+
* Creates a new DMChannel instance.
|
|
1849
|
+
*
|
|
1850
|
+
* @param {client} client - The client instance.
|
|
1851
|
+
* @param {APIDirectChannel} data - The raw data for the DM channel from the API.
|
|
1852
|
+
*/
|
|
1853
|
+
constructor(client3, data) {
|
|
1854
|
+
super(client3);
|
|
1855
|
+
/** The type of the channel, which is always `DM` for direct message channels. */
|
|
1856
|
+
this.type = "DM" /* DM */;
|
|
1857
|
+
/** The default permissions for the DM channel. */
|
|
1858
|
+
this.permissions = DEFAULT_PERMISSION_DM;
|
|
1859
|
+
/** Manages the messages in this DM channel. */
|
|
1860
|
+
this.messages = new MessageManager(this);
|
|
1861
|
+
/** The ID of the last message sent in this DM channel, if any. */
|
|
1862
|
+
this.lastMessageId = null;
|
|
1863
|
+
this._patch(data);
|
|
1864
|
+
}
|
|
1865
|
+
/**
|
|
1866
|
+
* Updates the DM channel instance with new data from the API.
|
|
1867
|
+
*
|
|
1868
|
+
* @param {APIDirectChannel} data - The raw data for the DM channel from the API.
|
|
1869
|
+
* @returns {this} The updated DM channel instance.
|
|
1870
|
+
* @protected
|
|
1871
|
+
*/
|
|
1872
|
+
_patch(data) {
|
|
1873
|
+
super._patch(data);
|
|
1874
|
+
if (typeof data.active === "boolean") this.active = data.active;
|
|
1875
|
+
if (data.last_message_id) this.lastMessageId = data.last_message_id;
|
|
1876
|
+
return this;
|
|
1877
|
+
}
|
|
1878
|
+
/**
|
|
1879
|
+
* Retrieves the last message sent in this DM channel.
|
|
1880
|
+
*
|
|
1881
|
+
* @returns {Message | null} The last message, or `null` if no message exists.
|
|
1882
|
+
*/
|
|
1883
|
+
get lastMessage() {
|
|
1884
|
+
var _a;
|
|
1885
|
+
if (!this.lastMessageId) return null;
|
|
1886
|
+
return (_a = this.messages.cache.get(this.lastMessageId)) != null ? _a : null;
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* Deletes multiple messages from this DM channel.
|
|
1890
|
+
*
|
|
1891
|
+
* @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.
|
|
1892
|
+
* @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
|
|
1893
|
+
*
|
|
1894
|
+
* @example
|
|
1895
|
+
* ```typescript
|
|
1896
|
+
* await dmChannel.bulkDelete(10); // Deletes the last 10 messages.
|
|
1897
|
+
* ```
|
|
1898
|
+
*/
|
|
1899
|
+
bulkDelete(messages) {
|
|
1900
|
+
return this.messages.bulkDelete(messages);
|
|
1901
|
+
}
|
|
1902
|
+
/**
|
|
1903
|
+
* Sends a message to this DM channel.
|
|
1904
|
+
*
|
|
1905
|
+
* @param {MessageOptions | string} options - The message content or options for the message.
|
|
1906
|
+
* @returns {Promise<Message>} A promise that resolves with the sent message.
|
|
1907
|
+
*
|
|
1908
|
+
* @example
|
|
1909
|
+
* ```typescript
|
|
1910
|
+
* await dmChannel.send("Hello, world!");
|
|
1911
|
+
* ```
|
|
1912
|
+
*/
|
|
1913
|
+
send(options) {
|
|
1914
|
+
return this.messages.send(options);
|
|
1915
|
+
}
|
|
1916
|
+
};
|
|
1917
|
+
|
|
1918
|
+
// src/struct/groupChannel.ts
|
|
1919
|
+
var GroupChannel2 = class extends Channel {
|
|
1920
|
+
/**
|
|
1921
|
+
* Creates a new GroupChannel instance.
|
|
1922
|
+
*
|
|
1923
|
+
* @param {client} client - The client instance.
|
|
1924
|
+
* @param {APIGroupChannel} data - The raw data for the group channel from the API.
|
|
1925
|
+
*/
|
|
1926
|
+
constructor(client3, data) {
|
|
1927
|
+
super(client3);
|
|
1928
|
+
/** The type of the channel, which is always `GROUP` for group channels. */
|
|
1929
|
+
this.type = "GROUP" /* GROUP */;
|
|
1930
|
+
/** The description of the group channel, if any. */
|
|
1931
|
+
this.description = null;
|
|
1932
|
+
/** The icon of the group channel, if any. */
|
|
1933
|
+
this.icon = null;
|
|
1934
|
+
/** Manages the messages in this group channel. */
|
|
1935
|
+
this.messages = new MessageManager(this);
|
|
1936
|
+
/** The ID of the last message sent in this group channel, if any. */
|
|
1937
|
+
this.lastMessageId = null;
|
|
1938
|
+
/** A map of user IDs to their corresponding `User` instances in the group channel. */
|
|
1939
|
+
this.users = /* @__PURE__ */ new Map();
|
|
1940
|
+
/** Whether the group channel is marked as NSFW (Not Safe For Work). */
|
|
1941
|
+
this.nsfw = false;
|
|
1942
|
+
this._patch(data);
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* Updates the group channel instance with new data from the API.
|
|
1946
|
+
*
|
|
1947
|
+
* @param {APIGroupChannel} data - The raw data for the group channel from the API.
|
|
1948
|
+
* @returns {this} The updated group channel instance.
|
|
1949
|
+
* @protected
|
|
1950
|
+
*/
|
|
1951
|
+
_patch(data) {
|
|
1952
|
+
var _a;
|
|
1953
|
+
super._patch(data);
|
|
1954
|
+
if ("description" in data) {
|
|
1955
|
+
this.description = (_a = data.description) != null ? _a : null;
|
|
1956
|
+
}
|
|
1957
|
+
if (Array.isArray(data.recipients)) {
|
|
1958
|
+
this.users.clear();
|
|
1959
|
+
for (const userId of data.recipients) {
|
|
1960
|
+
const user = this.client.users.cache.get(userId);
|
|
1961
|
+
if (user) this.users.set(user.id, user);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
if (typeof data.permissions === "number") {
|
|
1965
|
+
this.permissions = new ChannelPermissions(data.permissions).freeze();
|
|
1966
|
+
}
|
|
1967
|
+
if (data.owner) {
|
|
1968
|
+
this.ownerId = data.owner;
|
|
1969
|
+
}
|
|
1970
|
+
if (data.icon) {
|
|
1971
|
+
this.icon = new Attachment(this.client, data.icon);
|
|
1972
|
+
}
|
|
1973
|
+
if (data.name) {
|
|
1974
|
+
this.name = data.name;
|
|
1975
|
+
}
|
|
1976
|
+
if (data.last_message_id) this.lastMessageId = data.last_message_id;
|
|
1977
|
+
if (typeof data.nsfw === "boolean") this.nsfw = data.nsfw;
|
|
1978
|
+
return this;
|
|
1979
|
+
}
|
|
1980
|
+
/**
|
|
1981
|
+
* Retrieves the last message sent in this group channel.
|
|
1982
|
+
*
|
|
1983
|
+
* @returns {Message | null} The last message, or `null` if no message exists.
|
|
1984
|
+
*/
|
|
1985
|
+
get lastMessage() {
|
|
1986
|
+
var _a;
|
|
1987
|
+
if (!this.lastMessageId) return null;
|
|
1988
|
+
return (_a = this.messages.cache.get(this.lastMessageId)) != null ? _a : null;
|
|
1989
|
+
}
|
|
1990
|
+
/**
|
|
1991
|
+
* Retrieves the owner of the group channel.
|
|
1992
|
+
*
|
|
1993
|
+
* @returns {User | null} The owner of the group channel, or `null` if not found.
|
|
1994
|
+
*/
|
|
1995
|
+
get owner() {
|
|
1996
|
+
var _a;
|
|
1997
|
+
return (_a = this.client.users.cache.get(this.ownerId)) != null ? _a : null;
|
|
1998
|
+
}
|
|
1999
|
+
/**
|
|
2000
|
+
* Deletes multiple messages from this group channel.
|
|
2001
|
+
*
|
|
2002
|
+
* @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.
|
|
2003
|
+
* @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
|
|
2004
|
+
*
|
|
2005
|
+
* @example
|
|
2006
|
+
* ```typescript
|
|
2007
|
+
* await groupChannel.bulkDelete(10); // Deletes the last 10 messages.
|
|
2008
|
+
* ```
|
|
2009
|
+
*/
|
|
2010
|
+
bulkDelete(messages) {
|
|
2011
|
+
return this.messages.bulkDelete(messages);
|
|
2012
|
+
}
|
|
2013
|
+
/**
|
|
2014
|
+
* Creates an invite for the group channel.
|
|
2015
|
+
*
|
|
2016
|
+
* @returns {Promise<Invite>} A promise that resolves with the created invite.
|
|
2017
|
+
*
|
|
2018
|
+
* @example
|
|
2019
|
+
* ```typescript
|
|
2020
|
+
* const invite = await groupChannel.createInvite();
|
|
2021
|
+
* console.log(`Invite created: ${invite}`);
|
|
2022
|
+
* ```
|
|
2023
|
+
*/
|
|
2024
|
+
createInvite() {
|
|
2025
|
+
return __async(this, null, function* () {
|
|
2026
|
+
const data = yield this.client.api.post(`/channels/${this.id}/invites`, {});
|
|
2027
|
+
return new Invite(
|
|
2028
|
+
this.client,
|
|
2029
|
+
data
|
|
2030
|
+
);
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
/**
|
|
2034
|
+
* Adds a user to the group channel.
|
|
2035
|
+
*
|
|
2036
|
+
* @param {UserResolvable} user - The user to add to the group channel.
|
|
2037
|
+
* @returns {Promise<void>} A promise that resolves when the user has been successfully added.
|
|
2038
|
+
*
|
|
2039
|
+
* @example
|
|
2040
|
+
* ```typescript
|
|
2041
|
+
* await groupChannel.add(user);
|
|
2042
|
+
* ```
|
|
2043
|
+
*/
|
|
2044
|
+
add(user) {
|
|
2045
|
+
return __async(this, null, function* () {
|
|
2046
|
+
const id = this.client.users.resolveId(user);
|
|
2047
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
2048
|
+
yield this.client.api.put(`/channels/${this.id}/recipients/${id}`);
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
/**
|
|
2052
|
+
* Removes a user from the group channel.
|
|
2053
|
+
*
|
|
2054
|
+
* @param {UserResolvable} user - The user to remove from the group channel.
|
|
2055
|
+
* @returns {Promise<void>} A promise that resolves when the user has been successfully removed.
|
|
2056
|
+
*
|
|
2057
|
+
* @example
|
|
2058
|
+
* ```typescript
|
|
2059
|
+
* await groupChannel.remove(user);
|
|
2060
|
+
* ```
|
|
2061
|
+
*/
|
|
2062
|
+
remove(user) {
|
|
2063
|
+
return __async(this, null, function* () {
|
|
2064
|
+
const id = this.client.users.resolveId(user);
|
|
2065
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
2066
|
+
yield this.client.api.delete(`/channels/${this.id}/recipients/${id}`);
|
|
2067
|
+
});
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* Leaves the group channel.
|
|
2071
|
+
*
|
|
2072
|
+
* @returns {Promise<void>} A promise that resolves when the group channel has been successfully left.
|
|
2073
|
+
*
|
|
2074
|
+
* @example
|
|
2075
|
+
* ```typescript
|
|
2076
|
+
* await groupChannel.leave();
|
|
2077
|
+
* ```
|
|
2078
|
+
*/
|
|
2079
|
+
leave() {
|
|
2080
|
+
return super.delete();
|
|
2081
|
+
}
|
|
2082
|
+
/**
|
|
2083
|
+
* Sends a message to this group channel.
|
|
2084
|
+
*
|
|
2085
|
+
* @param {MessageOptions | string} options - The message content or options for the message.
|
|
2086
|
+
* @returns {Promise<Message>} A promise that resolves with the sent message.
|
|
2087
|
+
*
|
|
2088
|
+
* @example
|
|
2089
|
+
* ```typescript
|
|
2090
|
+
* await groupChannel.send("Hello, group!");
|
|
2091
|
+
* ```
|
|
2092
|
+
*/
|
|
2093
|
+
send(options) {
|
|
2094
|
+
return this.messages.send(options);
|
|
2095
|
+
}
|
|
2096
|
+
// iconURL(options?: { size: number }): string | null {
|
|
2097
|
+
// if (!this.icon) return null;
|
|
2098
|
+
// return this.client.api.cdn.icon(this.icon.id, options?.size);
|
|
2099
|
+
// }
|
|
2100
|
+
};
|
|
2101
|
+
|
|
2102
|
+
// src/struct/invite.ts
|
|
2103
|
+
var Invite = class extends Base {
|
|
2104
|
+
/**
|
|
2105
|
+
* Creates a new Invite instance.
|
|
2106
|
+
*
|
|
2107
|
+
* @param {client} client - The client instance.
|
|
2108
|
+
* @param {APIInvite} data - The raw data for the invite from the API.
|
|
2109
|
+
*/
|
|
2110
|
+
constructor(client3, data) {
|
|
2111
|
+
super(client3);
|
|
2112
|
+
/** The ID of the server associated with the invite, if any. */
|
|
2113
|
+
this.serverId = null;
|
|
2114
|
+
this._patch(data);
|
|
2115
|
+
}
|
|
2116
|
+
/**
|
|
2117
|
+
* Updates the invite instance with new data from the API.
|
|
2118
|
+
*
|
|
2119
|
+
* @param {APIInvite} data - The raw data for the invite from the API.
|
|
2120
|
+
* @returns {this} The updated invite instance.
|
|
2121
|
+
* @protected
|
|
2122
|
+
*/
|
|
2123
|
+
_patch(data) {
|
|
2124
|
+
super._patch(data);
|
|
2125
|
+
if (data.channel) this.channelId = data.channel;
|
|
2126
|
+
if (data.creator) this.inviterId = data.channel;
|
|
2127
|
+
return this;
|
|
2128
|
+
}
|
|
2129
|
+
/**
|
|
2130
|
+
* Retrieves the server associated with the invite.
|
|
2131
|
+
*
|
|
2132
|
+
* @returns {Server | null} The server associated with the invite, or `null` if not found.
|
|
2133
|
+
*/
|
|
2134
|
+
get server() {
|
|
2135
|
+
var _a;
|
|
2136
|
+
return (_a = this.client.servers.cache.get(this.serverId)) != null ? _a : null;
|
|
2137
|
+
}
|
|
2138
|
+
/**
|
|
2139
|
+
* Retrieves the channel associated with the invite.
|
|
2140
|
+
*
|
|
2141
|
+
* @returns {Channel | null} The channel associated with the invite, or `null` if not found.
|
|
2142
|
+
*/
|
|
2143
|
+
get channel() {
|
|
2144
|
+
var _a;
|
|
2145
|
+
return (_a = this.client.channels.cache.get(this.channelId)) != null ? _a : null;
|
|
2146
|
+
}
|
|
2147
|
+
/**
|
|
2148
|
+
* Retrieves the user who created the invite.
|
|
2149
|
+
*
|
|
2150
|
+
* @returns {User | null} The user who created the invite, or `null` if not found.
|
|
2151
|
+
*/
|
|
2152
|
+
get inviter() {
|
|
2153
|
+
var _a;
|
|
2154
|
+
return (_a = this.client.users.cache.get(this.inviterId)) != null ? _a : null;
|
|
2155
|
+
}
|
|
2156
|
+
// toString(): string {
|
|
2157
|
+
// return this.client.api.cdn.invite(this.id);
|
|
2158
|
+
// }
|
|
2159
|
+
};
|
|
2160
|
+
|
|
2161
|
+
// src/struct/mentions.ts
|
|
2162
|
+
var Mentions = class {
|
|
2163
|
+
/**
|
|
2164
|
+
* Creates a new Mentions instance.
|
|
2165
|
+
*
|
|
2166
|
+
* @param {Message} message - The message associated with the mentions.
|
|
2167
|
+
* @param {string[]} _users - An array of user IDs mentioned in the message.
|
|
2168
|
+
*/
|
|
2169
|
+
constructor(message, _users) {
|
|
2170
|
+
this.message = message;
|
|
2171
|
+
this._users = _users;
|
|
2172
|
+
this.client = message.client;
|
|
2173
|
+
}
|
|
2174
|
+
/**
|
|
2175
|
+
* Checks if a specific user is mentioned in the message.
|
|
2176
|
+
*
|
|
2177
|
+
* @param {UserResolvable} user - The user to check.
|
|
2178
|
+
* @returns {boolean} `true` if the user is mentioned, otherwise `false`.
|
|
2179
|
+
* @throws {TypeError} Throws an error if the user cannot be resolved.
|
|
2180
|
+
*
|
|
2181
|
+
* @example
|
|
2182
|
+
* ```typescript
|
|
2183
|
+
* if (mentions.has(someUser)) {
|
|
2184
|
+
* console.log("User is mentioned!");
|
|
2185
|
+
* }
|
|
2186
|
+
* ```
|
|
2187
|
+
*/
|
|
2188
|
+
has(user) {
|
|
2189
|
+
const id = this.client.users.resolveId(user);
|
|
2190
|
+
if (!id) throw new TypeError("INVALID_TYPE");
|
|
2191
|
+
return this._users.includes(id);
|
|
2192
|
+
}
|
|
2193
|
+
/**
|
|
2194
|
+
* Retrieves the server members mentioned in the message.
|
|
2195
|
+
*
|
|
2196
|
+
* @returns {Map<string, ServerMember> | null} A map of user IDs to `ServerMember` instances, or `null` if the message is not in a server.
|
|
2197
|
+
*
|
|
2198
|
+
* @example
|
|
2199
|
+
* ```typescript
|
|
2200
|
+
* const members = mentions.members;
|
|
2201
|
+
* if (members) {
|
|
2202
|
+
* members.forEach(member => console.log(member.displayName));
|
|
2203
|
+
* }
|
|
2204
|
+
* ```
|
|
2205
|
+
*/
|
|
2206
|
+
get members() {
|
|
2207
|
+
const server = this.message.server;
|
|
2208
|
+
if (!server) return null;
|
|
2209
|
+
const members = /* @__PURE__ */ new Map();
|
|
2210
|
+
for (const userId of this._users) {
|
|
2211
|
+
const member = server.members.cache.get(userId);
|
|
2212
|
+
if (member) members.set(member.id, member);
|
|
2213
|
+
}
|
|
2214
|
+
return members;
|
|
2215
|
+
}
|
|
2216
|
+
/**
|
|
2217
|
+
* Retrieves the users mentioned in the message.
|
|
2218
|
+
*
|
|
2219
|
+
* @returns {Map<string, User>} A map of user IDs to `User` instances.
|
|
2220
|
+
*
|
|
2221
|
+
* @example
|
|
2222
|
+
* ```typescript
|
|
2223
|
+
* const users = mentions.users;
|
|
2224
|
+
* users.forEach(user => console.log(user.username));
|
|
2225
|
+
* ```
|
|
2226
|
+
*/
|
|
2227
|
+
get users() {
|
|
2228
|
+
const users = /* @__PURE__ */ new Map();
|
|
2229
|
+
for (const userId of this._users) {
|
|
2230
|
+
const user = this.client.users.cache.get(userId);
|
|
2231
|
+
if (user) users.set(user.id, user);
|
|
2232
|
+
}
|
|
2233
|
+
return users;
|
|
2234
|
+
}
|
|
2235
|
+
};
|
|
2236
|
+
|
|
2237
|
+
// src/struct/messageEmbed.ts
|
|
2238
|
+
var import_stream2 = require("stream");
|
|
2239
|
+
var import_axios5 = __toESM(require("axios"), 1);
|
|
2240
|
+
var import_form_data2 = __toESM(require("form-data"), 1);
|
|
2241
|
+
var import_node_buffer2 = require("buffer");
|
|
2242
|
+
var _url, _title, _description, _icon_url, _color, _media;
|
|
2243
|
+
var MessageEmbed2 = class {
|
|
2244
|
+
constructor() {
|
|
2245
|
+
__privateAdd(this, _url);
|
|
2246
|
+
__privateAdd(this, _title);
|
|
2247
|
+
__privateAdd(this, _description);
|
|
2248
|
+
__privateAdd(this, _icon_url);
|
|
2249
|
+
__privateAdd(this, _color);
|
|
2250
|
+
__privateAdd(this, _media);
|
|
2251
|
+
}
|
|
2252
|
+
/**
|
|
2253
|
+
* Sets the title of the embed.
|
|
2254
|
+
*
|
|
2255
|
+
* @param {string} title - The title to set.
|
|
2256
|
+
* @returns {this} The updated `MessageEmbed` instance.
|
|
2257
|
+
*/
|
|
2258
|
+
setTitle(title) {
|
|
2259
|
+
__privateSet(this, _title, title);
|
|
2260
|
+
return this;
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Sets the icon URL of the embed.
|
|
2264
|
+
*
|
|
2265
|
+
* @param {string} iconURL - The URL of the icon to set.
|
|
2266
|
+
* @returns {this} The updated `MessageEmbed` instance.
|
|
2267
|
+
*/
|
|
2268
|
+
setIcon(iconURL) {
|
|
2269
|
+
__privateSet(this, _icon_url, iconURL);
|
|
2270
|
+
return this;
|
|
2271
|
+
}
|
|
2272
|
+
/**
|
|
2273
|
+
* Sets the color of the embed.
|
|
2274
|
+
*
|
|
2275
|
+
* @param {string} color - The color to set (e.g., a hex code).
|
|
2276
|
+
* @returns {this} The updated `MessageEmbed` instance.
|
|
2277
|
+
*/
|
|
2278
|
+
setColor(color) {
|
|
2279
|
+
__privateSet(this, _color, color);
|
|
2280
|
+
return this;
|
|
2281
|
+
}
|
|
2282
|
+
/**
|
|
2283
|
+
* Sets the description of the embed.
|
|
2284
|
+
*
|
|
2285
|
+
* @param {string} description - The description to set.
|
|
2286
|
+
* @returns {this} The updated `MessageEmbed` instance.
|
|
2287
|
+
*/
|
|
2288
|
+
setDescription(description) {
|
|
2289
|
+
__privateSet(this, _description, description);
|
|
2290
|
+
return this;
|
|
2291
|
+
}
|
|
2292
|
+
/**
|
|
2293
|
+
* Sets the URL of the embed.
|
|
2294
|
+
*
|
|
2295
|
+
* @param {string} url - The URL to set.
|
|
2296
|
+
* @returns {this} The updated `MessageEmbed` instance.
|
|
2297
|
+
*/
|
|
2298
|
+
setURL(url) {
|
|
2299
|
+
__privateSet(this, _url, url);
|
|
2300
|
+
return this;
|
|
2301
|
+
}
|
|
2302
|
+
/**
|
|
2303
|
+
* Sets the media (e.g., image or video) of the embed.
|
|
2304
|
+
*
|
|
2305
|
+
* @param {Readable | string | File} media - The media URL, File or Stream to set.
|
|
2306
|
+
* @returns {this} The updated `MessageEmbed` instance.
|
|
2307
|
+
*/
|
|
2308
|
+
setMedia(media) {
|
|
2309
|
+
__privateSet(this, _media, media);
|
|
2310
|
+
return this;
|
|
2311
|
+
}
|
|
2312
|
+
/**
|
|
2313
|
+
*
|
|
2314
|
+
* @param client The client instance used to send the embed.
|
|
2315
|
+
* @returns SendableEmbed
|
|
2316
|
+
* Converts the embed to a JSON object that can be sent to the API, including media handling.
|
|
2317
|
+
*/
|
|
2318
|
+
toJSONWithMedia(client3) {
|
|
2319
|
+
return __async(this, null, function* () {
|
|
2320
|
+
const embed = {
|
|
2321
|
+
title: __privateGet(this, _title),
|
|
2322
|
+
icon_url: __privateGet(this, _icon_url),
|
|
2323
|
+
colour: __privateGet(this, _color),
|
|
2324
|
+
description: __privateGet(this, _description),
|
|
2325
|
+
url: __privateGet(this, _url)
|
|
2326
|
+
};
|
|
2327
|
+
if (__privateGet(this, _media)) {
|
|
2328
|
+
let att = __privateGet(this, _media);
|
|
2329
|
+
const data = new import_form_data2.default();
|
|
2330
|
+
if (typeof att === "string") {
|
|
2331
|
+
const readableStream = yield import_axios5.default.get(att, {
|
|
2332
|
+
responseType: "stream"
|
|
2333
|
+
});
|
|
2334
|
+
data.append("file", readableStream.data, {
|
|
2335
|
+
filename: att.split("/").pop()
|
|
2336
|
+
});
|
|
2337
|
+
}
|
|
2338
|
+
if (att instanceof import_stream2.Readable) {
|
|
2339
|
+
data.append("file", att);
|
|
2340
|
+
}
|
|
2341
|
+
if (att instanceof import_node_buffer2.File) {
|
|
2342
|
+
const buffer = Buffer.from(yield att.arrayBuffer());
|
|
2343
|
+
data.append("file", buffer, { filename: att.name });
|
|
2344
|
+
}
|
|
2345
|
+
yield client3.cdn.post("/attachments", data).then((attachment) => {
|
|
2346
|
+
const { id } = attachment;
|
|
2347
|
+
embed.media = id;
|
|
2348
|
+
});
|
|
2349
|
+
}
|
|
2350
|
+
return embed;
|
|
2351
|
+
});
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Converts the embed to a JSON object that can be sent to the API.
|
|
2355
|
+
*
|
|
2356
|
+
* @returns {SendableEmbed} The JSON representation of the embed.
|
|
2357
|
+
*/
|
|
2358
|
+
toJSON() {
|
|
2359
|
+
var _a;
|
|
2360
|
+
return {
|
|
2361
|
+
title: __privateGet(this, _title),
|
|
2362
|
+
icon_url: __privateGet(this, _icon_url),
|
|
2363
|
+
colour: __privateGet(this, _color),
|
|
2364
|
+
description: __privateGet(this, _description),
|
|
2365
|
+
url: __privateGet(this, _url),
|
|
2366
|
+
media: (_a = __privateGet(this, _media)) == null ? void 0 : _a.toString()
|
|
2367
|
+
};
|
|
2368
|
+
}
|
|
2369
|
+
};
|
|
2370
|
+
_url = new WeakMap();
|
|
2371
|
+
_title = new WeakMap();
|
|
2372
|
+
_description = new WeakMap();
|
|
2373
|
+
_icon_url = new WeakMap();
|
|
2374
|
+
_color = new WeakMap();
|
|
2375
|
+
_media = new WeakMap();
|
|
2376
|
+
|
|
2377
|
+
// src/struct/notesChannel.ts
|
|
2378
|
+
var NotesChannel = class extends Channel {
|
|
2379
|
+
/**
|
|
2380
|
+
* Creates a new NotesChannel instance.
|
|
2381
|
+
*
|
|
2382
|
+
* @param {client} client - The client instance.
|
|
2383
|
+
* @param {APINotesChannel} data - The raw data for the notes channel from the API.
|
|
2384
|
+
*/
|
|
2385
|
+
constructor(client3, data) {
|
|
2386
|
+
super(client3);
|
|
2387
|
+
/** The type of the channel, which is always `NOTES` for notes channels. */
|
|
2388
|
+
this.type = "NOTES" /* NOTES */;
|
|
2389
|
+
/** The ID of the last message sent in this notes channel, if any. */
|
|
2390
|
+
this.lastMessageId = null;
|
|
2391
|
+
/** Manages the messages in this notes channel. */
|
|
2392
|
+
this.messages = new MessageManager(this);
|
|
2393
|
+
this._patch(data);
|
|
2394
|
+
}
|
|
2395
|
+
/**
|
|
2396
|
+
* Updates the notes channel instance with new data from the API.
|
|
2397
|
+
*
|
|
2398
|
+
* @param {APINotesChannel} data - The raw data for the notes channel from the API.
|
|
2399
|
+
* @returns {this} The updated notes channel instance.
|
|
2400
|
+
* @protected
|
|
2401
|
+
*/
|
|
2402
|
+
_patch(data) {
|
|
2403
|
+
super._patch(data);
|
|
2404
|
+
if (data.user) {
|
|
2405
|
+
this.userId = data.user;
|
|
2406
|
+
}
|
|
2407
|
+
return this;
|
|
2408
|
+
}
|
|
2409
|
+
/**
|
|
2410
|
+
* Sends a message to this notes channel.
|
|
2411
|
+
*
|
|
2412
|
+
* @param {MessageOptions | string} options - The message content or options for the message.
|
|
2413
|
+
* @returns {Promise<Message>} A promise that resolves with the sent message.
|
|
2414
|
+
*
|
|
2415
|
+
* @example
|
|
2416
|
+
* ```typescript
|
|
2417
|
+
* await notesChannel.send("This is a saved message.");
|
|
2418
|
+
* ```
|
|
2419
|
+
*/
|
|
2420
|
+
send(options) {
|
|
2421
|
+
return this.messages.send(options);
|
|
2422
|
+
}
|
|
2423
|
+
/**
|
|
2424
|
+
* Deletes multiple messages from this notes channel.
|
|
2425
|
+
*
|
|
2426
|
+
* @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.
|
|
2427
|
+
* @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
|
|
2428
|
+
*
|
|
2429
|
+
* @example
|
|
2430
|
+
* ```typescript
|
|
2431
|
+
* await notesChannel.bulkDelete(5); // Deletes the last 5 messages.
|
|
2432
|
+
* ```
|
|
2433
|
+
*/
|
|
2434
|
+
bulkDelete(messages) {
|
|
2435
|
+
return this.messages.bulkDelete(messages);
|
|
2436
|
+
}
|
|
2437
|
+
/**
|
|
2438
|
+
* Retrieves the last message sent in this notes channel.
|
|
2439
|
+
*
|
|
2440
|
+
* @returns {Message | null} The last message, or `null` if no message exists.
|
|
2441
|
+
*/
|
|
2442
|
+
get lastMessage() {
|
|
2443
|
+
var _a;
|
|
2444
|
+
if (!this.lastMessageId) return null;
|
|
2445
|
+
return (_a = this.messages.cache.get(this.lastMessageId)) != null ? _a : null;
|
|
2446
|
+
}
|
|
2447
|
+
/**
|
|
2448
|
+
* Retrieves the user associated with this notes channel.
|
|
2449
|
+
*
|
|
2450
|
+
* @returns {User} The user associated with the notes channel.
|
|
2451
|
+
*/
|
|
2452
|
+
get user() {
|
|
2453
|
+
return this.client.user;
|
|
2454
|
+
}
|
|
2455
|
+
};
|
|
2456
|
+
|
|
2457
|
+
// src/struct/serverChannel.ts
|
|
2458
|
+
var ServerChannel = class extends Channel {
|
|
2459
|
+
/**
|
|
2460
|
+
* Creates a new ServerChannel instance.
|
|
2461
|
+
*
|
|
2462
|
+
* @param {client} client - The client instance.
|
|
2463
|
+
* @param {APIServerChannel} data - The raw data for the server channel from the API.
|
|
2464
|
+
*/
|
|
2465
|
+
constructor(client3, data) {
|
|
2466
|
+
super(client3);
|
|
2467
|
+
/** The description of the channel, or `null` if none is set. */
|
|
2468
|
+
this.description = null;
|
|
2469
|
+
/** The icon of the channel, or `null` if none is set. */
|
|
2470
|
+
this.icon = null;
|
|
2471
|
+
/** The permission overwrites for the channel. */
|
|
2472
|
+
this.overwrites = /* @__PURE__ */ new Map();
|
|
2473
|
+
/** Whether the channel is marked as NSFW (Not Safe For Work). */
|
|
2474
|
+
this.nsfw = false;
|
|
2475
|
+
this._patch(data);
|
|
2476
|
+
}
|
|
2477
|
+
/**
|
|
2478
|
+
* Updates the server channel instance with new data from the API.
|
|
2479
|
+
*
|
|
2480
|
+
* @param {APIServerChannel} data - The raw data for the server channel from the API.
|
|
2481
|
+
* @param {FieldsChannel[]} [clear=[]] - Fields to clear in the channel.
|
|
2482
|
+
* @returns {this} The updated server channel instance.
|
|
2483
|
+
* @protected
|
|
2484
|
+
*/
|
|
2485
|
+
_patch(data, clear = []) {
|
|
2486
|
+
var _a;
|
|
2487
|
+
super._patch(data);
|
|
2488
|
+
if (data.name) this.name = data.name;
|
|
2489
|
+
if (data.server) this.serverId = data.server;
|
|
2490
|
+
if ("description" in data) this.description = (_a = data.description) != null ? _a : null;
|
|
2491
|
+
if (data.icon) this.icon = new Attachment(this.client, data.icon);
|
|
2492
|
+
if (typeof data.nsfw === "boolean") this.nsfw = data.nsfw;
|
|
2493
|
+
if (data.role_permissions) {
|
|
2494
|
+
this.overwrites.clear();
|
|
2495
|
+
for (const [id, { a, d }] of Object.entries(data.role_permissions)) {
|
|
2496
|
+
this.overwrites.set(id, {
|
|
2497
|
+
allow: new FullPermissions(a),
|
|
2498
|
+
deny: new FullPermissions(d)
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
for (const field of clear) {
|
|
2503
|
+
if (field === "Icon") this.icon = null;
|
|
2504
|
+
if (field === "Description") this.description = null;
|
|
2505
|
+
}
|
|
2506
|
+
return this;
|
|
2507
|
+
}
|
|
2508
|
+
/**
|
|
2509
|
+
* Creates an invite for the server channel.
|
|
2510
|
+
*
|
|
2511
|
+
* @returns {Promise<Invite>} A promise that resolves with the created invite.
|
|
2512
|
+
*
|
|
2513
|
+
* @example
|
|
2514
|
+
* ```typescript
|
|
2515
|
+
* const invite = await serverChannel.createInvite();
|
|
2516
|
+
* console.log(`Invite created: ${invite}`);
|
|
2517
|
+
* ```
|
|
2518
|
+
*/
|
|
2519
|
+
createInvite() {
|
|
2520
|
+
return __async(this, null, function* () {
|
|
2521
|
+
const data = yield this.client.api.post(`/channels/${this.id}/invites`, {});
|
|
2522
|
+
return new Invite(
|
|
2523
|
+
this.client,
|
|
2524
|
+
data
|
|
2525
|
+
);
|
|
2526
|
+
});
|
|
2527
|
+
}
|
|
2528
|
+
// iconURL(options?: { size: number }): string | null {
|
|
2529
|
+
// return this.icon
|
|
2530
|
+
// ? this.client.api.cdn.icon(this.icon.id, options?.size)
|
|
2531
|
+
// : null;
|
|
2532
|
+
// }
|
|
2533
|
+
/**
|
|
2534
|
+
* Retrieves the server this channel belongs to.
|
|
2535
|
+
*
|
|
2536
|
+
* @returns {Server} The server instance.
|
|
2537
|
+
*/
|
|
2538
|
+
get server() {
|
|
2539
|
+
return this.client.servers.cache.get(this.serverId);
|
|
2540
|
+
}
|
|
2541
|
+
/**
|
|
2542
|
+
* Retrieves the category this channel belongs to, if any.
|
|
2543
|
+
*
|
|
2544
|
+
* @returns {Category | null} The category instance, or `null` if the channel is not in a category.
|
|
2545
|
+
*/
|
|
2546
|
+
get category() {
|
|
2547
|
+
var _a;
|
|
2548
|
+
return (_a = Array.from(this.server.categories.values()).find(
|
|
2549
|
+
(cat) => cat.children.has(this.id)
|
|
2550
|
+
)) != null ? _a : null;
|
|
2551
|
+
}
|
|
2552
|
+
};
|
|
2553
|
+
|
|
2554
|
+
// src/struct/serverMember.ts
|
|
2555
|
+
var ServerMember2 = class extends Base {
|
|
2556
|
+
/**
|
|
2557
|
+
* Creates a new ServerMember instance.
|
|
2558
|
+
*
|
|
2559
|
+
* @param {client} client - The client instance.
|
|
2560
|
+
* @param {APIMember} data - The raw data for the server member from the API.
|
|
2561
|
+
*/
|
|
2562
|
+
constructor(client3, data) {
|
|
2563
|
+
super(client3);
|
|
2564
|
+
/** The nickname of the member, or `null` if none is set. */
|
|
2565
|
+
this.nickname = null;
|
|
2566
|
+
/** The avatar of the member, or `null` if none is set. */
|
|
2567
|
+
this.avatar = null;
|
|
2568
|
+
/** roles assigned to the member */
|
|
2569
|
+
this.roles = [];
|
|
2570
|
+
this._patch(data);
|
|
2571
|
+
}
|
|
2572
|
+
/**
|
|
2573
|
+
* Updates the server member instance with new data from the API.
|
|
2574
|
+
*
|
|
2575
|
+
* @param {APIMember} data - The raw data for the server member from the API.
|
|
2576
|
+
* @param {FieldsMember[]} [clear=[]] - Fields to clear in the server member.
|
|
2577
|
+
* @returns {this} The updated server member instance.
|
|
2578
|
+
* @protected
|
|
2579
|
+
*/
|
|
2580
|
+
_patch(data, clear = []) {
|
|
2581
|
+
var _a;
|
|
2582
|
+
super._patch(data);
|
|
2583
|
+
if ("nickname" in data) {
|
|
2584
|
+
this.nickname = (_a = data.nickname) != null ? _a : null;
|
|
2585
|
+
}
|
|
2586
|
+
if (data.avatar) {
|
|
2587
|
+
this.avatar = new Attachment(this.client, data.avatar);
|
|
2588
|
+
}
|
|
2589
|
+
if (data._id) {
|
|
2590
|
+
this.serverId = data._id.server;
|
|
2591
|
+
this.id = data._id.user;
|
|
2592
|
+
}
|
|
2593
|
+
if (Array.isArray(data.roles)) {
|
|
2594
|
+
if (!data.roles.length) this.roles = [];
|
|
2595
|
+
else {
|
|
2596
|
+
this.roles = data.roles.map((roleId) => {
|
|
2597
|
+
const role = this.server.roles.cache.get(roleId);
|
|
2598
|
+
if (!role) {
|
|
2599
|
+
throw new Error(
|
|
2600
|
+
`Role with ID ${roleId} not found in server ${this.serverId}`
|
|
2601
|
+
);
|
|
2602
|
+
}
|
|
2603
|
+
return role;
|
|
2604
|
+
});
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
for (const field of clear) {
|
|
2608
|
+
if (field === "Avatar") this.avatar = null;
|
|
2609
|
+
if (field === "Nickname") this.nickname = null;
|
|
2610
|
+
}
|
|
2611
|
+
return this;
|
|
2612
|
+
}
|
|
2613
|
+
/**
|
|
2614
|
+
* Sets the nickname of the server member.
|
|
2615
|
+
*
|
|
2616
|
+
* @param {string} [nickname] - The new nickname to set, or `undefined` to clear the nickname.
|
|
2617
|
+
* @returns {Promise<this>} A promise that resolves with the updated server member instance.
|
|
2618
|
+
*
|
|
2619
|
+
* @example
|
|
2620
|
+
* ```typescript
|
|
2621
|
+
* await member.setNickname("NewNickname");
|
|
2622
|
+
* ```
|
|
2623
|
+
*/
|
|
2624
|
+
setNickname(nickname) {
|
|
2625
|
+
return __async(this, null, function* () {
|
|
2626
|
+
yield this.server.members.edit(this, { nickname });
|
|
2627
|
+
return this;
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
/**
|
|
2631
|
+
* adds a role to the server member.
|
|
2632
|
+
* @param roleId - The ID of the role to add to the member.
|
|
2633
|
+
* @returns
|
|
2634
|
+
*/
|
|
2635
|
+
addRole(roleId) {
|
|
2636
|
+
return __async(this, null, function* () {
|
|
2637
|
+
const currentRoles = this.roles.map((role) => role.id);
|
|
2638
|
+
if (currentRoles.includes(roleId)) {
|
|
2639
|
+
return this;
|
|
2640
|
+
}
|
|
2641
|
+
yield this.server.members.edit(this, {
|
|
2642
|
+
roles: [...currentRoles, roleId]
|
|
2643
|
+
});
|
|
2644
|
+
return this;
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2647
|
+
/**
|
|
2648
|
+
* Removes a role from the server member.
|
|
2649
|
+
*
|
|
2650
|
+
* @param {string} roleId - The ID of the role to remove from the member.
|
|
2651
|
+
* @returns {Promise<this>} A promise that resolves with the updated server member instance.
|
|
2652
|
+
*
|
|
2653
|
+
* @example
|
|
2654
|
+
* ```typescript
|
|
2655
|
+
* await member.removeRole("roleId");
|
|
2656
|
+
* ```
|
|
2657
|
+
*/
|
|
2658
|
+
removeRole(roleId) {
|
|
2659
|
+
return __async(this, null, function* () {
|
|
2660
|
+
const currentRoles = this.roles.map((role) => role.id);
|
|
2661
|
+
if (!currentRoles.includes(roleId)) {
|
|
2662
|
+
return this;
|
|
2663
|
+
}
|
|
2664
|
+
yield this.server.members.edit(this, {
|
|
2665
|
+
roles: currentRoles.filter((id) => id !== roleId)
|
|
2666
|
+
});
|
|
2667
|
+
return this;
|
|
2668
|
+
});
|
|
2669
|
+
}
|
|
2670
|
+
/**
|
|
2671
|
+
* Bans the server member.
|
|
2672
|
+
*
|
|
2673
|
+
* @param {string} [reason] - The reason for the ban.
|
|
2674
|
+
* @returns {Promise<void>} A promise that resolves when the member is banned.
|
|
2675
|
+
*
|
|
2676
|
+
* @example
|
|
2677
|
+
* ```typescript
|
|
2678
|
+
* await member.ban("Violation of rules");
|
|
2679
|
+
* ```
|
|
2680
|
+
*/
|
|
2681
|
+
ban(reason) {
|
|
2682
|
+
return this.server.members.ban(this, reason);
|
|
2683
|
+
}
|
|
2684
|
+
/**
|
|
2685
|
+
* Kicks the server member.
|
|
2686
|
+
*
|
|
2687
|
+
* @returns {Promise<void>} A promise that resolves when the member is kicked.
|
|
2688
|
+
*
|
|
2689
|
+
* @example
|
|
2690
|
+
* ```typescript
|
|
2691
|
+
* await member.kick();
|
|
2692
|
+
* ```
|
|
2693
|
+
*/
|
|
2694
|
+
kick() {
|
|
2695
|
+
return this.server.members.kick(this);
|
|
2696
|
+
}
|
|
2697
|
+
/**
|
|
2698
|
+
* Leaves the server.
|
|
2699
|
+
*
|
|
2700
|
+
* @returns {Promise<void>} A promise that resolves when the member leaves the server.
|
|
2701
|
+
*
|
|
2702
|
+
* @example
|
|
2703
|
+
* ```typescript
|
|
2704
|
+
* await member.leave();
|
|
2705
|
+
* ```
|
|
2706
|
+
*/
|
|
2707
|
+
leave() {
|
|
2708
|
+
return this.client.servers.delete(this.serverId);
|
|
2709
|
+
}
|
|
2710
|
+
// async displayAvatarURL(options?: { size: number }): Promise<string> {
|
|
2711
|
+
// return await this.user.displayAvatarURL(options);
|
|
2712
|
+
// }
|
|
2713
|
+
/**
|
|
2714
|
+
* Retrieves the user associated with this server member.
|
|
2715
|
+
*
|
|
2716
|
+
* @returns {User} The user instance.
|
|
2717
|
+
*/
|
|
2718
|
+
get user() {
|
|
2719
|
+
return this.client.users.cache.get(this.id);
|
|
2720
|
+
}
|
|
2721
|
+
/**
|
|
2722
|
+
* Retrieves the server this member belongs to.
|
|
2723
|
+
*
|
|
2724
|
+
* @returns {Server} The server instance.
|
|
2725
|
+
*/
|
|
2726
|
+
get server() {
|
|
2727
|
+
return this.client.servers.cache.get(this.serverId);
|
|
2728
|
+
}
|
|
2729
|
+
/**
|
|
2730
|
+
* Converts the server member to a string representation.
|
|
2731
|
+
*
|
|
2732
|
+
* @returns {string} A string representation of the server member in the format `<@userId>`.
|
|
2733
|
+
*/
|
|
2734
|
+
toString() {
|
|
2735
|
+
return `<@${this.id}>`;
|
|
2736
|
+
}
|
|
2737
|
+
};
|
|
2738
|
+
|
|
2739
|
+
// src/struct/textChannel.ts
|
|
2740
|
+
var TextChannel2 = class extends ServerChannel {
|
|
2741
|
+
/**
|
|
2742
|
+
* Creates a new TextChannel instance.
|
|
2743
|
+
*
|
|
2744
|
+
* @param {client} client - The client instance.
|
|
2745
|
+
* @param {APITextChannel} data - The raw data for the text channel from the API.
|
|
2746
|
+
*/
|
|
2747
|
+
constructor(client3, data) {
|
|
2748
|
+
super(client3, data);
|
|
2749
|
+
/** The ID of the last message sent in this text channel, if any. */
|
|
2750
|
+
this.lastMessageId = null;
|
|
2751
|
+
/** Manages the messages in this text channel. */
|
|
2752
|
+
this.messages = new MessageManager(this);
|
|
2753
|
+
/** The type of the channel, which is always `TEXT` for text channels. */
|
|
2754
|
+
this.type = "TEXT" /* TEXT */;
|
|
2755
|
+
this._patch(data);
|
|
2756
|
+
}
|
|
2757
|
+
/**
|
|
2758
|
+
* Updates the text channel instance with new data from the API.
|
|
2759
|
+
*
|
|
2760
|
+
* @param {APITextChannel} data - The raw data for the text channel from the API.
|
|
2761
|
+
* @returns {this} The updated text channel instance.
|
|
2762
|
+
* @protected
|
|
2763
|
+
*/
|
|
2764
|
+
_patch(data) {
|
|
2765
|
+
super._patch(data);
|
|
2766
|
+
if (data.last_message_id) this.lastMessageId = data.last_message_id;
|
|
2767
|
+
return this;
|
|
2768
|
+
}
|
|
2769
|
+
/**
|
|
2770
|
+
* Retrieves the last message sent in this text channel.
|
|
2771
|
+
*
|
|
2772
|
+
* @returns {Message | null} The last message, or `null` if no message exists.
|
|
2773
|
+
*/
|
|
2774
|
+
get lastMessage() {
|
|
2775
|
+
var _a;
|
|
2776
|
+
if (!this.lastMessageId) return null;
|
|
2777
|
+
return (_a = this.messages.cache.get(this.lastMessageId)) != null ? _a : null;
|
|
2778
|
+
}
|
|
2779
|
+
/**
|
|
2780
|
+
* Sends a message to this text channel.
|
|
2781
|
+
*
|
|
2782
|
+
* @param {MessageOptions | string} options - The message content or options for the message.
|
|
2783
|
+
* @returns {Promise<Message>} A promise that resolves with the sent message.
|
|
2784
|
+
*
|
|
2785
|
+
* @example
|
|
2786
|
+
* ```typescript
|
|
2787
|
+
* await textChannel.send("Hello, world!");
|
|
2788
|
+
* ```
|
|
2789
|
+
*/
|
|
2790
|
+
send(options) {
|
|
2791
|
+
return this.messages.send(options);
|
|
2792
|
+
}
|
|
2793
|
+
/**
|
|
2794
|
+
* Deletes multiple messages from this text channel.
|
|
2795
|
+
*
|
|
2796
|
+
* @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.
|
|
2797
|
+
* @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
|
|
2798
|
+
*
|
|
2799
|
+
* @example
|
|
2800
|
+
* ```typescript
|
|
2801
|
+
* await textChannel.bulkDelete(10); // Deletes the last 10 messages.
|
|
2802
|
+
* ```
|
|
2803
|
+
*/
|
|
2804
|
+
bulkDelete(messages) {
|
|
2805
|
+
return this.messages.bulkDelete(messages);
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2808
|
+
|
|
2809
|
+
// src/struct/voiceChannels.ts
|
|
2810
|
+
var VoiceChannel = class extends ServerChannel {
|
|
2811
|
+
/**
|
|
2812
|
+
* Creates a new VoiceChannel instance.
|
|
2813
|
+
*
|
|
2814
|
+
* @param {client} client - The client instance.
|
|
2815
|
+
* @param {APIVoiceChannel} data - The raw data for the voice channel from the API.
|
|
2816
|
+
*/
|
|
2817
|
+
constructor(client3, data) {
|
|
2818
|
+
super(client3, data);
|
|
2819
|
+
/** The type of the channel, which is always `VOICE` for voice channels. */
|
|
2820
|
+
this.type = "VOICE" /* VOICE */;
|
|
2821
|
+
this._patch(data);
|
|
2822
|
+
}
|
|
2823
|
+
/**
|
|
2824
|
+
* Updates the voice channel instance with new data from the API.
|
|
2825
|
+
*
|
|
2826
|
+
* @param {APIVoiceChannel} data - The raw data for the voice channel from the API.
|
|
2827
|
+
* @returns {this} The updated voice channel instance.
|
|
2828
|
+
* @protected
|
|
2829
|
+
*/
|
|
2830
|
+
_patch(data) {
|
|
2831
|
+
super._patch(data);
|
|
2832
|
+
return this;
|
|
2833
|
+
}
|
|
2834
|
+
/**
|
|
2835
|
+
* Acknowledges the voice channel.
|
|
2836
|
+
*
|
|
2837
|
+
* @throws {TypeError} Throws an error because voice channels cannot be acknowledged.
|
|
2838
|
+
*
|
|
2839
|
+
* @example
|
|
2840
|
+
* ```typescript
|
|
2841
|
+
* try {
|
|
2842
|
+
* await voiceChannel.ack();
|
|
2843
|
+
* } catch (error) {
|
|
2844
|
+
* console.error(error.message); // "Cannot ack voice channel"
|
|
2845
|
+
* }
|
|
2846
|
+
* ```
|
|
2847
|
+
*/
|
|
2848
|
+
ack() {
|
|
2849
|
+
throw new TypeError("Cannot ack voice channel");
|
|
2850
|
+
}
|
|
2851
|
+
};
|
|
2852
|
+
|
|
2853
|
+
// src/struct/category.ts
|
|
2854
|
+
var Category = class extends Base {
|
|
2855
|
+
/**
|
|
2856
|
+
* Creates a new Category instance.
|
|
2857
|
+
*
|
|
2858
|
+
* @param {Server} server - The server this category belongs to.
|
|
2859
|
+
* @param {APICategory} data - The raw data for the category from the API.
|
|
2860
|
+
*/
|
|
2861
|
+
constructor(server, data) {
|
|
2862
|
+
super(server.client);
|
|
2863
|
+
this.server = server;
|
|
2864
|
+
/** An array of channel IDs that belong to this category. */
|
|
2865
|
+
this._children = [];
|
|
2866
|
+
this._patch(data);
|
|
2867
|
+
}
|
|
2868
|
+
/**
|
|
2869
|
+
* Updates the category instance with new data from the API.
|
|
2870
|
+
*
|
|
2871
|
+
* @param {APICategory} data - The raw data for the category from the API.
|
|
2872
|
+
* @returns {this} The updated category instance.
|
|
2873
|
+
* @protected
|
|
2874
|
+
*/
|
|
2875
|
+
_patch(data) {
|
|
2876
|
+
super._patch(data);
|
|
2877
|
+
if (data.title) {
|
|
2878
|
+
this.name = data.title;
|
|
2879
|
+
}
|
|
2880
|
+
if (Array.isArray(data.channels)) {
|
|
2881
|
+
this._children = data.channels;
|
|
2882
|
+
}
|
|
2883
|
+
return this;
|
|
2884
|
+
}
|
|
2885
|
+
/**
|
|
2886
|
+
* Retrieves the channels that belong to this category.
|
|
2887
|
+
*
|
|
2888
|
+
* @returns {Map<string, ServerChannel>} A map of channel IDs to their corresponding `ServerChannel` instances.
|
|
2889
|
+
*/
|
|
2890
|
+
get children() {
|
|
2891
|
+
const coll = /* @__PURE__ */ new Map();
|
|
2892
|
+
for (const childId of this._children) {
|
|
2893
|
+
const child = this.server.channels.cache.get(childId);
|
|
2894
|
+
if (child) coll.set(child.id, child);
|
|
2895
|
+
}
|
|
2896
|
+
return coll;
|
|
2897
|
+
}
|
|
2898
|
+
/**
|
|
2899
|
+
* Converts the category to a string representation.
|
|
2900
|
+
*
|
|
2901
|
+
* @returns {string} The name of the category.
|
|
2902
|
+
*/
|
|
2903
|
+
toString() {
|
|
2904
|
+
return this.name;
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
|
|
2908
|
+
// src/struct/emoji.ts
|
|
2909
|
+
var Emoji = class extends Base {
|
|
2910
|
+
/**
|
|
2911
|
+
* Creates a new Emoji instance.
|
|
2912
|
+
*
|
|
2913
|
+
* @param {client} client - The client instance.
|
|
2914
|
+
* @param {Emoji} data - The raw data for the emoji.
|
|
2915
|
+
*/
|
|
2916
|
+
constructor(client3, data) {
|
|
2917
|
+
super(client3);
|
|
2918
|
+
/** The parent object of the emoji, which can be a server or other entity. */
|
|
2919
|
+
this.parent = null;
|
|
2920
|
+
/** The ID of the user who created the emoji, or `null` if not available. */
|
|
2921
|
+
this.creator_id = null;
|
|
2922
|
+
/** The name of the emoji, or `null` if not set. */
|
|
2923
|
+
this.name = null;
|
|
2924
|
+
this._patch(data);
|
|
2925
|
+
}
|
|
2926
|
+
/**
|
|
2927
|
+
* Retrieves the user who created the emoji.
|
|
2928
|
+
*
|
|
2929
|
+
* @returns {User | null} The creator of the emoji, or `null` if not found.
|
|
2930
|
+
*/
|
|
2931
|
+
get creator() {
|
|
2932
|
+
var _a;
|
|
2933
|
+
return (_a = this.client.users.cache.get(this.creator_id)) != null ? _a : null;
|
|
2934
|
+
}
|
|
2935
|
+
/**
|
|
2936
|
+
* Retrieves the server associated with the emoji, if any.
|
|
2937
|
+
*
|
|
2938
|
+
* @returns {Server | null} The server instance, or `null` if the emoji is not associated with a server.
|
|
2939
|
+
*/
|
|
2940
|
+
get server() {
|
|
2941
|
+
var _a;
|
|
2942
|
+
if (!this.parent) return null;
|
|
2943
|
+
return (_a = this.client.servers.cache.get(this.parent.id)) != null ? _a : null;
|
|
2944
|
+
}
|
|
2945
|
+
};
|
|
2946
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2947
|
+
0 && (module.exports = {
|
|
2948
|
+
Attachment,
|
|
2949
|
+
Base,
|
|
2950
|
+
Category,
|
|
2951
|
+
Channel,
|
|
2952
|
+
DMChannel,
|
|
2953
|
+
Emoji,
|
|
2954
|
+
GroupChannel,
|
|
2955
|
+
Invite,
|
|
2956
|
+
Mentions,
|
|
2957
|
+
Message,
|
|
2958
|
+
MessageEmbed,
|
|
2959
|
+
NotesChannel,
|
|
2960
|
+
Presence,
|
|
2961
|
+
Role,
|
|
2962
|
+
Server,
|
|
2963
|
+
ServerChannel,
|
|
2964
|
+
ServerMember,
|
|
2965
|
+
Status,
|
|
2966
|
+
TextChannel,
|
|
2967
|
+
User,
|
|
2968
|
+
VoiceChannel
|
|
2969
|
+
});
|
|
2970
|
+
//# sourceMappingURL=index.cjs.map
|