hischool.js 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/lib/cjs/Client.d.ts +166 -0
- package/lib/cjs/Client.d.ts.map +1 -0
- package/lib/cjs/Client.js +221 -0
- package/lib/cjs/api/baseURL.d.ts +2 -0
- package/lib/cjs/api/baseURL.d.ts.map +1 -0
- package/lib/cjs/api/baseURL.js +5 -0
- package/lib/cjs/api/index.d.ts +177 -0
- package/lib/cjs/api/index.d.ts.map +1 -0
- package/lib/cjs/api/index.js +150 -0
- package/lib/cjs/api/params.d.ts +285 -0
- package/lib/cjs/api/params.d.ts.map +1 -0
- package/lib/cjs/api/params.js +194 -0
- package/lib/cjs/api/routes.d.ts +1089 -0
- package/lib/cjs/api/routes.d.ts.map +1 -0
- package/lib/cjs/api/routes.js +2 -0
- package/lib/cjs/api/schema.d.ts +4705 -0
- package/lib/cjs/api/schema.d.ts.map +1 -0
- package/lib/cjs/api/schema.js +2 -0
- package/lib/cjs/api/types.d.ts +131 -0
- package/lib/cjs/api/types.d.ts.map +1 -0
- package/lib/cjs/api/types.js +2 -0
- package/lib/cjs/classes/BannedUser.d.ts +18 -0
- package/lib/cjs/classes/BannedUser.d.ts.map +1 -0
- package/lib/cjs/classes/BannedUser.js +21 -0
- package/lib/cjs/classes/Bot.d.ts +82 -0
- package/lib/cjs/classes/Bot.d.ts.map +1 -0
- package/lib/cjs/classes/Bot.js +145 -0
- package/lib/cjs/classes/Channel.d.ts +465 -0
- package/lib/cjs/classes/Channel.d.ts.map +1 -0
- package/lib/cjs/classes/Channel.js +599 -0
- package/lib/cjs/classes/ChannelUnread.d.ts +27 -0
- package/lib/cjs/classes/ChannelUnread.d.ts.map +1 -0
- package/lib/cjs/classes/ChannelUnread.js +50 -0
- package/lib/cjs/classes/ChannelWebhook.d.ts +53 -0
- package/lib/cjs/classes/ChannelWebhook.d.ts.map +1 -0
- package/lib/cjs/classes/ChannelWebhook.js +113 -0
- package/lib/cjs/classes/Emoji.d.ts +57 -0
- package/lib/cjs/classes/Emoji.d.ts.map +1 -0
- package/lib/cjs/classes/Emoji.js +104 -0
- package/lib/cjs/classes/File.d.ts +67 -0
- package/lib/cjs/classes/File.d.ts.map +1 -0
- package/lib/cjs/classes/File.js +102 -0
- package/lib/cjs/classes/Invite.d.ts +60 -0
- package/lib/cjs/classes/Invite.d.ts.map +1 -0
- package/lib/cjs/classes/Invite.js +91 -0
- package/lib/cjs/classes/MFA.d.ts +83 -0
- package/lib/cjs/classes/MFA.d.ts.map +1 -0
- package/lib/cjs/classes/MFA.js +196 -0
- package/lib/cjs/classes/Message.d.ts +484 -0
- package/lib/cjs/classes/Message.d.ts.map +1 -0
- package/lib/cjs/classes/Message.js +341 -0
- package/lib/cjs/classes/MessageEmbed.d.ts +122 -0
- package/lib/cjs/classes/MessageEmbed.d.ts.map +1 -0
- package/lib/cjs/classes/MessageEmbed.js +181 -0
- package/lib/cjs/classes/PublicBot.d.ts +28 -0
- package/lib/cjs/classes/PublicBot.d.ts.map +1 -0
- package/lib/cjs/classes/PublicBot.js +60 -0
- package/lib/cjs/classes/PublicInvite.d.ts +57 -0
- package/lib/cjs/classes/PublicInvite.d.ts.map +1 -0
- package/lib/cjs/classes/PublicInvite.js +104 -0
- package/lib/cjs/classes/Server.d.ts +473 -0
- package/lib/cjs/classes/Server.d.ts.map +1 -0
- package/lib/cjs/classes/Server.js +585 -0
- package/lib/cjs/classes/ServerBan.d.ts +26 -0
- package/lib/cjs/classes/ServerBan.d.ts.map +1 -0
- package/lib/cjs/classes/ServerBan.js +44 -0
- package/lib/cjs/classes/ServerMember.d.ts +138 -0
- package/lib/cjs/classes/ServerMember.d.ts.map +1 -0
- package/lib/cjs/classes/ServerMember.js +234 -0
- package/lib/cjs/classes/Session.d.ts +45 -0
- package/lib/cjs/classes/Session.d.ts.map +1 -0
- package/lib/cjs/classes/Session.js +94 -0
- package/lib/cjs/classes/SystemMessage.d.ts +127 -0
- package/lib/cjs/classes/SystemMessage.d.ts.map +1 -0
- package/lib/cjs/classes/SystemMessage.js +172 -0
- package/lib/cjs/classes/User.d.ts +203 -0
- package/lib/cjs/classes/User.d.ts.map +1 -0
- package/lib/cjs/classes/User.js +299 -0
- package/lib/cjs/classes/UserProfile.d.ts +23 -0
- package/lib/cjs/classes/UserProfile.d.ts.map +1 -0
- package/lib/cjs/classes/UserProfile.js +35 -0
- package/lib/cjs/classes/index.d.ts +21 -0
- package/lib/cjs/classes/index.d.ts.map +1 -0
- package/lib/cjs/classes/index.js +36 -0
- package/lib/cjs/collections/AccountCollection.d.ts +91 -0
- package/lib/cjs/collections/AccountCollection.d.ts.map +1 -0
- package/lib/cjs/collections/AccountCollection.js +150 -0
- package/lib/cjs/collections/BotCollection.d.ts +39 -0
- package/lib/cjs/collections/BotCollection.d.ts.map +1 -0
- package/lib/cjs/collections/BotCollection.js +89 -0
- package/lib/cjs/collections/ChannelCollection.d.ts +39 -0
- package/lib/cjs/collections/ChannelCollection.d.ts.map +1 -0
- package/lib/cjs/collections/ChannelCollection.js +93 -0
- package/lib/cjs/collections/ChannelUnreadCollection.d.ts +24 -0
- package/lib/cjs/collections/ChannelUnreadCollection.d.ts.map +1 -0
- package/lib/cjs/collections/ChannelUnreadCollection.js +56 -0
- package/lib/cjs/collections/ChannelWebhookCollection.d.ts +29 -0
- package/lib/cjs/collections/ChannelWebhookCollection.d.ts.map +1 -0
- package/lib/cjs/collections/ChannelWebhookCollection.js +69 -0
- package/lib/cjs/collections/Collection.d.ts +153 -0
- package/lib/cjs/collections/Collection.d.ts.map +1 -0
- package/lib/cjs/collections/Collection.js +170 -0
- package/lib/cjs/collections/EmojiCollection.d.ts +27 -0
- package/lib/cjs/collections/EmojiCollection.d.ts.map +1 -0
- package/lib/cjs/collections/EmojiCollection.js +67 -0
- package/lib/cjs/collections/MessageCollection.d.ts +28 -0
- package/lib/cjs/collections/MessageCollection.d.ts.map +1 -0
- package/lib/cjs/collections/MessageCollection.js +69 -0
- package/lib/cjs/collections/ServerCollection.d.ts +36 -0
- package/lib/cjs/collections/ServerCollection.d.ts.map +1 -0
- package/lib/cjs/collections/ServerCollection.js +96 -0
- package/lib/cjs/collections/ServerMemberCollection.d.ts +45 -0
- package/lib/cjs/collections/ServerMemberCollection.d.ts.map +1 -0
- package/lib/cjs/collections/ServerMemberCollection.js +95 -0
- package/lib/cjs/collections/SessionCollection.d.ts +27 -0
- package/lib/cjs/collections/SessionCollection.d.ts.map +1 -0
- package/lib/cjs/collections/SessionCollection.js +63 -0
- package/lib/cjs/collections/UserCollection.d.ts +31 -0
- package/lib/cjs/collections/UserCollection.d.ts.map +1 -0
- package/lib/cjs/collections/UserCollection.js +81 -0
- package/lib/cjs/collections/index.d.ts +12 -0
- package/lib/cjs/collections/index.d.ts.map +1 -0
- package/lib/cjs/collections/index.js +38 -0
- package/lib/cjs/events/EventClient.d.ts +89 -0
- package/lib/cjs/events/EventClient.d.ts.map +1 -0
- package/lib/cjs/events/EventClient.js +186 -0
- package/lib/cjs/events/index.d.ts +18 -0
- package/lib/cjs/events/index.d.ts.map +1 -0
- package/lib/cjs/events/index.js +20 -0
- package/lib/cjs/events/v1.d.ts +214 -0
- package/lib/cjs/events/v1.d.ts.map +1 -0
- package/lib/cjs/events/v1.js +502 -0
- package/lib/cjs/hydration/bot.d.ts +21 -0
- package/lib/cjs/hydration/bot.d.ts.map +1 -0
- package/lib/cjs/hydration/bot.js +31 -0
- package/lib/cjs/hydration/channel.d.ts +25 -0
- package/lib/cjs/hydration/channel.d.ts.map +1 -0
- package/lib/cjs/hydration/channel.js +40 -0
- package/lib/cjs/hydration/channelUnread.d.ts +11 -0
- package/lib/cjs/hydration/channelUnread.d.ts.map +1 -0
- package/lib/cjs/hydration/channelUnread.js +19 -0
- package/lib/cjs/hydration/channelWebhook.d.ts +12 -0
- package/lib/cjs/hydration/channelWebhook.d.ts.map +1 -0
- package/lib/cjs/hydration/channelWebhook.js +21 -0
- package/lib/cjs/hydration/emoji.d.ts +13 -0
- package/lib/cjs/hydration/emoji.d.ts.map +1 -0
- package/lib/cjs/hydration/emoji.js +18 -0
- package/lib/cjs/hydration/index.d.ts +1404 -0
- package/lib/cjs/hydration/index.d.ts.map +1 -0
- package/lib/cjs/hydration/index.js +68 -0
- package/lib/cjs/hydration/message.d.ts +25 -0
- package/lib/cjs/hydration/message.d.ts.map +1 -0
- package/lib/cjs/hydration/message.js +48 -0
- package/lib/cjs/hydration/server.d.ts +31 -0
- package/lib/cjs/hydration/server.d.ts.map +1 -0
- package/lib/cjs/hydration/server.js +44 -0
- package/lib/cjs/hydration/serverMember.d.ts +14 -0
- package/lib/cjs/hydration/serverMember.d.ts.map +1 -0
- package/lib/cjs/hydration/serverMember.js +21 -0
- package/lib/cjs/hydration/session.d.ts +8 -0
- package/lib/cjs/hydration/session.d.ts.map +1 -0
- package/lib/cjs/hydration/session.js +13 -0
- package/lib/cjs/hydration/user.d.ts +43 -0
- package/lib/cjs/hydration/user.d.ts.map +1 -0
- package/lib/cjs/hydration/user.js +53 -0
- package/lib/cjs/index.d.ts +9 -0
- package/lib/cjs/index.d.ts.map +1 -0
- package/lib/cjs/index.js +43 -0
- package/lib/cjs/lib/merge.d.ts +15 -0
- package/lib/cjs/lib/merge.d.ts.map +1 -0
- package/lib/cjs/lib/merge.js +2 -0
- package/lib/cjs/lib/regex.d.ts +13 -0
- package/lib/cjs/lib/regex.d.ts.map +1 -0
- package/lib/cjs/lib/regex.js +15 -0
- package/lib/cjs/permissions/calculator.d.ts +19 -0
- package/lib/cjs/permissions/calculator.d.ts.map +1 -0
- package/lib/cjs/permissions/calculator.js +136 -0
- package/lib/cjs/permissions/definitions.d.ts +73 -0
- package/lib/cjs/permissions/definitions.d.ts.map +1 -0
- package/lib/cjs/permissions/definitions.js +124 -0
- package/lib/cjs/storage/ObjectStorage.d.ts +28 -0
- package/lib/cjs/storage/ObjectStorage.d.ts.map +1 -0
- package/lib/cjs/storage/ObjectStorage.js +41 -0
- package/lib/esm/Client.d.ts +166 -0
- package/lib/esm/Client.d.ts.map +1 -0
- package/lib/esm/Client.js +214 -0
- package/lib/esm/api/baseURL.d.ts +2 -0
- package/lib/esm/api/baseURL.d.ts.map +1 -0
- package/lib/esm/api/baseURL.js +2 -0
- package/lib/esm/api/index.d.ts +177 -0
- package/lib/esm/api/index.d.ts.map +1 -0
- package/lib/esm/api/index.js +139 -0
- package/lib/esm/api/params.d.ts +285 -0
- package/lib/esm/api/params.d.ts.map +1 -0
- package/lib/esm/api/params.js +191 -0
- package/lib/esm/api/routes.d.ts +1089 -0
- package/lib/esm/api/routes.d.ts.map +1 -0
- package/lib/esm/api/routes.js +1 -0
- package/lib/esm/api/schema.d.ts +4705 -0
- package/lib/esm/api/schema.d.ts.map +1 -0
- package/lib/esm/api/schema.js +1 -0
- package/lib/esm/api/types.d.ts +131 -0
- package/lib/esm/api/types.d.ts.map +1 -0
- package/lib/esm/api/types.js +1 -0
- package/lib/esm/classes/BannedUser.d.ts +18 -0
- package/lib/esm/classes/BannedUser.d.ts.map +1 -0
- package/lib/esm/classes/BannedUser.js +21 -0
- package/lib/esm/classes/Bot.d.ts +82 -0
- package/lib/esm/classes/Bot.d.ts.map +1 -0
- package/lib/esm/classes/Bot.js +116 -0
- package/lib/esm/classes/Channel.d.ts +465 -0
- package/lib/esm/classes/Channel.d.ts.map +1 -0
- package/lib/esm/classes/Channel.js +529 -0
- package/lib/esm/classes/ChannelUnread.d.ts +27 -0
- package/lib/esm/classes/ChannelUnread.d.ts.map +1 -0
- package/lib/esm/classes/ChannelUnread.js +34 -0
- package/lib/esm/classes/ChannelWebhook.d.ts +53 -0
- package/lib/esm/classes/ChannelWebhook.d.ts.map +1 -0
- package/lib/esm/classes/ChannelWebhook.js +83 -0
- package/lib/esm/classes/Emoji.d.ts +57 -0
- package/lib/esm/classes/Emoji.d.ts.map +1 -0
- package/lib/esm/classes/Emoji.js +77 -0
- package/lib/esm/classes/File.d.ts +67 -0
- package/lib/esm/classes/File.d.ts.map +1 -0
- package/lib/esm/classes/File.js +105 -0
- package/lib/esm/classes/Invite.d.ts +60 -0
- package/lib/esm/classes/Invite.d.ts.map +1 -0
- package/lib/esm/classes/Invite.js +80 -0
- package/lib/esm/classes/MFA.d.ts +83 -0
- package/lib/esm/classes/MFA.d.ts.map +1 -0
- package/lib/esm/classes/MFA.js +165 -0
- package/lib/esm/classes/Message.d.ts +484 -0
- package/lib/esm/classes/Message.d.ts.map +1 -0
- package/lib/esm/classes/Message.js +300 -0
- package/lib/esm/classes/MessageEmbed.d.ts +122 -0
- package/lib/esm/classes/MessageEmbed.d.ts.map +1 -0
- package/lib/esm/classes/MessageEmbed.js +192 -0
- package/lib/esm/classes/PublicBot.d.ts +28 -0
- package/lib/esm/classes/PublicBot.d.ts.map +1 -0
- package/lib/esm/classes/PublicBot.js +47 -0
- package/lib/esm/classes/PublicInvite.d.ts +57 -0
- package/lib/esm/classes/PublicInvite.d.ts.map +1 -0
- package/lib/esm/classes/PublicInvite.js +100 -0
- package/lib/esm/classes/Server.d.ts +473 -0
- package/lib/esm/classes/Server.d.ts.map +1 -0
- package/lib/esm/classes/Server.js +522 -0
- package/lib/esm/classes/ServerBan.d.ts +26 -0
- package/lib/esm/classes/ServerBan.d.ts.map +1 -0
- package/lib/esm/classes/ServerBan.js +33 -0
- package/lib/esm/classes/ServerMember.d.ts +138 -0
- package/lib/esm/classes/ServerMember.d.ts.map +1 -0
- package/lib/esm/classes/ServerMember.js +199 -0
- package/lib/esm/classes/Session.d.ts +45 -0
- package/lib/esm/classes/Session.d.ts.map +1 -0
- package/lib/esm/classes/Session.js +65 -0
- package/lib/esm/classes/SystemMessage.d.ts +127 -0
- package/lib/esm/classes/SystemMessage.d.ts.map +1 -0
- package/lib/esm/classes/SystemMessage.js +171 -0
- package/lib/esm/classes/User.d.ts +203 -0
- package/lib/esm/classes/User.d.ts.map +1 -0
- package/lib/esm/classes/User.js +252 -0
- package/lib/esm/classes/UserProfile.d.ts +23 -0
- package/lib/esm/classes/UserProfile.d.ts.map +1 -0
- package/lib/esm/classes/UserProfile.js +31 -0
- package/lib/esm/classes/index.d.ts +21 -0
- package/lib/esm/classes/index.d.ts.map +1 -0
- package/lib/esm/classes/index.js +20 -0
- package/lib/esm/collections/AccountCollection.d.ts +91 -0
- package/lib/esm/collections/AccountCollection.d.ts.map +1 -0
- package/lib/esm/collections/AccountCollection.js +139 -0
- package/lib/esm/collections/BotCollection.d.ts +39 -0
- package/lib/esm/collections/BotCollection.d.ts.map +1 -0
- package/lib/esm/collections/BotCollection.js +68 -0
- package/lib/esm/collections/ChannelCollection.d.ts +39 -0
- package/lib/esm/collections/ChannelCollection.d.ts.map +1 -0
- package/lib/esm/collections/ChannelCollection.js +75 -0
- package/lib/esm/collections/ChannelUnreadCollection.d.ts +24 -0
- package/lib/esm/collections/ChannelUnreadCollection.d.ts.map +1 -0
- package/lib/esm/collections/ChannelUnreadCollection.js +41 -0
- package/lib/esm/collections/ChannelWebhookCollection.d.ts +29 -0
- package/lib/esm/collections/ChannelWebhookCollection.d.ts.map +1 -0
- package/lib/esm/collections/ChannelWebhookCollection.js +52 -0
- package/lib/esm/collections/Collection.d.ts +153 -0
- package/lib/esm/collections/Collection.d.ts.map +1 -0
- package/lib/esm/collections/Collection.js +160 -0
- package/lib/esm/collections/EmojiCollection.d.ts +27 -0
- package/lib/esm/collections/EmojiCollection.d.ts.map +1 -0
- package/lib/esm/collections/EmojiCollection.js +52 -0
- package/lib/esm/collections/MessageCollection.d.ts +28 -0
- package/lib/esm/collections/MessageCollection.d.ts.map +1 -0
- package/lib/esm/collections/MessageCollection.js +54 -0
- package/lib/esm/collections/ServerCollection.d.ts +36 -0
- package/lib/esm/collections/ServerCollection.d.ts.map +1 -0
- package/lib/esm/collections/ServerCollection.js +79 -0
- package/lib/esm/collections/ServerMemberCollection.d.ts +45 -0
- package/lib/esm/collections/ServerMemberCollection.d.ts.map +1 -0
- package/lib/esm/collections/ServerMemberCollection.js +80 -0
- package/lib/esm/collections/SessionCollection.d.ts +27 -0
- package/lib/esm/collections/SessionCollection.d.ts.map +1 -0
- package/lib/esm/collections/SessionCollection.js +46 -0
- package/lib/esm/collections/UserCollection.d.ts +31 -0
- package/lib/esm/collections/UserCollection.d.ts.map +1 -0
- package/lib/esm/collections/UserCollection.js +66 -0
- package/lib/esm/collections/index.d.ts +12 -0
- package/lib/esm/collections/index.d.ts.map +1 -0
- package/lib/esm/collections/index.js +11 -0
- package/lib/esm/events/EventClient.d.ts +89 -0
- package/lib/esm/events/EventClient.d.ts.map +1 -0
- package/lib/esm/events/EventClient.js +175 -0
- package/lib/esm/events/index.d.ts +18 -0
- package/lib/esm/events/index.d.ts.map +1 -0
- package/lib/esm/events/index.js +2 -0
- package/lib/esm/events/v1.d.ts +214 -0
- package/lib/esm/events/v1.d.ts.map +1 -0
- package/lib/esm/events/v1.js +514 -0
- package/lib/esm/hydration/bot.d.ts +21 -0
- package/lib/esm/hydration/bot.d.ts.map +1 -0
- package/lib/esm/hydration/bot.js +28 -0
- package/lib/esm/hydration/channel.d.ts +25 -0
- package/lib/esm/hydration/channel.d.ts.map +1 -0
- package/lib/esm/hydration/channel.js +37 -0
- package/lib/esm/hydration/channelUnread.d.ts +11 -0
- package/lib/esm/hydration/channelUnread.d.ts.map +1 -0
- package/lib/esm/hydration/channelUnread.js +16 -0
- package/lib/esm/hydration/channelWebhook.d.ts +12 -0
- package/lib/esm/hydration/channelWebhook.d.ts.map +1 -0
- package/lib/esm/hydration/channelWebhook.js +18 -0
- package/lib/esm/hydration/emoji.d.ts +13 -0
- package/lib/esm/hydration/emoji.d.ts.map +1 -0
- package/lib/esm/hydration/emoji.js +15 -0
- package/lib/esm/hydration/index.d.ts +1404 -0
- package/lib/esm/hydration/index.d.ts.map +1 -0
- package/lib/esm/hydration/index.js +65 -0
- package/lib/esm/hydration/message.d.ts +25 -0
- package/lib/esm/hydration/message.d.ts.map +1 -0
- package/lib/esm/hydration/message.js +45 -0
- package/lib/esm/hydration/server.d.ts +31 -0
- package/lib/esm/hydration/server.d.ts.map +1 -0
- package/lib/esm/hydration/server.js +41 -0
- package/lib/esm/hydration/serverMember.d.ts +14 -0
- package/lib/esm/hydration/serverMember.d.ts.map +1 -0
- package/lib/esm/hydration/serverMember.js +18 -0
- package/lib/esm/hydration/session.d.ts +8 -0
- package/lib/esm/hydration/session.d.ts.map +1 -0
- package/lib/esm/hydration/session.js +10 -0
- package/lib/esm/hydration/user.d.ts +43 -0
- package/lib/esm/hydration/user.d.ts.map +1 -0
- package/lib/esm/hydration/user.js +50 -0
- package/lib/esm/index.d.ts +9 -0
- package/lib/esm/index.d.ts.map +1 -0
- package/lib/esm/index.js +8 -0
- package/lib/esm/lib/merge.d.ts +15 -0
- package/lib/esm/lib/merge.d.ts.map +1 -0
- package/lib/esm/lib/merge.js +1 -0
- package/lib/esm/lib/regex.d.ts +13 -0
- package/lib/esm/lib/regex.d.ts.map +1 -0
- package/lib/esm/lib/regex.js +12 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/permissions/calculator.d.ts +19 -0
- package/lib/esm/permissions/calculator.d.ts.map +1 -0
- package/lib/esm/permissions/calculator.js +129 -0
- package/lib/esm/permissions/definitions.d.ts +73 -0
- package/lib/esm/permissions/definitions.d.ts.map +1 -0
- package/lib/esm/permissions/definitions.js +121 -0
- package/lib/esm/storage/ObjectStorage.d.ts +28 -0
- package/lib/esm/storage/ObjectStorage.d.ts.map +1 -0
- package/lib/esm/storage/ObjectStorage.js +39 -0
- package/package.json +59 -0
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
import { bitwiseAndEq, calculatePermission, } from "../permissions/calculator.js";
|
|
2
|
+
import { Permission } from "../permissions/definitions.js";
|
|
3
|
+
import { batch } from "solid-js";
|
|
4
|
+
import { decodeTime, ulid } from "ulid";
|
|
5
|
+
/**
|
|
6
|
+
* Channel Class
|
|
7
|
+
*/
|
|
8
|
+
export class Channel {
|
|
9
|
+
#collection;
|
|
10
|
+
id;
|
|
11
|
+
/**
|
|
12
|
+
* Construct Channel
|
|
13
|
+
* @param collection Collection
|
|
14
|
+
* @param id Channel Id
|
|
15
|
+
*/
|
|
16
|
+
constructor(collection, id) {
|
|
17
|
+
this.#collection = collection;
|
|
18
|
+
this.id = id;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Write to string as a channel mention
|
|
22
|
+
* @returns Formatted String
|
|
23
|
+
*/
|
|
24
|
+
toString() {
|
|
25
|
+
return `<#${this.id}>`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether this object exists
|
|
29
|
+
*/
|
|
30
|
+
get $exists() {
|
|
31
|
+
return !!this.#collection.getUnderlyingObject(this.id).id;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Time when this server was created
|
|
35
|
+
*/
|
|
36
|
+
get createdAt() {
|
|
37
|
+
return new Date(decodeTime(this.id));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Channel type
|
|
41
|
+
*/
|
|
42
|
+
get type() {
|
|
43
|
+
return this.#collection.getUnderlyingObject(this.id).channelType;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Absolute pathname to this channel in the client
|
|
47
|
+
*/
|
|
48
|
+
get path() {
|
|
49
|
+
if (this.serverId) {
|
|
50
|
+
return `/server/${this.serverId}/channel/${this.id}`;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return `/channel/${this.id}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* URL to this channel
|
|
58
|
+
*/
|
|
59
|
+
get url() {
|
|
60
|
+
return this.#collection.client.configuration?.app + this.path;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Channel name
|
|
64
|
+
*/
|
|
65
|
+
get name() {
|
|
66
|
+
return this.#collection.getUnderlyingObject(this.id).name;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Display name
|
|
70
|
+
*/
|
|
71
|
+
get displayName() {
|
|
72
|
+
return this.type === "SavedMessages"
|
|
73
|
+
? this.user?.username
|
|
74
|
+
: this.type === "DirectMessage"
|
|
75
|
+
? this.recipient?.username
|
|
76
|
+
: this.name;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Channel description
|
|
80
|
+
*/
|
|
81
|
+
get description() {
|
|
82
|
+
return this.#collection.getUnderlyingObject(this.id).description;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Channel icon
|
|
86
|
+
*/
|
|
87
|
+
get icon() {
|
|
88
|
+
return this.#collection.getUnderlyingObject(this.id).icon;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Whether the conversation is active
|
|
92
|
+
*/
|
|
93
|
+
get active() {
|
|
94
|
+
return this.#collection.getUnderlyingObject(this.id).active;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* User ids of people currently typing in channel
|
|
98
|
+
*/
|
|
99
|
+
get typingIds() {
|
|
100
|
+
return this.#collection.getUnderlyingObject(this.id).typingIds;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Users currently trying in channel
|
|
104
|
+
*/
|
|
105
|
+
get typing() {
|
|
106
|
+
return [...this.typingIds.values()].map((id) => this.#collection.client.users.get(id));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* User ids of recipients of the group
|
|
110
|
+
*/
|
|
111
|
+
get recipientIds() {
|
|
112
|
+
return this.#collection.getUnderlyingObject(this.id).recipientIds;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Recipients of the group
|
|
116
|
+
*/
|
|
117
|
+
get recipients() {
|
|
118
|
+
return [
|
|
119
|
+
...this.#collection.getUnderlyingObject(this.id).recipientIds.values(),
|
|
120
|
+
].map((id) => this.#collection.client.users.get(id));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Find recipient of this DM
|
|
124
|
+
*/
|
|
125
|
+
get recipient() {
|
|
126
|
+
return this.type === "DirectMessage"
|
|
127
|
+
? this.recipients?.find((user) => user?.id !== this.#collection.client.user.id)
|
|
128
|
+
: undefined;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* User ID
|
|
132
|
+
*/
|
|
133
|
+
get userId() {
|
|
134
|
+
return this.#collection.getUnderlyingObject(this.id).userId;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* User this channel belongs to
|
|
138
|
+
*/
|
|
139
|
+
get user() {
|
|
140
|
+
return this.#collection.client.users.get(this.#collection.getUnderlyingObject(this.id).userId);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Owner ID
|
|
144
|
+
*/
|
|
145
|
+
get ownerId() {
|
|
146
|
+
return this.#collection.getUnderlyingObject(this.id).ownerId;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Owner of the group
|
|
150
|
+
*/
|
|
151
|
+
get owner() {
|
|
152
|
+
return this.#collection.client.users.get(this.#collection.getUnderlyingObject(this.id).ownerId);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Server ID
|
|
156
|
+
*/
|
|
157
|
+
get serverId() {
|
|
158
|
+
return this.#collection.getUnderlyingObject(this.id).serverId;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Server this channel is in
|
|
162
|
+
*/
|
|
163
|
+
get server() {
|
|
164
|
+
return this.#collection.client.servers.get(this.#collection.getUnderlyingObject(this.id).serverId);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Permissions allowed for users in this group
|
|
168
|
+
*/
|
|
169
|
+
get permissions() {
|
|
170
|
+
return this.#collection.getUnderlyingObject(this.id).permissions;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Default permissions for this server channel
|
|
174
|
+
*/
|
|
175
|
+
get defaultPermissions() {
|
|
176
|
+
return this.#collection.getUnderlyingObject(this.id).defaultPermissions;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Role permissions for this server channel
|
|
180
|
+
*/
|
|
181
|
+
get rolePermissions() {
|
|
182
|
+
return this.#collection.getUnderlyingObject(this.id).rolePermissions;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Whether this channel is marked as mature
|
|
186
|
+
*/
|
|
187
|
+
get mature() {
|
|
188
|
+
return this.#collection.getUnderlyingObject(this.id).nsfw;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* ID of the last message sent in this channel
|
|
192
|
+
*/
|
|
193
|
+
get lastMessageId() {
|
|
194
|
+
return this.#collection.getUnderlyingObject(this.id).lastMessageId;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Last message sent in this channel
|
|
198
|
+
*/
|
|
199
|
+
get lastMessage() {
|
|
200
|
+
return this.#collection.client.messages.get(this.lastMessageId);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Time when the last message was sent
|
|
204
|
+
*/
|
|
205
|
+
get lastMessageAt() {
|
|
206
|
+
return this.lastMessageId
|
|
207
|
+
? new Date(decodeTime(this.lastMessageId))
|
|
208
|
+
: undefined;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Time when the channel was last updated (either created or a message was sent)
|
|
212
|
+
*/
|
|
213
|
+
get updatedAt() {
|
|
214
|
+
return this.lastMessageAt ?? this.createdAt;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get whether this channel is unread.
|
|
218
|
+
*/
|
|
219
|
+
get unread() {
|
|
220
|
+
if (!this.lastMessageId ||
|
|
221
|
+
this.type === "SavedMessages" ||
|
|
222
|
+
this.type === "VoiceChannel" ||
|
|
223
|
+
this.#collection.client.options.channelIsMuted(this))
|
|
224
|
+
return false;
|
|
225
|
+
return ((this.#collection.client.channelUnreads.get(this.id)?.lastMessageId ??
|
|
226
|
+
"0").localeCompare(this.lastMessageId) === -1);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Get mentions in this channel for user.
|
|
230
|
+
*/
|
|
231
|
+
get mentions() {
|
|
232
|
+
if (this.type === "SavedMessages" || this.type === "VoiceChannel")
|
|
233
|
+
return undefined;
|
|
234
|
+
return this.#collection.client.channelUnreads.get(this.id)
|
|
235
|
+
?.messageMentionIds;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* URL to the channel icon
|
|
239
|
+
*/
|
|
240
|
+
get iconURL() {
|
|
241
|
+
return (this.icon?.createFileURL({ max_side: 256 }) ?? this.recipient?.avatarURL);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* URL to a small variant of the channel icon
|
|
245
|
+
*/
|
|
246
|
+
get smallIconURL() {
|
|
247
|
+
return this.icon?.createFileURL({ max_side: 64 });
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* URL to the animated channel icon
|
|
251
|
+
*/
|
|
252
|
+
get animatedIconURL() {
|
|
253
|
+
return (this.icon?.createFileURL({ max_side: 256 }, true) ??
|
|
254
|
+
this.recipient?.animatedAvatarURL);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Whether this channel may be hidden to some users
|
|
258
|
+
*/
|
|
259
|
+
get potentiallyRestrictedChannel() {
|
|
260
|
+
if (!this.serverId)
|
|
261
|
+
return false;
|
|
262
|
+
return (bitwiseAndEq(this.defaultPermissions?.d ?? 0, Permission.ViewChannel) ||
|
|
263
|
+
!bitwiseAndEq(this.server.defaultPermissions, Permission.ViewChannel) ||
|
|
264
|
+
[...(this.server?.roles.keys() ?? [])].find((role) => bitwiseAndEq(this.rolePermissions?.[role]?.d ?? 0, Permission.ViewChannel) ||
|
|
265
|
+
bitwiseAndEq(this.server?.roles.get(role)?.permissions.d ?? 0, Permission.ViewChannel)));
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Permission the currently authenticated user has against this channel
|
|
269
|
+
*/
|
|
270
|
+
get permission() {
|
|
271
|
+
return calculatePermission(this.#collection.client, this);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Check whether we have a given permission in a channel
|
|
275
|
+
* @param permission Permission Names
|
|
276
|
+
* @returns Whether we have this permission
|
|
277
|
+
*/
|
|
278
|
+
havePermission(...permission) {
|
|
279
|
+
return bitwiseAndEq(this.permission, ...permission.map((x) => Permission[x]));
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Check whether we have at least one of the given permissions in a channel
|
|
283
|
+
* @param permission Permission Names
|
|
284
|
+
* @returns Whether we have one of the permissions
|
|
285
|
+
*/
|
|
286
|
+
orPermission(...permission) {
|
|
287
|
+
return (permission.findIndex((x) => bitwiseAndEq(this.permission, Permission[x])) !== -1);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Fetch a channel's members.
|
|
291
|
+
* @requires `Group`
|
|
292
|
+
* @returns An array of the channel's members.
|
|
293
|
+
*/
|
|
294
|
+
async fetchMembers() {
|
|
295
|
+
const members = await this.#collection.client.api.get(`/channels/${this.id}/members`);
|
|
296
|
+
return batch(() => members.map((user) => this.#collection.client.users.getOrCreate(user._id, user)));
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Fetch a channel's webhooks
|
|
300
|
+
* @requires `TextChannel`, `Group`
|
|
301
|
+
* @returns Webhooks
|
|
302
|
+
*/
|
|
303
|
+
async fetchWebhooks() {
|
|
304
|
+
const webhooks = await this.#collection.client.api.get(`/channels/${this.id}/webhooks`);
|
|
305
|
+
return batch(() => webhooks.map((webhook) => this.#collection.client.channelWebhooks.getOrCreate(webhook.id, webhook)));
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Edit a channel
|
|
309
|
+
* @param data Changes
|
|
310
|
+
*/
|
|
311
|
+
async edit(data) {
|
|
312
|
+
await this.#collection.client.api.patch(`/channels/${this.id}`, data);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Delete or leave a channel
|
|
316
|
+
* @param leaveSilently Whether to not send a message on leave
|
|
317
|
+
* @requires `DirectMessage`, `Group`, `TextChannel`, `VoiceChannel`
|
|
318
|
+
*/
|
|
319
|
+
async delete(leaveSilently) {
|
|
320
|
+
await this.#collection.client.api.delete(`/channels/${this.id}`, {
|
|
321
|
+
leave_silently: leaveSilently,
|
|
322
|
+
});
|
|
323
|
+
if (this.type === "DirectMessage") {
|
|
324
|
+
this.#collection.updateUnderlyingObject(this.id, "active", false);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
this.#collection.delete(this.id);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Add a user to a group
|
|
331
|
+
* @param user_id ID of the target user
|
|
332
|
+
* @requires `Group`
|
|
333
|
+
*/
|
|
334
|
+
async addMember(user_id) {
|
|
335
|
+
return await this.#collection.client.api.put(`/channels/${this.id}/recipients/${user_id}`);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Remove a user from a group
|
|
339
|
+
* @param user_id ID of the target user
|
|
340
|
+
* @requires `Group`
|
|
341
|
+
*/
|
|
342
|
+
async removeMember(user_id) {
|
|
343
|
+
return await this.#collection.client.api.delete(`/channels/${this.id}/recipients/${user_id}`);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Send a message
|
|
347
|
+
* @param data Either the message as a string or message sending route data
|
|
348
|
+
* @requires `SavedMessages`, `DirectMessage`, `Group`, `TextChannel`
|
|
349
|
+
* @returns Sent message
|
|
350
|
+
*/
|
|
351
|
+
async sendMessage(data, idempotencyKey = ulid()) {
|
|
352
|
+
const msg = typeof data === "string" ? { content: data } : data;
|
|
353
|
+
// Mark as silent message
|
|
354
|
+
if (msg.content?.startsWith("@silent ")) {
|
|
355
|
+
msg.content = msg.content.substring(8);
|
|
356
|
+
msg.flags ||= 1;
|
|
357
|
+
msg.flags |= 1;
|
|
358
|
+
}
|
|
359
|
+
const message = await this.#collection.client.api.post(`/channels/${this.id}/messages`, msg, {
|
|
360
|
+
headers: {
|
|
361
|
+
"Idempotency-Key": idempotencyKey,
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
return this.#collection.client.messages.getOrCreate(message._id, message, true);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Fetch a message by its ID
|
|
368
|
+
* @param messageId ID of the target message
|
|
369
|
+
* @requires `SavedMessages`, `DirectMessage`, `Group`, `TextChannel`
|
|
370
|
+
* @returns Message
|
|
371
|
+
*/
|
|
372
|
+
async fetchMessage(messageId) {
|
|
373
|
+
const message = await this.#collection.client.api.get(`/channels/${this.id}/messages/${messageId}`);
|
|
374
|
+
return this.#collection.client.messages.getOrCreate(message._id, message);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Fetch multiple messages from a channel
|
|
378
|
+
* @param params Message fetching route data
|
|
379
|
+
* @requires `SavedMessages`, `DirectMessage`, `Group`, `TextChannel`
|
|
380
|
+
* @returns Messages
|
|
381
|
+
*/
|
|
382
|
+
async fetchMessages(params) {
|
|
383
|
+
const messages = (await this.#collection.client.api.get(`/channels/${this.id}/messages`, { ...params }));
|
|
384
|
+
return messages.map((message) => this.#collection.client.messages.getOrCreate(message._id, message));
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Fetch multiple messages from a channel including the users that sent them
|
|
388
|
+
* @param params Message fetching route data
|
|
389
|
+
* @requires `SavedMessages`, `DirectMessage`, `Group`, `TextChannel`
|
|
390
|
+
* @returns Object including messages and users
|
|
391
|
+
*/
|
|
392
|
+
async fetchMessagesWithUsers(params) {
|
|
393
|
+
const data = (await this.#collection.client.api.get(`/channels/${this.id}/messages`, { ...params, include_users: true }));
|
|
394
|
+
return batch(() => ({
|
|
395
|
+
messages: data.messages.map((message) => this.#collection.client.messages.getOrCreate(message._id, message)),
|
|
396
|
+
users: data.users.map((user) => this.#collection.client.users.getOrCreate(user._id, user)),
|
|
397
|
+
members: data.members?.map((member) => this.#collection.client.serverMembers.getOrCreate(member._id, member)),
|
|
398
|
+
}));
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Search for messages
|
|
402
|
+
* @param params Message searching route data
|
|
403
|
+
* @requires `SavedMessages`, `DirectMessage`, `Group`, `TextChannel`
|
|
404
|
+
* @returns Messages
|
|
405
|
+
*/
|
|
406
|
+
async search(params) {
|
|
407
|
+
const messages = (await this.#collection.client.api.post(`/channels/${this.id}/search`, params));
|
|
408
|
+
return batch(() => messages.map((message) => this.#collection.client.messages.getOrCreate(message._id, message)));
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Search for messages including the users that sent them
|
|
412
|
+
* @param params Message searching route data
|
|
413
|
+
* @requires `SavedMessages`, `DirectMessage`, `Group`, `TextChannel`
|
|
414
|
+
* @returns Object including messages and users
|
|
415
|
+
*/
|
|
416
|
+
async searchWithUsers(params) {
|
|
417
|
+
const data = (await this.#collection.client.api.post(`/channels/${this.id}/search`, {
|
|
418
|
+
...params,
|
|
419
|
+
include_users: true,
|
|
420
|
+
}));
|
|
421
|
+
return batch(() => ({
|
|
422
|
+
messages: data.messages.map((message) => this.#collection.client.messages.getOrCreate(message._id, message)),
|
|
423
|
+
users: data.users.map((user) => this.#collection.client.users.getOrCreate(user._id, user)),
|
|
424
|
+
members: data.members?.map((member) => this.#collection.client.serverMembers.getOrCreate(member._id, member)),
|
|
425
|
+
}));
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Delete many messages by their IDs
|
|
429
|
+
* @param ids List of message IDs
|
|
430
|
+
* @requires `SavedMessages`, `DirectMessage`, `Group`, `TextChannel`
|
|
431
|
+
*/
|
|
432
|
+
async deleteMessages(ids) {
|
|
433
|
+
await this.#collection.client.api.delete(`/channels/${this.id}/messages/bulk`, {
|
|
434
|
+
ids,
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Create an invite to the channel
|
|
439
|
+
* @requires `TextChannel`, `VoiceChannel`
|
|
440
|
+
* @returns Newly created invite code
|
|
441
|
+
*/
|
|
442
|
+
async createInvite() {
|
|
443
|
+
return await this.#collection.client.api.post(`/channels/${this.id}/invites`);
|
|
444
|
+
}
|
|
445
|
+
#ackTimeout;
|
|
446
|
+
#ackLimit;
|
|
447
|
+
#manuallyMarked;
|
|
448
|
+
/**
|
|
449
|
+
* Mark a channel as read
|
|
450
|
+
* @param message Last read message or its ID
|
|
451
|
+
* @param skipRateLimiter Whether to skip the internal rate limiter
|
|
452
|
+
* @param skipRequest For internal updates only
|
|
453
|
+
* @param skipNextMarking For internal usage only
|
|
454
|
+
* @requires `SavedMessages`, `DirectMessage`, `Group`, `TextChannel`
|
|
455
|
+
*/
|
|
456
|
+
async ack(message, skipRateLimiter, skipRequest, skipNextMarking) {
|
|
457
|
+
if (!message && this.#manuallyMarked) {
|
|
458
|
+
this.#manuallyMarked = false;
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
// Skip the next unread marking
|
|
462
|
+
else if (skipNextMarking) {
|
|
463
|
+
this.#manuallyMarked = true;
|
|
464
|
+
}
|
|
465
|
+
const lastMessageId = (typeof message === "string" ? message : message?.id) ??
|
|
466
|
+
this.lastMessageId ??
|
|
467
|
+
ulid();
|
|
468
|
+
const unreads = this.#collection.client.channelUnreads;
|
|
469
|
+
const channelUnread = unreads.get(this.id);
|
|
470
|
+
if (channelUnread) {
|
|
471
|
+
unreads.updateUnderlyingObject(this.id, {
|
|
472
|
+
lastMessageId,
|
|
473
|
+
});
|
|
474
|
+
if (channelUnread.messageMentionIds.size) {
|
|
475
|
+
channelUnread.messageMentionIds.clear();
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
// Skip request if not needed
|
|
479
|
+
if (skipRequest)
|
|
480
|
+
return;
|
|
481
|
+
/**
|
|
482
|
+
* Send the actual acknowledgement request
|
|
483
|
+
*/
|
|
484
|
+
const performAck = () => {
|
|
485
|
+
this.#ackLimit = undefined;
|
|
486
|
+
this.#collection.client.api.put(`/channels/${this.id}/ack/${lastMessageId}`);
|
|
487
|
+
};
|
|
488
|
+
if (skipRateLimiter)
|
|
489
|
+
return performAck();
|
|
490
|
+
clearTimeout(this.#ackTimeout);
|
|
491
|
+
if (this.#ackLimit && +new Date() > this.#ackLimit) {
|
|
492
|
+
performAck();
|
|
493
|
+
}
|
|
494
|
+
// We need to use setTimeout here for both Node.js and browser.
|
|
495
|
+
this.#ackTimeout = setTimeout(performAck, 5000);
|
|
496
|
+
if (!this.#ackLimit) {
|
|
497
|
+
this.#ackLimit = +new Date() + 15e3;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Set role permissions
|
|
502
|
+
* @param role_id Role Id, set to 'default' to affect all users
|
|
503
|
+
* @param permissions Permission value
|
|
504
|
+
* @requires `Group`, `TextChannel`, `VoiceChannel`
|
|
505
|
+
*/
|
|
506
|
+
async setPermissions(role_id = "default", permissions) {
|
|
507
|
+
return await this.#collection.client.api.put(`/channels/${this.id}/permissions/${role_id}`, { permissions });
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Start typing in this channel
|
|
511
|
+
* @requires `DirectMessage`, `Group`, `TextChannel`
|
|
512
|
+
*/
|
|
513
|
+
startTyping() {
|
|
514
|
+
this.#collection.client.events.send({
|
|
515
|
+
type: "BeginTyping",
|
|
516
|
+
channel: this.id,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Stop typing in this channel
|
|
521
|
+
* @requires `DirectMessage`, `Group`, `TextChannel`
|
|
522
|
+
*/
|
|
523
|
+
stopTyping() {
|
|
524
|
+
this.#collection.client.events.send({
|
|
525
|
+
type: "EndTyping",
|
|
526
|
+
channel: this.id,
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ChannelUnreadCollection } from "../collections/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Channel Unread Class
|
|
4
|
+
*/
|
|
5
|
+
export declare class ChannelUnread {
|
|
6
|
+
#private;
|
|
7
|
+
readonly id: string;
|
|
8
|
+
/**
|
|
9
|
+
* Construct Channel
|
|
10
|
+
* @param collection Collection
|
|
11
|
+
* @param id Channel Id
|
|
12
|
+
*/
|
|
13
|
+
constructor(collection: ChannelUnreadCollection, id: string);
|
|
14
|
+
/**
|
|
15
|
+
* Whether this object exists
|
|
16
|
+
*/
|
|
17
|
+
get $exists(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Last read message id
|
|
20
|
+
*/
|
|
21
|
+
get lastMessageId(): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* List of message IDs that we were mentioned in
|
|
24
|
+
*/
|
|
25
|
+
get messageMentionIds(): import("@solid-primitives/set").ReactiveSet<string>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=ChannelUnread.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChannelUnread.d.ts","sourceRoot":"","sources":["../../../src/classes/ChannelUnread.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE;;GAEG;AACH,qBAAa,aAAa;;IAExB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;gBACS,UAAU,EAAE,uBAAuB,EAAE,EAAE,EAAE,MAAM;IAK3D;;OAEG;IACH,IAAI,OAAO,YAEV;IAED;;OAEG;IACH,IAAI,aAAa,uBAEhB;IAED;;OAEG;IACH,IAAI,iBAAiB,wDAEpB;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel Unread Class
|
|
3
|
+
*/
|
|
4
|
+
export class ChannelUnread {
|
|
5
|
+
#collection;
|
|
6
|
+
id;
|
|
7
|
+
/**
|
|
8
|
+
* Construct Channel
|
|
9
|
+
* @param collection Collection
|
|
10
|
+
* @param id Channel Id
|
|
11
|
+
*/
|
|
12
|
+
constructor(collection, id) {
|
|
13
|
+
this.#collection = collection;
|
|
14
|
+
this.id = id;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Whether this object exists
|
|
18
|
+
*/
|
|
19
|
+
get $exists() {
|
|
20
|
+
return !!this.#collection.getUnderlyingObject(this.id).id;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Last read message id
|
|
24
|
+
*/
|
|
25
|
+
get lastMessageId() {
|
|
26
|
+
return this.#collection.getUnderlyingObject(this.id).lastMessageId;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* List of message IDs that we were mentioned in
|
|
30
|
+
*/
|
|
31
|
+
get messageMentionIds() {
|
|
32
|
+
return this.#collection.getUnderlyingObject(this.id).messageMentionIds;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ChannelWebhookCollection } from "../collections/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Channel Webhook Class
|
|
4
|
+
*/
|
|
5
|
+
export declare class ChannelWebhook {
|
|
6
|
+
#private;
|
|
7
|
+
readonly id: string;
|
|
8
|
+
/**
|
|
9
|
+
* Construct Channel Webhook
|
|
10
|
+
* @param collection Collection
|
|
11
|
+
* @param id Webhook
|
|
12
|
+
*/
|
|
13
|
+
constructor(collection: ChannelWebhookCollection, id: string);
|
|
14
|
+
/**
|
|
15
|
+
* Whether this object exists
|
|
16
|
+
*/
|
|
17
|
+
get $exists(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Webhook name
|
|
20
|
+
*/
|
|
21
|
+
get name(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Webhook avatar
|
|
24
|
+
*/
|
|
25
|
+
get avatar(): import("./File.js").File | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Webhook avatar URL
|
|
28
|
+
*/
|
|
29
|
+
get avatarURL(): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Channel ID this webhook belongs to
|
|
32
|
+
*/
|
|
33
|
+
get channelId(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Channel this webhook belongs to
|
|
36
|
+
*/
|
|
37
|
+
get channel(): import("./Channel.js").Channel | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Secret token for sending messages to this webhook
|
|
40
|
+
*/
|
|
41
|
+
get token(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Edit this webhook
|
|
44
|
+
* TODO: not in production
|
|
45
|
+
*/
|
|
46
|
+
edit(data: any): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Delete this webhook
|
|
49
|
+
* TODO: not in production
|
|
50
|
+
*/
|
|
51
|
+
delete(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=ChannelWebhook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChannelWebhook.d.ts","sourceRoot":"","sources":["../../../src/classes/ChannelWebhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAGnE;;GAEG;AACH,qBAAa,cAAc;;IAEzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;gBACS,UAAU,EAAE,wBAAwB,EAAE,EAAE,EAAE,MAAM;IAK5D;;OAEG;IACH,IAAI,OAAO,YAEV;IAED;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,MAAM,yCAET;IAED;;OAEG;IACH,IAAI,SAAS,uBAIZ;IAED;;OAEG;IACH,IAAI,SAAS,WAEZ;IAED;;OAEG;IACH,IAAI,OAAO,+CAIV;IAED;;OAEG;IACH,IAAI,KAAK,WAER;IAED;;;OAGG;IACG,IAAI,CAAC,IAAI,EAAE,GAAG;IAcpB;;;OAGG;IACG,MAAM;CAQb"}
|