discord.js-selfbots-v13 0.0.1-security → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of discord.js-selfbots-v13 might be problematic. Click here for more details.
- package/LICENSE +674 -0
- package/README.md +127 -5
- package/package.json +101 -6
- package/src/WebSocket.js +39 -0
- package/src/client/BaseClient.js +87 -0
- package/src/client/Client.js +1154 -0
- package/src/client/WebhookClient.js +61 -0
- package/src/client/actions/Action.js +115 -0
- package/src/client/actions/ActionsManager.js +72 -0
- package/src/client/actions/ApplicationCommandPermissionsUpdate.js +34 -0
- package/src/client/actions/AutoModerationActionExecution.js +26 -0
- package/src/client/actions/AutoModerationRuleCreate.js +27 -0
- package/src/client/actions/AutoModerationRuleDelete.js +31 -0
- package/src/client/actions/AutoModerationRuleUpdate.js +29 -0
- package/src/client/actions/ChannelCreate.js +23 -0
- package/src/client/actions/ChannelDelete.js +39 -0
- package/src/client/actions/ChannelUpdate.js +34 -0
- package/src/client/actions/GuildAuditLogEntryCreate.js +29 -0
- package/src/client/actions/GuildBanAdd.js +20 -0
- package/src/client/actions/GuildBanRemove.js +25 -0
- package/src/client/actions/GuildChannelsPositionUpdate.js +21 -0
- package/src/client/actions/GuildDelete.js +65 -0
- package/src/client/actions/GuildEmojiCreate.js +20 -0
- package/src/client/actions/GuildEmojiDelete.js +21 -0
- package/src/client/actions/GuildEmojiUpdate.js +20 -0
- package/src/client/actions/GuildEmojisUpdate.js +34 -0
- package/src/client/actions/GuildIntegrationsUpdate.js +19 -0
- package/src/client/actions/GuildMemberRemove.js +33 -0
- package/src/client/actions/GuildMemberUpdate.js +44 -0
- package/src/client/actions/GuildRoleCreate.js +25 -0
- package/src/client/actions/GuildRoleDelete.js +31 -0
- package/src/client/actions/GuildRoleUpdate.js +39 -0
- package/src/client/actions/GuildRolesPositionUpdate.js +21 -0
- package/src/client/actions/GuildScheduledEventCreate.js +27 -0
- package/src/client/actions/GuildScheduledEventDelete.js +31 -0
- package/src/client/actions/GuildScheduledEventUpdate.js +30 -0
- package/src/client/actions/GuildScheduledEventUserAdd.js +32 -0
- package/src/client/actions/GuildScheduledEventUserRemove.js +32 -0
- package/src/client/actions/GuildStickerCreate.js +20 -0
- package/src/client/actions/GuildStickerDelete.js +21 -0
- package/src/client/actions/GuildStickerUpdate.js +20 -0
- package/src/client/actions/GuildStickersUpdate.js +34 -0
- package/src/client/actions/GuildUpdate.js +33 -0
- package/src/client/actions/InteractionCreate.js +115 -0
- package/src/client/actions/InviteCreate.js +28 -0
- package/src/client/actions/InviteDelete.js +30 -0
- package/src/client/actions/MessageCreate.js +50 -0
- package/src/client/actions/MessageDelete.js +32 -0
- package/src/client/actions/MessageDeleteBulk.js +46 -0
- package/src/client/actions/MessageReactionAdd.js +56 -0
- package/src/client/actions/MessageReactionRemove.js +45 -0
- package/src/client/actions/MessageReactionRemoveAll.js +33 -0
- package/src/client/actions/MessageReactionRemoveEmoji.js +28 -0
- package/src/client/actions/MessageUpdate.js +26 -0
- package/src/client/actions/PresenceUpdate.js +45 -0
- package/src/client/actions/StageInstanceCreate.js +28 -0
- package/src/client/actions/StageInstanceDelete.js +33 -0
- package/src/client/actions/StageInstanceUpdate.js +30 -0
- package/src/client/actions/ThreadCreate.js +24 -0
- package/src/client/actions/ThreadDelete.js +32 -0
- package/src/client/actions/ThreadListSync.js +59 -0
- package/src/client/actions/ThreadMemberUpdate.js +30 -0
- package/src/client/actions/ThreadMembersUpdate.js +34 -0
- package/src/client/actions/TypingStart.js +29 -0
- package/src/client/actions/UserUpdate.js +35 -0
- package/src/client/actions/VoiceStateUpdate.js +57 -0
- package/src/client/actions/WebhooksUpdate.js +20 -0
- package/src/client/voice/ClientVoiceManager.js +51 -0
- package/src/client/websocket/WebSocketManager.js +412 -0
- package/src/client/websocket/WebSocketShard.js +908 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +23 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_CREATE.js +18 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_DELETE.js +20 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_UPDATE.js +20 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.js +5 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/CALL_CREATE.js +14 -0
- package/src/client/websocket/handlers/CALL_DELETE.js +11 -0
- package/src/client/websocket/handlers/CALL_UPDATE.js +11 -0
- package/src/client/websocket/handlers/CHANNEL_CREATE.js +5 -0
- package/src/client/websocket/handlers/CHANNEL_DELETE.js +5 -0
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +22 -0
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +16 -0
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +16 -0
- package/src/client/websocket/handlers/CHANNEL_UPDATE.js +16 -0
- package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +11 -0
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_BAN_ADD.js +5 -0
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_CREATE.js +46 -0
- package/src/client/websocket/handlers/GUILD_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +39 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +20 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +55 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.js +5 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.js +5 -0
- package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/GUILD_UPDATE.js +5 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.js +16 -0
- package/src/client/websocket/handlers/INTERACTION_FAILURE.js +18 -0
- package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +11 -0
- package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +30 -0
- package/src/client/websocket/handlers/INVITE_CREATE.js +5 -0
- package/src/client/websocket/handlers/INVITE_DELETE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_ACK.js +16 -0
- package/src/client/websocket/handlers/MESSAGE_CREATE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.js +5 -0
- package/src/client/websocket/handlers/MESSAGE_UPDATE.js +16 -0
- package/src/client/websocket/handlers/PRESENCE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/READY.js +172 -0
- package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +17 -0
- package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +15 -0
- package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +18 -0
- package/src/client/websocket/handlers/RESUMED.js +14 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.js +5 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.js +5 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_CREATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_DELETE.js +5 -0
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.js +5 -0
- package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/THREAD_UPDATE.js +16 -0
- package/src/client/websocket/handlers/TYPING_START.js +5 -0
- package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +12 -0
- package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +9 -0
- package/src/client/websocket/handlers/USER_UPDATE.js +5 -0
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js +6 -0
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.js +5 -0
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.js +5 -0
- package/src/client/websocket/handlers/index.js +86 -0
- package/src/errors/DJSError.js +61 -0
- package/src/errors/Messages.js +227 -0
- package/src/errors/index.js +4 -0
- package/src/index.js +190 -0
- package/src/main.js +1 -0
- package/src/managers/ApplicationCommandManager.js +267 -0
- package/src/managers/ApplicationCommandPermissionsManager.js +425 -0
- package/src/managers/AutoModerationRuleManager.js +296 -0
- package/src/managers/BaseGuildEmojiManager.js +80 -0
- package/src/managers/BaseManager.js +19 -0
- package/src/managers/BillingManager.js +66 -0
- package/src/managers/CachedManager.js +71 -0
- package/src/managers/ChannelManager.js +139 -0
- package/src/managers/ClientUserSettingManager.js +490 -0
- package/src/managers/DataManager.js +61 -0
- package/src/managers/DeveloperPortalManager.js +104 -0
- package/src/managers/GuildApplicationCommandManager.js +28 -0
- package/src/managers/GuildBanManager.js +204 -0
- package/src/managers/GuildChannelManager.js +502 -0
- package/src/managers/GuildEmojiManager.js +171 -0
- package/src/managers/GuildEmojiRoleManager.js +118 -0
- package/src/managers/GuildFolderManager.js +24 -0
- package/src/managers/GuildForumThreadManager.js +114 -0
- package/src/managers/GuildInviteManager.js +213 -0
- package/src/managers/GuildManager.js +304 -0
- package/src/managers/GuildMemberManager.js +724 -0
- package/src/managers/GuildMemberRoleManager.js +191 -0
- package/src/managers/GuildScheduledEventManager.js +296 -0
- package/src/managers/GuildSettingManager.js +148 -0
- package/src/managers/GuildStickerManager.js +179 -0
- package/src/managers/GuildTextThreadManager.js +98 -0
- package/src/managers/InteractionManager.js +39 -0
- package/src/managers/MessageManager.js +393 -0
- package/src/managers/PermissionOverwriteManager.js +166 -0
- package/src/managers/PresenceManager.js +58 -0
- package/src/managers/ReactionManager.js +67 -0
- package/src/managers/ReactionUserManager.js +71 -0
- package/src/managers/RelationshipManager.js +258 -0
- package/src/managers/RoleManager.js +352 -0
- package/src/managers/SessionManager.js +57 -0
- package/src/managers/StageInstanceManager.js +162 -0
- package/src/managers/ThreadManager.js +207 -0
- package/src/managers/ThreadMemberManager.js +186 -0
- package/src/managers/UserManager.js +150 -0
- package/src/managers/VoiceStateManager.js +37 -0
- package/src/rest/APIRequest.js +136 -0
- package/src/rest/APIRouter.js +53 -0
- package/src/rest/CaptchaSolver.js +78 -0
- package/src/rest/DiscordAPIError.js +103 -0
- package/src/rest/HTTPError.js +62 -0
- package/src/rest/RESTManager.js +81 -0
- package/src/rest/RateLimitError.js +55 -0
- package/src/rest/RequestHandler.js +446 -0
- package/src/sharding/Shard.js +443 -0
- package/src/sharding/ShardClientUtil.js +275 -0
- package/src/sharding/ShardingManager.js +318 -0
- package/src/structures/AnonymousGuild.js +98 -0
- package/src/structures/ApplicationCommand.js +1028 -0
- package/src/structures/ApplicationRoleConnectionMetadata.js +45 -0
- package/src/structures/AutoModerationActionExecution.js +89 -0
- package/src/structures/AutoModerationRule.js +294 -0
- package/src/structures/AutocompleteInteraction.js +106 -0
- package/src/structures/Base.js +43 -0
- package/src/structures/BaseCommandInteraction.js +211 -0
- package/src/structures/BaseGuild.js +116 -0
- package/src/structures/BaseGuildEmoji.js +56 -0
- package/src/structures/BaseGuildTextChannel.js +193 -0
- package/src/structures/BaseGuildVoiceChannel.js +243 -0
- package/src/structures/BaseMessageComponent.js +114 -0
- package/src/structures/ButtonInteraction.js +11 -0
- package/src/structures/Call.js +58 -0
- package/src/structures/CategoryChannel.js +83 -0
- package/src/structures/Channel.js +271 -0
- package/src/structures/ClientApplication.js +204 -0
- package/src/structures/ClientPresence.js +84 -0
- package/src/structures/ClientUser.js +624 -0
- package/src/structures/CommandInteraction.js +41 -0
- package/src/structures/CommandInteractionOptionResolver.js +276 -0
- package/src/structures/ContextMenuInteraction.js +65 -0
- package/src/structures/DMChannel.js +280 -0
- package/src/structures/DeveloperPortalApplication.js +520 -0
- package/src/structures/DirectoryChannel.js +20 -0
- package/src/structures/Emoji.js +148 -0
- package/src/structures/ForumChannel.js +271 -0
- package/src/structures/Guild.js +1744 -0
- package/src/structures/GuildAuditLogs.js +734 -0
- package/src/structures/GuildBan.js +59 -0
- package/src/structures/GuildBoost.js +108 -0
- package/src/structures/GuildChannel.js +454 -0
- package/src/structures/GuildEmoji.js +161 -0
- package/src/structures/GuildFolder.js +75 -0
- package/src/structures/GuildMember.js +686 -0
- package/src/structures/GuildPreview.js +191 -0
- package/src/structures/GuildPreviewEmoji.js +27 -0
- package/src/structures/GuildScheduledEvent.js +441 -0
- package/src/structures/GuildTemplate.js +236 -0
- package/src/structures/Integration.js +188 -0
- package/src/structures/IntegrationApplication.js +96 -0
- package/src/structures/Interaction.js +351 -0
- package/src/structures/InteractionCollector.js +248 -0
- package/src/structures/InteractionResponse.js +114 -0
- package/src/structures/InteractionWebhook.js +43 -0
- package/src/structures/Invite.js +375 -0
- package/src/structures/InviteGuild.js +23 -0
- package/src/structures/InviteStageInstance.js +86 -0
- package/src/structures/Message.js +1188 -0
- package/src/structures/MessageActionRow.js +103 -0
- package/src/structures/MessageAttachment.js +193 -0
- package/src/structures/MessageButton.js +231 -0
- package/src/structures/MessageCollector.js +146 -0
- package/src/structures/MessageComponentInteraction.js +120 -0
- package/src/structures/MessageContextMenuInteraction.js +20 -0
- package/src/structures/MessageEmbed.js +586 -0
- package/src/structures/MessageMentions.js +272 -0
- package/src/structures/MessagePayload.js +358 -0
- package/src/structures/MessageReaction.js +171 -0
- package/src/structures/MessageSelectMenu.js +391 -0
- package/src/structures/Modal.js +279 -0
- package/src/structures/ModalSubmitFieldsResolver.js +53 -0
- package/src/structures/ModalSubmitInteraction.js +119 -0
- package/src/structures/NewsChannel.js +32 -0
- package/src/structures/OAuth2Guild.js +28 -0
- package/src/structures/PartialGroupDMChannel.js +430 -0
- package/src/structures/PermissionOverwrites.js +196 -0
- package/src/structures/Presence.js +441 -0
- package/src/structures/ReactionCollector.js +229 -0
- package/src/structures/ReactionEmoji.js +31 -0
- package/src/structures/RichPresence.js +722 -0
- package/src/structures/Role.js +515 -0
- package/src/structures/SelectMenuInteraction.js +170 -0
- package/src/structures/Session.js +81 -0
- package/src/structures/StageChannel.js +104 -0
- package/src/structures/StageInstance.js +208 -0
- package/src/structures/Sticker.js +310 -0
- package/src/structures/StickerPack.js +95 -0
- package/src/structures/StoreChannel.js +56 -0
- package/src/structures/Team.js +167 -0
- package/src/structures/TeamMember.js +71 -0
- package/src/structures/TextChannel.js +33 -0
- package/src/structures/TextInputComponent.js +201 -0
- package/src/structures/ThreadChannel.js +626 -0
- package/src/structures/ThreadMember.js +105 -0
- package/src/structures/Typing.js +74 -0
- package/src/structures/User.js +697 -0
- package/src/structures/UserContextMenuInteraction.js +29 -0
- package/src/structures/VoiceChannel.js +110 -0
- package/src/structures/VoiceRegion.js +53 -0
- package/src/structures/VoiceState.js +306 -0
- package/src/structures/WebEmbed.js +401 -0
- package/src/structures/Webhook.js +461 -0
- package/src/structures/WelcomeChannel.js +60 -0
- package/src/structures/WelcomeScreen.js +48 -0
- package/src/structures/Widget.js +87 -0
- package/src/structures/WidgetMember.js +99 -0
- package/src/structures/interfaces/Application.js +190 -0
- package/src/structures/interfaces/Collector.js +300 -0
- package/src/structures/interfaces/InteractionResponses.js +313 -0
- package/src/structures/interfaces/TextBasedChannel.js +566 -0
- package/src/util/ActivityFlags.js +44 -0
- package/src/util/ApplicationFlags.js +74 -0
- package/src/util/BitField.js +170 -0
- package/src/util/ChannelFlags.js +45 -0
- package/src/util/Constants.js +1917 -0
- package/src/util/DataResolver.js +145 -0
- package/src/util/Formatters.js +214 -0
- package/src/util/GuildMemberFlags.js +43 -0
- package/src/util/Intents.js +74 -0
- package/src/util/LimitedCollection.js +131 -0
- package/src/util/MessageFlags.js +54 -0
- package/src/util/Options.js +360 -0
- package/src/util/Permissions.js +187 -0
- package/src/util/PremiumUsageFlags.js +31 -0
- package/src/util/PurchasedFlags.js +31 -0
- package/src/util/RemoteAuth.js +522 -0
- package/src/util/SnowflakeUtil.js +92 -0
- package/src/util/Sweepers.js +466 -0
- package/src/util/SystemChannelFlags.js +55 -0
- package/src/util/ThreadMemberFlags.js +30 -0
- package/src/util/UserFlags.js +104 -0
- package/src/util/Util.js +741 -0
- package/src/util/Voice.js +1456 -0
- package/src/util/arRPC/index.js +229 -0
- package/src/util/arRPC/process/detectable.json +1 -0
- package/src/util/arRPC/process/index.js +102 -0
- package/src/util/arRPC/process/native/index.js +5 -0
- package/src/util/arRPC/process/native/linux.js +37 -0
- package/src/util/arRPC/process/native/win32.js +25 -0
- package/src/util/arRPC/transports/ipc.js +281 -0
- package/src/util/arRPC/transports/websocket.js +128 -0
- package/typings/enums.d.ts +346 -0
- package/typings/index.d.ts +7725 -0
- package/typings/index.test-d.ts +0 -0
- package/typings/rawDataTypes.d.ts +283 -0
@@ -0,0 +1,626 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const { Channel } = require('./Channel');
|
4
|
+
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
5
|
+
const { RangeError } = require('../errors');
|
6
|
+
const InteractionManager = require('../managers/InteractionManager');
|
7
|
+
const MessageManager = require('../managers/MessageManager');
|
8
|
+
const ThreadMemberManager = require('../managers/ThreadMemberManager');
|
9
|
+
const ChannelFlags = require('../util/ChannelFlags');
|
10
|
+
const Permissions = require('../util/Permissions');
|
11
|
+
const { resolveAutoArchiveMaxLimit } = require('../util/Util');
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Represents a thread channel on Discord.
|
15
|
+
* @extends {Channel}
|
16
|
+
* @implements {TextBasedChannel}
|
17
|
+
*/
|
18
|
+
class ThreadChannel extends Channel {
|
19
|
+
constructor(guild, data, client) {
|
20
|
+
super(guild?.client ?? client, data, false);
|
21
|
+
|
22
|
+
/**
|
23
|
+
* The guild the thread is in
|
24
|
+
* @type {Guild}
|
25
|
+
*/
|
26
|
+
this.guild = guild;
|
27
|
+
|
28
|
+
/**
|
29
|
+
* The id of the guild the channel is in
|
30
|
+
* @type {Snowflake}
|
31
|
+
*/
|
32
|
+
this.guildId = guild?.id ?? data.guild_id;
|
33
|
+
|
34
|
+
/**
|
35
|
+
* A manager of the messages sent to this thread
|
36
|
+
* @type {MessageManager}
|
37
|
+
*/
|
38
|
+
this.messages = new MessageManager(this);
|
39
|
+
|
40
|
+
/**
|
41
|
+
* A manager of the members that are part of this thread
|
42
|
+
* @type {ThreadMemberManager}
|
43
|
+
*/
|
44
|
+
this.members = new ThreadMemberManager(this);
|
45
|
+
|
46
|
+
/**
|
47
|
+
* A manager of the interactions sent to this channel
|
48
|
+
* @type {InteractionManager}
|
49
|
+
*/
|
50
|
+
this.interactions = new InteractionManager(this);
|
51
|
+
if (data) this._patch(data);
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* First message in the thread
|
56
|
+
* @type {?Message}
|
57
|
+
* @readonly
|
58
|
+
*/
|
59
|
+
get firstMessage() {
|
60
|
+
return this.messages.cache.get(this.id);
|
61
|
+
}
|
62
|
+
|
63
|
+
_patch(data, partial = false) {
|
64
|
+
super._patch(data);
|
65
|
+
|
66
|
+
if ('name' in data) {
|
67
|
+
/**
|
68
|
+
* The name of the thread
|
69
|
+
* @type {string}
|
70
|
+
*/
|
71
|
+
this.name = data.name;
|
72
|
+
}
|
73
|
+
|
74
|
+
if ('guild_id' in data) {
|
75
|
+
this.guildId = data.guild_id;
|
76
|
+
}
|
77
|
+
|
78
|
+
if ('parent_id' in data) {
|
79
|
+
/**
|
80
|
+
* The id of the parent channel of this thread
|
81
|
+
* @type {?Snowflake}
|
82
|
+
*/
|
83
|
+
this.parentId = data.parent_id;
|
84
|
+
} else {
|
85
|
+
this.parentId ??= null;
|
86
|
+
}
|
87
|
+
|
88
|
+
if ('thread_metadata' in data) {
|
89
|
+
/**
|
90
|
+
* Whether the thread is locked
|
91
|
+
* @type {?boolean}
|
92
|
+
*/
|
93
|
+
this.locked = data.thread_metadata.locked ?? false;
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Whether members without `MANAGE_THREADS` can invite other members without `MANAGE_THREADS`
|
97
|
+
* <info>Always `null` in public threads</info>
|
98
|
+
* @type {?boolean}
|
99
|
+
*/
|
100
|
+
this.invitable = this.type === 'GUILD_PRIVATE_THREAD' ? data.thread_metadata.invitable ?? false : null;
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Whether the thread is archived
|
104
|
+
* @type {?boolean}
|
105
|
+
*/
|
106
|
+
this.archived = data.thread_metadata.archived;
|
107
|
+
|
108
|
+
/**
|
109
|
+
* The amount of time (in minutes) after which the thread will automatically archive in case of no recent activity
|
110
|
+
* @type {?number}
|
111
|
+
*/
|
112
|
+
this.autoArchiveDuration = data.thread_metadata.auto_archive_duration;
|
113
|
+
|
114
|
+
/**
|
115
|
+
* The timestamp when the thread's archive status was last changed
|
116
|
+
* <info>If the thread was never archived or unarchived, this is the timestamp at which the thread was
|
117
|
+
* created</info>
|
118
|
+
* @type {?number}
|
119
|
+
*/
|
120
|
+
this.archiveTimestamp = new Date(data.thread_metadata.archive_timestamp).getTime();
|
121
|
+
|
122
|
+
if ('create_timestamp' in data.thread_metadata) {
|
123
|
+
// Note: this is needed because we can't assign directly to getters
|
124
|
+
this._createdTimestamp = Date.parse(data.thread_metadata.create_timestamp);
|
125
|
+
}
|
126
|
+
} else {
|
127
|
+
this.locked ??= null;
|
128
|
+
this.archived ??= null;
|
129
|
+
this.autoArchiveDuration ??= null;
|
130
|
+
this.archiveTimestamp ??= null;
|
131
|
+
this.invitable ??= null;
|
132
|
+
}
|
133
|
+
|
134
|
+
this._createdTimestamp ??= this.type === 'GUILD_PRIVATE_THREAD' ? super.createdTimestamp : null;
|
135
|
+
|
136
|
+
if ('owner_id' in data) {
|
137
|
+
/**
|
138
|
+
* The id of the member who created this thread
|
139
|
+
* @type {?Snowflake}
|
140
|
+
*/
|
141
|
+
this.ownerId = data.owner_id;
|
142
|
+
} else {
|
143
|
+
this.ownerId ??= null;
|
144
|
+
}
|
145
|
+
|
146
|
+
if ('last_message_id' in data) {
|
147
|
+
/**
|
148
|
+
* The last message id sent in this thread, if one was sent
|
149
|
+
* @type {?Snowflake}
|
150
|
+
*/
|
151
|
+
this.lastMessageId = data.last_message_id;
|
152
|
+
} else {
|
153
|
+
this.lastMessageId ??= null;
|
154
|
+
}
|
155
|
+
|
156
|
+
if ('last_pin_timestamp' in data) {
|
157
|
+
/**
|
158
|
+
* The timestamp when the last pinned message was pinned, if there was one
|
159
|
+
* @type {?number}
|
160
|
+
*/
|
161
|
+
this.lastPinTimestamp = data.last_pin_timestamp ? new Date(data.last_pin_timestamp).getTime() : null;
|
162
|
+
} else {
|
163
|
+
this.lastPinTimestamp ??= null;
|
164
|
+
}
|
165
|
+
|
166
|
+
if ('rate_limit_per_user' in data || !partial) {
|
167
|
+
/**
|
168
|
+
* The rate limit per user (slowmode) for this thread in seconds
|
169
|
+
* @type {?number}
|
170
|
+
*/
|
171
|
+
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
172
|
+
} else {
|
173
|
+
this.rateLimitPerUser ??= null;
|
174
|
+
}
|
175
|
+
|
176
|
+
if ('message_count' in data) {
|
177
|
+
/**
|
178
|
+
* <info>Threads created before July 1, 2022 may have an inaccurate count.
|
179
|
+
* If you need an approximate value higher than that, use `ThreadChannel#messages.cache.size`</info>
|
180
|
+
* @type {?number}
|
181
|
+
*/
|
182
|
+
this.messageCount = data.message_count;
|
183
|
+
} else {
|
184
|
+
this.messageCount ??= null;
|
185
|
+
}
|
186
|
+
|
187
|
+
if ('member_count' in data) {
|
188
|
+
/**
|
189
|
+
* The approximate count of users in this thread
|
190
|
+
* <info>This stops counting at 50. If you need an approximate value higher than that, use
|
191
|
+
* `ThreadChannel#members.cache.size`</info>
|
192
|
+
* @type {?number}
|
193
|
+
*/
|
194
|
+
this.memberCount = data.member_count;
|
195
|
+
} else {
|
196
|
+
this.memberCount ??= null;
|
197
|
+
}
|
198
|
+
|
199
|
+
if ('total_message_sent' in data) {
|
200
|
+
/**
|
201
|
+
* The number of messages ever sent in a thread, similar to {@link ThreadChannel#messageCount} except it
|
202
|
+
* will not decrement whenever a message is deleted
|
203
|
+
* @type {?number}
|
204
|
+
*/
|
205
|
+
this.totalMessageSent = data.total_message_sent;
|
206
|
+
} else {
|
207
|
+
this.totalMessageSent ??= null;
|
208
|
+
}
|
209
|
+
|
210
|
+
if ('applied_tags' in data) {
|
211
|
+
/**
|
212
|
+
* The tags applied to this thread
|
213
|
+
* @type {Snowflake[]}
|
214
|
+
*/
|
215
|
+
this.appliedTags = data.applied_tags;
|
216
|
+
} else {
|
217
|
+
this.appliedTags ??= [];
|
218
|
+
}
|
219
|
+
|
220
|
+
if (data.member && this.client.user) this.members._add({ user_id: this.client.user.id, ...data.member });
|
221
|
+
if (data.messages) for (const message of data.messages) this.messages._add(message);
|
222
|
+
}
|
223
|
+
|
224
|
+
/**
|
225
|
+
* The timestamp when this thread was created. This isn't available for threads
|
226
|
+
* created before 2022-01-09
|
227
|
+
* @type {?number}
|
228
|
+
* @readonly
|
229
|
+
*/
|
230
|
+
get createdTimestamp() {
|
231
|
+
return this._createdTimestamp;
|
232
|
+
}
|
233
|
+
|
234
|
+
/**
|
235
|
+
* A collection of associated guild member objects of this thread's members
|
236
|
+
* @type {Collection<Snowflake, GuildMember>}
|
237
|
+
* @readonly
|
238
|
+
*/
|
239
|
+
get guildMembers() {
|
240
|
+
return this.members.cache.mapValues(member => member.guildMember);
|
241
|
+
}
|
242
|
+
|
243
|
+
/**
|
244
|
+
* The time at which this thread's archive status was last changed
|
245
|
+
* <info>If the thread was never archived or unarchived, this is the time at which the thread was created</info>
|
246
|
+
* @type {?Date}
|
247
|
+
* @readonly
|
248
|
+
*/
|
249
|
+
get archivedAt() {
|
250
|
+
if (!this.archiveTimestamp) return null;
|
251
|
+
return new Date(this.archiveTimestamp);
|
252
|
+
}
|
253
|
+
|
254
|
+
/**
|
255
|
+
* The time the thread was created at
|
256
|
+
* @type {?Date}
|
257
|
+
* @readonly
|
258
|
+
*/
|
259
|
+
get createdAt() {
|
260
|
+
return this.createdTimestamp && new Date(this.createdTimestamp);
|
261
|
+
}
|
262
|
+
|
263
|
+
/**
|
264
|
+
* The parent channel of this thread
|
265
|
+
* @type {?(NewsChannel|TextChannel|ForumChannel)}
|
266
|
+
* @readonly
|
267
|
+
*/
|
268
|
+
get parent() {
|
269
|
+
return this.guild.channels.resolve(this.parentId);
|
270
|
+
}
|
271
|
+
|
272
|
+
/**
|
273
|
+
* Makes the client user join the thread.
|
274
|
+
* @returns {Promise<ThreadChannel>}
|
275
|
+
*/
|
276
|
+
async join() {
|
277
|
+
await this.members.add('@me');
|
278
|
+
return this;
|
279
|
+
}
|
280
|
+
|
281
|
+
/**
|
282
|
+
* Makes the client user leave the thread.
|
283
|
+
* @returns {Promise<ThreadChannel>}
|
284
|
+
*/
|
285
|
+
async leave() {
|
286
|
+
await this.members.remove('@me');
|
287
|
+
return this;
|
288
|
+
}
|
289
|
+
|
290
|
+
/**
|
291
|
+
* Gets the overall set of permissions for a member or role in this thread's parent channel, taking overwrites into
|
292
|
+
* account.
|
293
|
+
* @param {GuildMemberResolvable|RoleResolvable} memberOrRole The member or role to obtain the overall permissions for
|
294
|
+
* @param {boolean} [checkAdmin=true] Whether having `ADMINISTRATOR` will return all permissions
|
295
|
+
* @returns {?Readonly<Permissions>}
|
296
|
+
*/
|
297
|
+
permissionsFor(memberOrRole, checkAdmin) {
|
298
|
+
return this.parent?.permissionsFor(memberOrRole, checkAdmin) ?? null;
|
299
|
+
}
|
300
|
+
|
301
|
+
/**
|
302
|
+
* Fetches the owner of this thread. If the thread member object isn't needed,
|
303
|
+
* use {@link ThreadChannel#ownerId} instead.
|
304
|
+
* @param {BaseFetchOptions} [options] The options for fetching the member
|
305
|
+
* @returns {Promise<?ThreadMember>}
|
306
|
+
*/
|
307
|
+
async fetchOwner({ cache = true, force = false } = {}) {
|
308
|
+
if (!force) {
|
309
|
+
const existing = this.members.cache.get(this.ownerId);
|
310
|
+
if (existing) return existing;
|
311
|
+
}
|
312
|
+
|
313
|
+
// We cannot fetch a single thread member, as of this commit's date, Discord API responds with 405
|
314
|
+
const members = await this.members.fetch(cache);
|
315
|
+
return members.get(this.ownerId) ?? null;
|
316
|
+
}
|
317
|
+
|
318
|
+
/**
|
319
|
+
* Fetches the message that started this thread, if any.
|
320
|
+
* <info>The `Promise` will reject if the original message in a forum post is deleted
|
321
|
+
* or when the original message in the parent channel is deleted.
|
322
|
+
* If you just need the id of that message, use {@link ThreadChannel#id} instead.</info>
|
323
|
+
* @param {BaseFetchOptions} [options] Additional options for this fetch
|
324
|
+
* @returns {Promise<Message|null>}
|
325
|
+
*/
|
326
|
+
// eslint-disable-next-line require-await
|
327
|
+
async fetchStarterMessage(options) {
|
328
|
+
const channel = this.parent?.type === 'GUILD_FORUM' ? this : this.parent;
|
329
|
+
return channel?.messages.fetch(this.id, options) ?? null;
|
330
|
+
}
|
331
|
+
|
332
|
+
/**
|
333
|
+
* The options used to edit a thread channel
|
334
|
+
* @typedef {Object} ThreadEditData
|
335
|
+
* @property {string} [name] The new name for the thread
|
336
|
+
* @property {boolean} [archived] Whether the thread is archived
|
337
|
+
* @property {ThreadAutoArchiveDuration} [autoArchiveDuration] The amount of time (in minutes) after which the thread
|
338
|
+
* should automatically archive in case of no recent activity
|
339
|
+
* @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the thread in seconds
|
340
|
+
* @property {boolean} [locked] Whether the thread is locked
|
341
|
+
* @property {boolean} [invitable] Whether non-moderators can add other non-moderators to a thread
|
342
|
+
* <info>Can only be edited on `GUILD_PRIVATE_THREAD`</info>
|
343
|
+
* @property {Snowflake[]} [appliedTags] The tags to apply to the thread
|
344
|
+
* @property {ChannelFlagsResolvable} [flags] The flags to set on the channel
|
345
|
+
*/
|
346
|
+
|
347
|
+
/**
|
348
|
+
* Edits this thread.
|
349
|
+
* @param {ThreadEditData} data The new data for this thread
|
350
|
+
* @param {string} [reason] Reason for editing this thread
|
351
|
+
* @returns {Promise<ThreadChannel>}
|
352
|
+
* @example
|
353
|
+
* // Edit a thread
|
354
|
+
* thread.edit({ name: 'new-thread' })
|
355
|
+
* .then(editedThread => console.log(editedThread))
|
356
|
+
* .catch(console.error);
|
357
|
+
*/
|
358
|
+
async edit(data, reason) {
|
359
|
+
let autoArchiveDuration = data.autoArchiveDuration;
|
360
|
+
if (autoArchiveDuration === 'MAX') autoArchiveDuration = resolveAutoArchiveMaxLimit(this.guild);
|
361
|
+
|
362
|
+
const newData = await this.client.api.channels(this.id).patch({
|
363
|
+
data: {
|
364
|
+
name: (data.name ?? this.name).trim(),
|
365
|
+
archived: data.archived,
|
366
|
+
auto_archive_duration: autoArchiveDuration,
|
367
|
+
rate_limit_per_user: data.rateLimitPerUser,
|
368
|
+
locked: data.locked,
|
369
|
+
invitable: this.type === 'GUILD_PRIVATE_THREAD' ? data.invitable : undefined,
|
370
|
+
applied_tags: data.appliedTags,
|
371
|
+
flags: 'flags' in data ? ChannelFlags.resolve(data.flags) : undefined,
|
372
|
+
},
|
373
|
+
reason,
|
374
|
+
});
|
375
|
+
|
376
|
+
return this.client.actions.ChannelUpdate.handle(newData).updated;
|
377
|
+
}
|
378
|
+
|
379
|
+
/**
|
380
|
+
* Sets whether the thread is archived.
|
381
|
+
* @param {boolean} [archived=true] Whether the thread is archived
|
382
|
+
* @param {string} [reason] Reason for archiving or unarchiving
|
383
|
+
* @returns {Promise<ThreadChannel>}
|
384
|
+
* @example
|
385
|
+
* // Archive the thread
|
386
|
+
* thread.setArchived(true)
|
387
|
+
* .then(newThread => console.log(`Thread is now ${newThread.archived ? 'archived' : 'active'}`))
|
388
|
+
* .catch(console.error);
|
389
|
+
*/
|
390
|
+
setArchived(archived = true, reason) {
|
391
|
+
return this.edit({ archived }, reason);
|
392
|
+
}
|
393
|
+
|
394
|
+
/**
|
395
|
+
* Sets the duration after which the thread will automatically archive in case of no recent activity.
|
396
|
+
* @param {ThreadAutoArchiveDuration} autoArchiveDuration The amount of time (in minutes) after which the thread
|
397
|
+
* should automatically archive in case of no recent activity
|
398
|
+
* @param {string} [reason] Reason for changing the auto archive duration
|
399
|
+
* @returns {Promise<ThreadChannel>}
|
400
|
+
* @example
|
401
|
+
* // Set the thread's auto archive time to 1 hour
|
402
|
+
* thread.setAutoArchiveDuration(60)
|
403
|
+
* .then(newThread => {
|
404
|
+
* console.log(`Thread will now archive after ${newThread.autoArchiveDuration} minutes of inactivity`);
|
405
|
+
* });
|
406
|
+
* .catch(console.error);
|
407
|
+
*/
|
408
|
+
setAutoArchiveDuration(autoArchiveDuration, reason) {
|
409
|
+
return this.edit({ autoArchiveDuration }, reason);
|
410
|
+
}
|
411
|
+
|
412
|
+
/**
|
413
|
+
* Sets whether members without the `MANAGE_THREADS` permission can invite other members without the
|
414
|
+
* `MANAGE_THREADS` permission to this thread.
|
415
|
+
* @param {boolean} [invitable=true] Whether non-moderators can invite non-moderators to this thread
|
416
|
+
* @param {string} [reason] Reason for changing invite
|
417
|
+
* @returns {Promise<ThreadChannel>}
|
418
|
+
*/
|
419
|
+
setInvitable(invitable = true, reason) {
|
420
|
+
if (this.type !== 'GUILD_PRIVATE_THREAD') return Promise.reject(new RangeError('THREAD_INVITABLE_TYPE', this.type));
|
421
|
+
return this.edit({ invitable }, reason);
|
422
|
+
}
|
423
|
+
|
424
|
+
/**
|
425
|
+
* Sets whether the thread can be **unarchived** by anyone with `SEND_MESSAGES` permission.
|
426
|
+
* When a thread is locked only members with `MANAGE_THREADS` can unarchive it.
|
427
|
+
* @param {boolean} [locked=true] Whether the thread is locked
|
428
|
+
* @param {string} [reason] Reason for locking or unlocking the thread
|
429
|
+
* @returns {Promise<ThreadChannel>}
|
430
|
+
* @example
|
431
|
+
* // Set the thread to locked
|
432
|
+
* thread.setLocked(true)
|
433
|
+
* .then(newThread => console.log(`Thread is now ${newThread.locked ? 'locked' : 'unlocked'}`))
|
434
|
+
* .catch(console.error);
|
435
|
+
*/
|
436
|
+
setLocked(locked = true, reason) {
|
437
|
+
return this.edit({ locked }, reason);
|
438
|
+
}
|
439
|
+
|
440
|
+
/**
|
441
|
+
* Sets a new name for this thread.
|
442
|
+
* @param {string} name The new name for the thread
|
443
|
+
* @param {string} [reason] Reason for changing the thread's name
|
444
|
+
* @returns {Promise<ThreadChannel>}
|
445
|
+
* @example
|
446
|
+
* // Change the thread's name
|
447
|
+
* thread.setName('not_general')
|
448
|
+
* .then(newThread => console.log(`Thread's new name is ${newThread.name}`))
|
449
|
+
* .catch(console.error);
|
450
|
+
*/
|
451
|
+
setName(name, reason) {
|
452
|
+
return this.edit({ name }, reason);
|
453
|
+
}
|
454
|
+
|
455
|
+
/**
|
456
|
+
* Sets the rate limit per user (slowmode) for this thread.
|
457
|
+
* @param {number} rateLimitPerUser The new rate limit in seconds
|
458
|
+
* @param {string} [reason] Reason for changing the thread's rate limit
|
459
|
+
* @returns {Promise<ThreadChannel>}
|
460
|
+
*/
|
461
|
+
setRateLimitPerUser(rateLimitPerUser, reason) {
|
462
|
+
return this.edit({ rateLimitPerUser }, reason);
|
463
|
+
}
|
464
|
+
|
465
|
+
/**
|
466
|
+
* Pins this thread from the forum channel.
|
467
|
+
* @param {string} [reason] Reason for pinning
|
468
|
+
* @returns {Promise<ThreadChannel>}
|
469
|
+
*/
|
470
|
+
pin(reason) {
|
471
|
+
return this.edit({ flags: this.flags.add(ChannelFlags.FLAGS.PINNED) }, reason);
|
472
|
+
}
|
473
|
+
|
474
|
+
/**
|
475
|
+
* Unpins this thread from the forum channel.
|
476
|
+
* @param {string} [reason] Reason for unpinning
|
477
|
+
* @returns {Promise<ThreadChannel>}
|
478
|
+
*/
|
479
|
+
unpin(reason) {
|
480
|
+
return this.edit({ flags: this.flags.remove(ChannelFlags.FLAGS.PINNED) }, reason);
|
481
|
+
}
|
482
|
+
|
483
|
+
/**
|
484
|
+
* Set the applied tags for this channel (only applicable to forum threads)
|
485
|
+
* @param {Snowflake[]} appliedTags The tags to set for this channel
|
486
|
+
* @param {string} [reason] Reason for changing the thread's applied tags
|
487
|
+
* @returns {Promise<ThreadChannel>}
|
488
|
+
*/
|
489
|
+
setAppliedTags(appliedTags, reason) {
|
490
|
+
return this.edit({ appliedTags }, reason);
|
491
|
+
}
|
492
|
+
|
493
|
+
/**
|
494
|
+
* Whether the client user is a member of the thread.
|
495
|
+
* @type {boolean}
|
496
|
+
* @readonly
|
497
|
+
*/
|
498
|
+
get joined() {
|
499
|
+
return this.members.cache.has(this.client.user?.id);
|
500
|
+
}
|
501
|
+
|
502
|
+
/**
|
503
|
+
* Whether the thread is editable by the client user (name, archived, autoArchiveDuration)
|
504
|
+
* @type {boolean}
|
505
|
+
* @readonly
|
506
|
+
*/
|
507
|
+
get editable() {
|
508
|
+
return (
|
509
|
+
(this.ownerId === this.client.user.id && (this.type !== 'GUILD_PRIVATE_THREAD' || this.joined)) || this.manageable
|
510
|
+
);
|
511
|
+
}
|
512
|
+
|
513
|
+
/**
|
514
|
+
* Whether the thread is joinable by the client user
|
515
|
+
* @type {boolean}
|
516
|
+
* @readonly
|
517
|
+
*/
|
518
|
+
get joinable() {
|
519
|
+
return (
|
520
|
+
!this.archived &&
|
521
|
+
!this.joined &&
|
522
|
+
this.permissionsFor(this.client.user)?.has(
|
523
|
+
this.type === 'GUILD_PRIVATE_THREAD' ? Permissions.FLAGS.MANAGE_THREADS : Permissions.FLAGS.VIEW_CHANNEL,
|
524
|
+
false,
|
525
|
+
)
|
526
|
+
);
|
527
|
+
}
|
528
|
+
|
529
|
+
/**
|
530
|
+
* Whether the thread is manageable by the client user, for deleting or editing rateLimitPerUser or locked.
|
531
|
+
* @type {boolean}
|
532
|
+
* @readonly
|
533
|
+
*/
|
534
|
+
get manageable() {
|
535
|
+
const permissions = this.permissionsFor(this.client.user);
|
536
|
+
if (!permissions) return false;
|
537
|
+
// This flag allows managing even if timed out
|
538
|
+
if (permissions.has(Permissions.FLAGS.ADMINISTRATOR, false)) return true;
|
539
|
+
|
540
|
+
return (
|
541
|
+
this.guild.members.me.communicationDisabledUntilTimestamp < Date.now() &&
|
542
|
+
permissions.has(Permissions.FLAGS.MANAGE_THREADS, false)
|
543
|
+
);
|
544
|
+
}
|
545
|
+
|
546
|
+
/**
|
547
|
+
* Whether the thread is viewable by the client user
|
548
|
+
* @type {boolean}
|
549
|
+
* @readonly
|
550
|
+
*/
|
551
|
+
get viewable() {
|
552
|
+
if (this.client.user.id === this.guild.ownerId) return true;
|
553
|
+
const permissions = this.permissionsFor(this.client.user);
|
554
|
+
if (!permissions) return false;
|
555
|
+
return permissions.has(Permissions.FLAGS.VIEW_CHANNEL, false);
|
556
|
+
}
|
557
|
+
|
558
|
+
/**
|
559
|
+
* Whether the client user can send messages in this thread
|
560
|
+
* @type {boolean}
|
561
|
+
* @readonly
|
562
|
+
*/
|
563
|
+
get sendable() {
|
564
|
+
const permissions = this.permissionsFor(this.client.user);
|
565
|
+
if (!permissions) return false;
|
566
|
+
// This flag allows sending even if timed out
|
567
|
+
if (permissions.has(Permissions.FLAGS.ADMINISTRATOR, false)) return true;
|
568
|
+
|
569
|
+
return (
|
570
|
+
!(this.archived && this.locked && !this.manageable) &&
|
571
|
+
(this.type !== 'GUILD_PRIVATE_THREAD' || this.joined || this.manageable) &&
|
572
|
+
permissions.has(Permissions.FLAGS.SEND_MESSAGES_IN_THREADS, false) &&
|
573
|
+
this.guild.members.me.communicationDisabledUntilTimestamp < Date.now()
|
574
|
+
);
|
575
|
+
}
|
576
|
+
|
577
|
+
/**
|
578
|
+
* Whether the thread is unarchivable by the client user
|
579
|
+
* @type {boolean}
|
580
|
+
* @readonly
|
581
|
+
*/
|
582
|
+
get unarchivable() {
|
583
|
+
return this.archived && this.sendable && (!this.locked || this.manageable);
|
584
|
+
}
|
585
|
+
|
586
|
+
/**
|
587
|
+
* Whether this thread is a private thread
|
588
|
+
* @returns {boolean}
|
589
|
+
*/
|
590
|
+
isPrivate() {
|
591
|
+
return this.type === 'GUILD_PRIVATE_THREAD';
|
592
|
+
}
|
593
|
+
|
594
|
+
/**
|
595
|
+
* Deletes this thread.
|
596
|
+
* @param {string} [reason] Reason for deleting this thread
|
597
|
+
* @returns {Promise<ThreadChannel>}
|
598
|
+
* @example
|
599
|
+
* // Delete the thread
|
600
|
+
* thread.delete('cleaning out old threads')
|
601
|
+
* .then(deletedThread => console.log(deletedThread))
|
602
|
+
* .catch(console.error);
|
603
|
+
*/
|
604
|
+
async delete(reason) {
|
605
|
+
await this.guild.channels.delete(this.id, reason);
|
606
|
+
return this;
|
607
|
+
}
|
608
|
+
|
609
|
+
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
610
|
+
/* eslint-disable no-empty-function */
|
611
|
+
get lastMessage() {}
|
612
|
+
get lastPinAt() {}
|
613
|
+
send() {}
|
614
|
+
sendTyping() {}
|
615
|
+
createMessageCollector() {}
|
616
|
+
awaitMessages() {}
|
617
|
+
createMessageComponentCollector() {}
|
618
|
+
awaitMessageComponent() {}
|
619
|
+
bulkDelete() {}
|
620
|
+
// Doesn't work on Thread channels; setRateLimitPerUser() {}
|
621
|
+
// Doesn't work on Thread channels; setNSFW() {}
|
622
|
+
}
|
623
|
+
|
624
|
+
TextBasedChannel.applyToClass(ThreadChannel, true, ['fetchWebhooks', 'setRateLimitPerUser', 'setNSFW']);
|
625
|
+
|
626
|
+
module.exports = ThreadChannel;
|