@ovencord/discord.js 14.16.3
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/LICENSE +191 -0
- package/README.md +148 -0
- package/package.json +73 -0
- package/src/client/Client.ts +967 -0
- package/src/client/actions/Action.ts +141 -0
- package/src/client/actions/ActionsManager.ts +138 -0
- package/src/client/actions/ChannelCreate.ts +21 -0
- package/src/client/actions/ChannelDelete.ts +20 -0
- package/src/client/actions/ChannelUpdate.ts +38 -0
- package/src/client/actions/GuildChannelsPositionUpdate.ts +17 -0
- package/src/client/actions/GuildEmojiCreate.ts +17 -0
- package/src/client/actions/GuildEmojiDelete.ts +16 -0
- package/src/client/actions/GuildEmojiUpdate.ts +17 -0
- package/src/client/actions/GuildEmojisUpdate.ts +30 -0
- package/src/client/actions/GuildMemberRemove.ts +29 -0
- package/src/client/actions/GuildMemberUpdate.ts +41 -0
- package/src/client/actions/GuildRoleCreate.ts +23 -0
- package/src/client/actions/GuildRoleDelete.ts +26 -0
- package/src/client/actions/GuildRolesPositionUpdate.ts +17 -0
- package/src/client/actions/GuildScheduledEventDelete.ts +28 -0
- package/src/client/actions/GuildScheduledEventUserAdd.ts +29 -0
- package/src/client/actions/GuildScheduledEventUserRemove.ts +29 -0
- package/src/client/actions/GuildSoundboardSoundDelete.ts +26 -0
- package/src/client/actions/GuildStickerCreate.ts +17 -0
- package/src/client/actions/GuildStickerDelete.ts +16 -0
- package/src/client/actions/GuildStickerUpdate.ts +17 -0
- package/src/client/actions/GuildStickersUpdate.ts +30 -0
- package/src/client/actions/GuildUpdate.ts +30 -0
- package/src/client/actions/InteractionCreate.ts +104 -0
- package/src/client/actions/MessageCreate.ts +38 -0
- package/src/client/actions/MessageDelete.ts +29 -0
- package/src/client/actions/MessageDeleteBulk.ts +45 -0
- package/src/client/actions/MessagePollVoteAdd.ts +37 -0
- package/src/client/actions/MessagePollVoteRemove.ts +35 -0
- package/src/client/actions/MessageReactionAdd.ts +68 -0
- package/src/client/actions/MessageReactionRemove.ts +47 -0
- package/src/client/actions/MessageReactionRemoveAll.ts +30 -0
- package/src/client/actions/MessageReactionRemoveEmoji.ts +25 -0
- package/src/client/actions/MessageUpdate.ts +22 -0
- package/src/client/actions/StageInstanceCreate.ts +25 -0
- package/src/client/actions/StageInstanceDelete.ts +28 -0
- package/src/client/actions/StageInstanceUpdate.ts +27 -0
- package/src/client/actions/ThreadCreate.ts +22 -0
- package/src/client/actions/ThreadMembersUpdate.ts +45 -0
- package/src/client/actions/TypingStart.ts +26 -0
- package/src/client/actions/UserUpdate.ts +33 -0
- package/src/client/voice/ClientVoiceManager.ts +46 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.ts +19 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.ts +17 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.ts +18 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.ts +21 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.ts +20 -0
- package/src/client/websocket/handlers/CHANNEL_CREATE.ts +4 -0
- package/src/client/websocket/handlers/CHANNEL_DELETE.ts +4 -0
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.ts +22 -0
- package/src/client/websocket/handlers/CHANNEL_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/ENTITLEMENT_CREATE.ts +14 -0
- package/src/client/websocket/handlers/ENTITLEMENT_DELETE.ts +18 -0
- package/src/client/websocket/handlers/ENTITLEMENT_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.ts +19 -0
- package/src/client/websocket/handlers/GUILD_BAN_ADD.ts +15 -0
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.ts +20 -0
- package/src/client/websocket/handlers/GUILD_CREATE.ts +34 -0
- package/src/client/websocket/handlers/GUILD_DELETE.ts +36 -0
- package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.ts +15 -0
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.ts +40 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.ts +17 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.ts +21 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.ts +17 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.ts +19 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.ts +24 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.ts +18 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.ts +20 -0
- package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.ts +4 -0
- package/src/client/websocket/handlers/INVITE_CREATE.ts +20 -0
- package/src/client/websocket/handlers/INVITE_DELETE.ts +23 -0
- package/src/client/websocket/handlers/MESSAGE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/PRESENCE_UPDATE.ts +42 -0
- package/src/client/websocket/handlers/RATE_LIMITED.ts +23 -0
- package/src/client/websocket/handlers/READY.ts +29 -0
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.ts +24 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.ts +14 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.ts +16 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/THREAD_CREATE.ts +4 -0
- package/src/client/websocket/handlers/THREAD_DELETE.ts +17 -0
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.ts +50 -0
- package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.ts +25 -0
- package/src/client/websocket/handlers/THREAD_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/TYPING_START.ts +4 -0
- package/src/client/websocket/handlers/USER_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.ts +16 -0
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.ts +5 -0
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.ts +37 -0
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/index.ts +74 -0
- package/src/errors/DJSError.ts +50 -0
- package/src/errors/ErrorCodes.ts +277 -0
- package/src/errors/Messages.ts +155 -0
- package/src/errors/index.ts +6 -0
- package/src/index.ts +241 -0
- package/src/managers/ApplicationCommandManager.ts +303 -0
- package/src/managers/ApplicationCommandPermissionsManager.ts +453 -0
- package/src/managers/ApplicationEmojiManager.ts +149 -0
- package/src/managers/AutoModerationRuleManager.ts +307 -0
- package/src/managers/BaseManager.ts +13 -0
- package/src/managers/CachedManager.ts +56 -0
- package/src/managers/CategoryChannelChildManager.ts +81 -0
- package/src/managers/ChannelManager.ts +194 -0
- package/src/managers/DMMessageManager.ts +15 -0
- package/src/managers/DataManager.ts +38 -0
- package/src/managers/EntitlementManager.ts +182 -0
- package/src/managers/GuildApplicationCommandManager.ts +29 -0
- package/src/managers/GuildBanManager.ts +221 -0
- package/src/managers/GuildChannelManager.ts +552 -0
- package/src/managers/GuildEmojiManager.ts +262 -0
- package/src/managers/GuildEmojiRoleManager.ts +134 -0
- package/src/managers/GuildForumThreadManager.ts +84 -0
- package/src/managers/GuildInviteManager.ts +236 -0
- package/src/managers/GuildManager.ts +265 -0
- package/src/managers/GuildMemberManager.ts +619 -0
- package/src/managers/GuildMemberRoleManager.ts +230 -0
- package/src/managers/GuildMessageManager.ts +31 -0
- package/src/managers/GuildScheduledEventManager.ts +330 -0
- package/src/managers/GuildSoundboardSoundManager.ts +157 -0
- package/src/managers/GuildStickerManager.ts +192 -0
- package/src/managers/GuildTextThreadManager.ts +91 -0
- package/src/managers/MessageManager.ts +352 -0
- package/src/managers/PartialGroupDMMessageManager.ts +15 -0
- package/src/managers/PermissionOverwriteManager.ts +174 -0
- package/src/managers/PollAnswerVoterManager.ts +59 -0
- package/src/managers/PresenceManager.ts +60 -0
- package/src/managers/ReactionManager.ts +72 -0
- package/src/managers/ReactionUserManager.ts +82 -0
- package/src/managers/RoleManager.ts +432 -0
- package/src/managers/StageInstanceManager.ts +166 -0
- package/src/managers/SubscriptionManager.ts +83 -0
- package/src/managers/ThreadManager.ts +210 -0
- package/src/managers/ThreadMemberManager.ts +194 -0
- package/src/managers/UserManager.ts +139 -0
- package/src/managers/VoiceStateManager.ts +61 -0
- package/src/sharding/Shard.ts +513 -0
- package/src/sharding/ShardClientUtil.ts +293 -0
- package/src/sharding/ShardingManager.ts +374 -0
- package/src/structures/ActionRow.ts +31 -0
- package/src/structures/AnnouncementChannel.ts +25 -0
- package/src/structures/AnonymousGuild.ts +110 -0
- package/src/structures/ApplicationCommand.ts +675 -0
- package/src/structures/ApplicationEmoji.ts +189 -0
- package/src/structures/ApplicationRoleConnectionMetadata.ts +54 -0
- package/src/structures/Attachment.ts +189 -0
- package/src/structures/AuthorizingIntegrationOwners.ts +63 -0
- package/src/structures/AutoModerationActionExecution.ts +138 -0
- package/src/structures/AutoModerationRule.ts +325 -0
- package/src/structures/AutocompleteInteraction.ts +115 -0
- package/src/structures/Base.ts +37 -0
- package/src/structures/BaseChannel.ts +188 -0
- package/src/structures/BaseGuild.ts +134 -0
- package/src/structures/BaseGuildEmoji.ts +113 -0
- package/src/structures/BaseGuildTextChannel.ts +230 -0
- package/src/structures/BaseGuildVoiceChannel.ts +270 -0
- package/src/structures/BaseInteraction.ts +393 -0
- package/src/structures/BaseInvite.ts +192 -0
- package/src/structures/BaseSelectMenuComponent.ts +58 -0
- package/src/structures/ButtonComponent.ts +68 -0
- package/src/structures/ButtonInteraction.ts +8 -0
- package/src/structures/CategoryChannel.ts +46 -0
- package/src/structures/ChannelSelectMenuComponent.ts +18 -0
- package/src/structures/ChannelSelectMenuInteraction.ts +34 -0
- package/src/structures/ChatInputCommandInteraction.ts +43 -0
- package/src/structures/ClientApplication.ts +470 -0
- package/src/structures/ClientPresence.ts +87 -0
- package/src/structures/ClientUser.ts +219 -0
- package/src/structures/CommandInteraction.ts +193 -0
- package/src/structures/CommandInteractionOptionResolver.ts +336 -0
- package/src/structures/Component.ts +59 -0
- package/src/structures/ContainerComponent.ts +63 -0
- package/src/structures/ContextMenuCommandInteraction.ts +68 -0
- package/src/structures/DMChannel.ts +148 -0
- package/src/structures/DirectoryChannel.ts +40 -0
- package/src/structures/Embed.ts +251 -0
- package/src/structures/Emoji.ts +61 -0
- package/src/structures/Entitlement.ts +206 -0
- package/src/structures/FileComponent.ts +41 -0
- package/src/structures/ForumChannel.ts +31 -0
- package/src/structures/GroupDMInvite.ts +34 -0
- package/src/structures/Guild.ts +1605 -0
- package/src/structures/GuildAuditLogs.ts +99 -0
- package/src/structures/GuildAuditLogsEntry.ts +557 -0
- package/src/structures/GuildBan.ts +65 -0
- package/src/structures/GuildChannel.ts +515 -0
- package/src/structures/GuildEmoji.ts +159 -0
- package/src/structures/GuildInvite.ts +233 -0
- package/src/structures/GuildMember.ts +643 -0
- package/src/structures/GuildOnboarding.ts +73 -0
- package/src/structures/GuildOnboardingPrompt.ts +93 -0
- package/src/structures/GuildOnboardingPromptOption.ts +100 -0
- package/src/structures/GuildPreview.ts +218 -0
- package/src/structures/GuildPreviewEmoji.ts +28 -0
- package/src/structures/GuildScheduledEvent.ts +593 -0
- package/src/structures/GuildTemplate.ts +229 -0
- package/src/structures/Integration.ts +257 -0
- package/src/structures/IntegrationApplication.ts +84 -0
- package/src/structures/InteractionCallback.ts +86 -0
- package/src/structures/InteractionCallbackResource.ts +57 -0
- package/src/structures/InteractionCallbackResponse.ts +35 -0
- package/src/structures/InteractionCollector.ts +260 -0
- package/src/structures/InteractionWebhook.ts +65 -0
- package/src/structures/InviteGuild.ts +22 -0
- package/src/structures/LabelComponent.ts +51 -0
- package/src/structures/MediaChannel.ts +8 -0
- package/src/structures/MediaGalleryComponent.ts +31 -0
- package/src/structures/MediaGalleryItem.ts +54 -0
- package/src/structures/MentionableSelectMenuComponent.ts +8 -0
- package/src/structures/MentionableSelectMenuInteraction.ts +76 -0
- package/src/structures/Message.ts +1202 -0
- package/src/structures/MessageCollector.ts +155 -0
- package/src/structures/MessageComponentInteraction.ts +132 -0
- package/src/structures/MessageContextMenuCommandInteraction.ts +18 -0
- package/src/structures/MessageMentions.ts +327 -0
- package/src/structures/MessagePayload.ts +325 -0
- package/src/structures/MessageReaction.ts +219 -0
- package/src/structures/ModalComponentResolver.ts +237 -0
- package/src/structures/ModalSubmitInteraction.ts +260 -0
- package/src/structures/OAuth2Guild.ts +30 -0
- package/src/structures/PartialGroupDMChannel.ts +151 -0
- package/src/structures/PermissionOverwrites.ts +222 -0
- package/src/structures/Poll.ts +195 -0
- package/src/structures/PollAnswer.ts +100 -0
- package/src/structures/Presence.ts +448 -0
- package/src/structures/PrimaryEntryPointCommandInteraction.ts +8 -0
- package/src/structures/ReactionCollector.ts +245 -0
- package/src/structures/ReactionEmoji.ts +30 -0
- package/src/structures/Role.ts +543 -0
- package/src/structures/RoleSelectMenuComponent.ts +8 -0
- package/src/structures/RoleSelectMenuInteraction.ts +34 -0
- package/src/structures/SKU.ts +62 -0
- package/src/structures/SectionComponent.ts +44 -0
- package/src/structures/SeparatorComponent.ts +29 -0
- package/src/structures/SoundboardSound.ts +176 -0
- package/src/structures/StageChannel.ts +118 -0
- package/src/structures/StageInstance.ts +173 -0
- package/src/structures/Sticker.ts +300 -0
- package/src/structures/StickerPack.ts +111 -0
- package/src/structures/StringSelectMenuComponent.ts +18 -0
- package/src/structures/StringSelectMenuInteraction.ts +21 -0
- package/src/structures/Subscription.ts +138 -0
- package/src/structures/Team.ts +131 -0
- package/src/structures/TeamMember.ts +77 -0
- package/src/structures/TextChannel.ts +33 -0
- package/src/structures/TextDisplayComponent.ts +18 -0
- package/src/structures/TextInputComponent.ts +28 -0
- package/src/structures/ThreadChannel.ts +680 -0
- package/src/structures/ThreadMember.ts +125 -0
- package/src/structures/ThreadOnlyChannel.ts +276 -0
- package/src/structures/ThumbnailComponent.ts +51 -0
- package/src/structures/Typing.ts +81 -0
- package/src/structures/UnfurledMediaItem.ts +33 -0
- package/src/structures/User.ts +511 -0
- package/src/structures/UserContextMenuCommandInteraction.ts +28 -0
- package/src/structures/UserSelectMenuComponent.ts +8 -0
- package/src/structures/UserSelectMenuInteraction.ts +54 -0
- package/src/structures/VoiceChannel.ts +119 -0
- package/src/structures/VoiceChannelEffect.ts +92 -0
- package/src/structures/VoiceRegion.ts +52 -0
- package/src/structures/VoiceState.ts +346 -0
- package/src/structures/Webhook.ts +526 -0
- package/src/structures/WelcomeChannel.ts +67 -0
- package/src/structures/WelcomeScreen.ts +53 -0
- package/src/structures/Widget.ts +110 -0
- package/src/structures/WidgetMember.ts +124 -0
- package/src/structures/interfaces/Application.ts +179 -0
- package/src/structures/interfaces/Collector.ts +372 -0
- package/src/structures/interfaces/InteractionResponses.ts +384 -0
- package/src/structures/interfaces/TextBasedChannel.ts +430 -0
- package/src/util/APITypes.ts +690 -0
- package/src/util/ActivityFlagsBitField.ts +26 -0
- package/src/util/ApplicationFlagsBitField.ts +43 -0
- package/src/util/AttachmentFlagsBitField.ts +26 -0
- package/src/util/BitField.ts +178 -0
- package/src/util/ChannelFlagsBitField.ts +43 -0
- package/src/util/Channels.ts +165 -0
- package/src/util/Colors.ts +72 -0
- package/src/util/Components.ts +285 -0
- package/src/util/Constants.ts +251 -0
- package/src/util/DataResolver.ts +146 -0
- package/src/util/Enums.ts +10 -0
- package/src/util/Events.ts +178 -0
- package/src/util/GuildMemberFlagsBitField.ts +43 -0
- package/src/util/IntentsBitField.ts +35 -0
- package/src/util/InviteFlagsBitField.ts +26 -0
- package/src/util/Invites.ts +27 -0
- package/src/util/LimitedCollection.ts +73 -0
- package/src/util/MessageFlagsBitField.ts +43 -0
- package/src/util/Options.ts +215 -0
- package/src/util/Partials.ts +50 -0
- package/src/util/PermissionsBitField.ts +113 -0
- package/src/util/RoleFlagsBitField.ts +26 -0
- package/src/util/SKUFlagsBitField.ts +26 -0
- package/src/util/ShardEvents.ts +26 -0
- package/src/util/Status.ts +16 -0
- package/src/util/Sweepers.ts +532 -0
- package/src/util/Symbols.ts +1 -0
- package/src/util/SystemChannelFlagsBitField.ts +45 -0
- package/src/util/ThreadMemberFlagsBitField.ts +33 -0
- package/src/util/Transformers.ts +123 -0
- package/src/util/UserFlagsBitField.ts +33 -0
- package/src/util/Util.ts +519 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { OverwriteType } from 'discord-api-types/v10';
|
|
2
|
+
import { DiscordjsTypeError, ErrorCodes } from '../errors/index.js';
|
|
3
|
+
import { PermissionsBitField } from '../util/PermissionsBitField.js';
|
|
4
|
+
import { Base } from './Base.js';
|
|
5
|
+
import { Role } from './Role.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a permission overwrite for a role or member in a guild channel.
|
|
9
|
+
*
|
|
10
|
+
* @extends {Base}
|
|
11
|
+
*/
|
|
12
|
+
export class PermissionOverwrites extends Base {
|
|
13
|
+
public client: any;
|
|
14
|
+
public id: any;
|
|
15
|
+
public type: any;
|
|
16
|
+
public deny: any;
|
|
17
|
+
public allow: any;
|
|
18
|
+
constructor(client, data, channel) {
|
|
19
|
+
super(client);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The GuildChannel this overwrite is for
|
|
23
|
+
*
|
|
24
|
+
* @name PermissionOverwrites#channel
|
|
25
|
+
* @type {GuildChannel}
|
|
26
|
+
* @readonly
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(this, 'channel', { value: channel });
|
|
29
|
+
|
|
30
|
+
this._patch(data);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_patch(data) {
|
|
34
|
+
/**
|
|
35
|
+
* The overwrite's id, either a {@link User} or a {@link Role} id
|
|
36
|
+
*
|
|
37
|
+
* @type {Snowflake}
|
|
38
|
+
*/
|
|
39
|
+
this.id = data.id;
|
|
40
|
+
|
|
41
|
+
if ('type' in data) {
|
|
42
|
+
/**
|
|
43
|
+
* The type of this overwrite
|
|
44
|
+
*
|
|
45
|
+
* @type {OverwriteType}
|
|
46
|
+
*/
|
|
47
|
+
this.type = data.type;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if ('deny' in data) {
|
|
51
|
+
/**
|
|
52
|
+
* The permissions that are denied for the user or role.
|
|
53
|
+
*
|
|
54
|
+
* @type {Readonly<PermissionsBitField>}
|
|
55
|
+
*/
|
|
56
|
+
this.deny = new PermissionsBitField(BigInt(data.deny)).freeze();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if ('allow' in data) {
|
|
60
|
+
/**
|
|
61
|
+
* The permissions that are allowed for the user or role.
|
|
62
|
+
*
|
|
63
|
+
* @type {Readonly<PermissionsBitField>}
|
|
64
|
+
*/
|
|
65
|
+
this.allow = new PermissionsBitField(BigInt(data.allow)).freeze();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Edits this Permission Overwrite.
|
|
71
|
+
*
|
|
72
|
+
* @param {PermissionOverwriteOptions} options The options for the update
|
|
73
|
+
* @param {string} [reason] Reason for creating/editing this overwrite
|
|
74
|
+
* @returns {Promise<PermissionOverwrites>}
|
|
75
|
+
* @example
|
|
76
|
+
* // Update permission overwrites
|
|
77
|
+
* permissionOverwrites.edit({
|
|
78
|
+
* SendMessages: false
|
|
79
|
+
* })
|
|
80
|
+
* .then(channel => console.log(channel.permissionOverwrites.get(message.author.id)))
|
|
81
|
+
* .catch(console.error);
|
|
82
|
+
*/
|
|
83
|
+
async edit(options, reason) {
|
|
84
|
+
await this.channel.permissionOverwrites.upsert(this.id, options, { type: this.type, reason }, this);
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Deletes this Permission Overwrite.
|
|
90
|
+
*
|
|
91
|
+
* @param {string} [reason] Reason for deleting this overwrite
|
|
92
|
+
* @returns {Promise<PermissionOverwrites>}
|
|
93
|
+
*/
|
|
94
|
+
async delete(reason) {
|
|
95
|
+
await this.channel.permissionOverwrites.delete(this.id, reason);
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
toJSON() {
|
|
100
|
+
return {
|
|
101
|
+
id: this.id,
|
|
102
|
+
type: this.type,
|
|
103
|
+
allow: this.allow,
|
|
104
|
+
deny: this.deny,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* An object mapping permission flags to `true` (enabled), `null` (unset) or `false` (disabled).
|
|
110
|
+
* ```js
|
|
111
|
+
* {
|
|
112
|
+
* 'SendMessages': true,
|
|
113
|
+
* 'EmbedLinks': null,
|
|
114
|
+
* 'AttachFiles': false,
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @typedef {Object<string, ?boolean>} PermissionOverwriteOptions
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @typedef {Object} ResolvedOverwriteOptions
|
|
123
|
+
* @property {PermissionsBitField} allow The allowed permissions
|
|
124
|
+
* @property {PermissionsBitField} deny The denied permissions
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Resolves bitfield permissions overwrites from an object.
|
|
129
|
+
*
|
|
130
|
+
* @param {PermissionOverwriteOptions} options The options for the update
|
|
131
|
+
* @param {ResolvedOverwriteOptions} initialPermissions The initial permissions
|
|
132
|
+
* @returns {ResolvedOverwriteOptions}
|
|
133
|
+
*/
|
|
134
|
+
static resolveOverwriteOptions(options, initialPermissions = {}) {
|
|
135
|
+
const allow = new PermissionsBitField(initialPermissions.allow);
|
|
136
|
+
const deny = new PermissionsBitField(initialPermissions.deny);
|
|
137
|
+
|
|
138
|
+
for (const [perm, value] of Object.entries(options)) {
|
|
139
|
+
if (value === true) {
|
|
140
|
+
allow.add(perm);
|
|
141
|
+
deny.remove(perm);
|
|
142
|
+
} else if (value === false) {
|
|
143
|
+
allow.remove(perm);
|
|
144
|
+
deny.add(perm);
|
|
145
|
+
} else if (value === null) {
|
|
146
|
+
allow.remove(perm);
|
|
147
|
+
deny.remove(perm);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return { allow, deny };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The raw data for a permission overwrite
|
|
156
|
+
*
|
|
157
|
+
* @typedef {Object} RawOverwriteData
|
|
158
|
+
* @property {Snowflake} id The id of the {@link Role} or {@link User} this overwrite belongs to
|
|
159
|
+
* @property {string} allow The permissions to allow
|
|
160
|
+
* @property {string} deny The permissions to deny
|
|
161
|
+
* @property {number} type The type of this OverwriteData
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Data that can be resolved into {@link APIOverwrite}. This can be:
|
|
166
|
+
* - PermissionOverwrites
|
|
167
|
+
* - OverwriteData
|
|
168
|
+
*
|
|
169
|
+
* @typedef {PermissionOverwrites|OverwriteData} OverwriteResolvable
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Data that can be used for a permission overwrite
|
|
174
|
+
*
|
|
175
|
+
* @typedef {Object} OverwriteData
|
|
176
|
+
* @property {UserResolvable|RoleResolvable} id Member or role this overwrite is for
|
|
177
|
+
* @property {PermissionResolvable} [allow] The permissions to allow
|
|
178
|
+
* @property {PermissionResolvable} [deny] The permissions to deny
|
|
179
|
+
* @property {OverwriteType} [type] The type of this OverwriteData (mandatory if `id` is a Snowflake)
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Resolves an overwrite into {@link APIOverwrite}.
|
|
184
|
+
*
|
|
185
|
+
* @param {OverwriteResolvable} overwrite The overwrite-like data to resolve
|
|
186
|
+
* @param {Guild} [guild] The guild to resolve from
|
|
187
|
+
* @returns {RawOverwriteData}
|
|
188
|
+
*/
|
|
189
|
+
static resolve(overwrite, guild) {
|
|
190
|
+
if (overwrite instanceof this) return overwrite.toJSON();
|
|
191
|
+
|
|
192
|
+
const id = guild.roles.resolveId(overwrite.id) ?? guild.client.users.resolveId(overwrite.id);
|
|
193
|
+
if (!id) {
|
|
194
|
+
throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'overwrite.id', 'UserResolvable or RoleResolvable');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (overwrite.type !== undefined && (typeof overwrite.type !== 'number' || !(overwrite.type in OverwriteType))) {
|
|
198
|
+
throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'overwrite.type', 'OverwriteType', true);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
let type;
|
|
202
|
+
if (typeof overwrite.id === 'string') {
|
|
203
|
+
if (overwrite.type === undefined) {
|
|
204
|
+
throw new DiscordjsTypeError(ErrorCodes.PermissionOverwritesTypeMandatory);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
type = overwrite.type;
|
|
208
|
+
} else {
|
|
209
|
+
type = overwrite.id instanceof Role ? OverwriteType.Role : OverwriteType.Member;
|
|
210
|
+
if (overwrite.type !== undefined && type !== overwrite.type) {
|
|
211
|
+
throw new DiscordjsTypeError(ErrorCodes.PermissionOverwritesTypeMismatch, OverwriteType[type]);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
id,
|
|
217
|
+
type,
|
|
218
|
+
allow: PermissionsBitField.resolve(overwrite.allow ?? PermissionsBitField.DefaultBit).toString(),
|
|
219
|
+
deny: PermissionsBitField.resolve(overwrite.deny ?? PermissionsBitField.DefaultBit).toString(),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { Collection } from '@ovencord/collection';
|
|
2
|
+
import { DiscordjsError, ErrorCodes } from '../errors/index.js';
|
|
3
|
+
import { Base } from './Base.js';
|
|
4
|
+
import { PollAnswer } from './PollAnswer.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a Poll
|
|
8
|
+
*
|
|
9
|
+
* @extends {Base}
|
|
10
|
+
*/
|
|
11
|
+
export class Poll extends Base {
|
|
12
|
+
public client: any;
|
|
13
|
+
public channelId: any;
|
|
14
|
+
public messageId: any;
|
|
15
|
+
public answers: any;
|
|
16
|
+
public resultsFinalized: any;
|
|
17
|
+
public allowMultiselect: any;
|
|
18
|
+
public layoutType: any;
|
|
19
|
+
public expiresTimestamp: any;
|
|
20
|
+
public question: any;
|
|
21
|
+
constructor(client, data, message, channel) {
|
|
22
|
+
super(client);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The id of the channel that this poll is in
|
|
26
|
+
*
|
|
27
|
+
* @type {Snowflake}
|
|
28
|
+
*/
|
|
29
|
+
this.channelId = data.channel_id ?? channel.id;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The channel that this poll is in
|
|
33
|
+
*
|
|
34
|
+
* @name Poll#channel
|
|
35
|
+
* @type {TextBasedChannel}
|
|
36
|
+
* @readonly
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
Object.defineProperty(this, 'channel', { value: channel });
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The id of the message that started this poll
|
|
43
|
+
*
|
|
44
|
+
* @type {Snowflake}
|
|
45
|
+
*/
|
|
46
|
+
this.messageId = data.message_id ?? message.id;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The message that started this poll
|
|
50
|
+
*
|
|
51
|
+
* @name Poll#message
|
|
52
|
+
* @type {Message}
|
|
53
|
+
* @readonly
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
Object.defineProperty(this, 'message', { value: message });
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The answers of this poll
|
|
60
|
+
*
|
|
61
|
+
* @type {Collection<number, PollAnswer|PartialPollAnswer>}
|
|
62
|
+
*/
|
|
63
|
+
this.answers = new Collection();
|
|
64
|
+
|
|
65
|
+
this._patch(data);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_patch(data) {
|
|
69
|
+
if (data.answers) {
|
|
70
|
+
for (const answer of data.answers) {
|
|
71
|
+
const existing = this.answers.get(answer.answer_id);
|
|
72
|
+
if (existing) {
|
|
73
|
+
existing._patch(answer);
|
|
74
|
+
} else {
|
|
75
|
+
this.answers.set(answer.answer_id, new PollAnswer(this.client, answer, this));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (data.results) {
|
|
81
|
+
/**
|
|
82
|
+
* Whether this poll's results have been precisely counted
|
|
83
|
+
*
|
|
84
|
+
* @type {boolean}
|
|
85
|
+
*/
|
|
86
|
+
this.resultsFinalized = data.results.is_finalized;
|
|
87
|
+
|
|
88
|
+
for (const answerResult of data.results.answer_counts) {
|
|
89
|
+
const answer = this.answers.get(answerResult.id);
|
|
90
|
+
answer?._patch(answerResult);
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
this.resultsFinalized ??= false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if ('allow_multiselect' in data) {
|
|
97
|
+
/**
|
|
98
|
+
* Whether this poll allows multiple answers
|
|
99
|
+
*
|
|
100
|
+
* @type {boolean}
|
|
101
|
+
*/
|
|
102
|
+
this.allowMultiselect = data.allow_multiselect;
|
|
103
|
+
} else {
|
|
104
|
+
this.allowMultiselect ??= null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if ('layout_type' in data) {
|
|
108
|
+
/**
|
|
109
|
+
* The layout type of this poll
|
|
110
|
+
*
|
|
111
|
+
* @type {PollLayoutType}
|
|
112
|
+
*/
|
|
113
|
+
this.layoutType = data.layout_type;
|
|
114
|
+
} else {
|
|
115
|
+
this.layoutType ??= null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if ('expiry' in data) {
|
|
119
|
+
/**
|
|
120
|
+
* The timestamp when this poll expires
|
|
121
|
+
*
|
|
122
|
+
* @type {?number}
|
|
123
|
+
*/
|
|
124
|
+
this.expiresTimestamp = data.expiry && Date.parse(data.expiry);
|
|
125
|
+
} else {
|
|
126
|
+
this.expiresTimestamp ??= null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (data.question) {
|
|
130
|
+
/**
|
|
131
|
+
* The media for a poll's question
|
|
132
|
+
*
|
|
133
|
+
* @typedef {Object} PollQuestionMedia
|
|
134
|
+
* @property {?string} text The text of this question
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The media for this poll's question
|
|
139
|
+
*
|
|
140
|
+
* @type {PollQuestionMedia}
|
|
141
|
+
*/
|
|
142
|
+
this.question = {
|
|
143
|
+
text: data.question.text,
|
|
144
|
+
};
|
|
145
|
+
} else {
|
|
146
|
+
this.question ??= {
|
|
147
|
+
text: null,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The date when this poll expires
|
|
154
|
+
*
|
|
155
|
+
* @type {?Date}
|
|
156
|
+
* @readonly
|
|
157
|
+
*/
|
|
158
|
+
get expiresAt() {
|
|
159
|
+
return this.expiresTimestamp && new Date(this.expiresTimestamp);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Whether this poll is a partial
|
|
164
|
+
*
|
|
165
|
+
* @type {boolean}
|
|
166
|
+
* @readonly
|
|
167
|
+
*/
|
|
168
|
+
get partial() {
|
|
169
|
+
return this.allowMultiselect === null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Fetches the message that started this poll, then updates the poll from the fetched message.
|
|
174
|
+
*
|
|
175
|
+
* @returns {Promise<Poll>}
|
|
176
|
+
*/
|
|
177
|
+
async fetch() {
|
|
178
|
+
await this.channel.messages.fetch(this.messageId);
|
|
179
|
+
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Ends this poll.
|
|
185
|
+
*
|
|
186
|
+
* @returns {Promise<Message>}
|
|
187
|
+
*/
|
|
188
|
+
async end() {
|
|
189
|
+
if (this.expiresTimestamp !== null && Date.now() > this.expiresTimestamp) {
|
|
190
|
+
throw new DiscordjsError(ErrorCodes.PollAlreadyExpired);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return this.channel.messages.endPoll(this.messageId);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { PollAnswerVoterManager } from '../managers/PollAnswerVoterManager.js';
|
|
2
|
+
import { resolveGuildEmoji } from '../util/Util.js';
|
|
3
|
+
import { Base } from './Base.js';
|
|
4
|
+
import { Emoji } from './Emoji.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents an answer to a {@link Poll}
|
|
8
|
+
*
|
|
9
|
+
* @extends {Base}
|
|
10
|
+
*/
|
|
11
|
+
export class PollAnswer extends Base {
|
|
12
|
+
public client: any;
|
|
13
|
+
public id: any;
|
|
14
|
+
public voters: any;
|
|
15
|
+
public voteCount: any;
|
|
16
|
+
public _emoji: any;
|
|
17
|
+
public text: any;
|
|
18
|
+
constructor(client, data, poll) {
|
|
19
|
+
super(client);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The {@link Poll} this answer is part of
|
|
23
|
+
*
|
|
24
|
+
* @name PollAnswer#poll
|
|
25
|
+
* @type {Poll|PartialPoll}
|
|
26
|
+
* @readonly
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(this, 'poll', { value: poll });
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The id of this answer
|
|
32
|
+
*
|
|
33
|
+
* @type {number}
|
|
34
|
+
*/
|
|
35
|
+
this.id = data.answer_id;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The manager of the voters for this answer
|
|
39
|
+
*
|
|
40
|
+
* @type {PollAnswerVoterManager}
|
|
41
|
+
*/
|
|
42
|
+
this.voters = new PollAnswerVoterManager(this);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The raw emoji of this answer
|
|
46
|
+
*
|
|
47
|
+
* @name PollAnswer#_emoji
|
|
48
|
+
* @type {?APIPartialEmoji}
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
Object.defineProperty(this, '_emoji', { value: null, writable: true });
|
|
52
|
+
|
|
53
|
+
this._patch(data);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_patch(data) {
|
|
57
|
+
// This `count` field comes from `poll.results.answer_counts`
|
|
58
|
+
if ('count' in data) {
|
|
59
|
+
/**
|
|
60
|
+
* The amount of votes this answer has
|
|
61
|
+
*
|
|
62
|
+
* @type {number}
|
|
63
|
+
*/
|
|
64
|
+
this.voteCount = data.count;
|
|
65
|
+
} else {
|
|
66
|
+
this.voteCount ??= this.voters.cache.size;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The text of this answer
|
|
71
|
+
*
|
|
72
|
+
* @type {?string}
|
|
73
|
+
*/
|
|
74
|
+
this.text ??= data.poll_media?.text ?? null;
|
|
75
|
+
|
|
76
|
+
if (data.poll_media?.emoji) {
|
|
77
|
+
this._emoji = data.poll_media.emoji;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The emoji of this answer
|
|
83
|
+
*
|
|
84
|
+
* @type {?(GuildEmoji|Emoji)}
|
|
85
|
+
*/
|
|
86
|
+
get emoji() {
|
|
87
|
+
if (!this._emoji || (!this._emoji.id && !this._emoji.name)) return null;
|
|
88
|
+
return resolveGuildEmoji(this.client, this._emoji.id) ?? new Emoji(this.client, this._emoji);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Whether this poll answer is a partial.
|
|
93
|
+
*
|
|
94
|
+
* @type {boolean}
|
|
95
|
+
* @readonly
|
|
96
|
+
*/
|
|
97
|
+
get partial() {
|
|
98
|
+
return this.poll.partial || (this.text === null && this.emoji === null);
|
|
99
|
+
}
|
|
100
|
+
}
|