oceanic.js 1.10.3-dev.c6c9f52 → 1.10.3-dev.ca8b6e8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/Client.d.ts +99 -0
- package/dist/lib/Client.js +263 -0
- package/dist/lib/Constants.d.ts +1215 -0
- package/dist/lib/Constants.js +1513 -0
- package/dist/lib/gateway/Shard.d.ts +83 -0
- package/dist/lib/gateway/Shard.js +1621 -0
- package/dist/lib/gateway/ShardManager.d.ts +29 -0
- package/dist/lib/gateway/ShardManager.js +300 -0
- package/dist/lib/index.d.ts +84 -0
- package/dist/lib/index.js +168 -0
- package/dist/lib/rest/Bucket.d.ts +33 -0
- package/dist/lib/rest/Bucket.js +78 -0
- package/dist/lib/rest/DiscordHTTPError.d.ts +16 -0
- package/dist/lib/rest/DiscordHTTPError.js +65 -0
- package/dist/lib/rest/DiscordRESTError.d.ts +19 -0
- package/dist/lib/rest/DiscordRESTError.js +89 -0
- package/dist/lib/rest/OAuthHelper.d.ts +62 -0
- package/dist/lib/rest/OAuthHelper.js +183 -0
- package/dist/lib/rest/RESTManager.d.ts +42 -0
- package/dist/lib/rest/RESTManager.js +82 -0
- package/dist/lib/rest/RequestHandler.d.ts +28 -0
- package/dist/lib/rest/RequestHandler.js +313 -0
- package/dist/lib/rest/SequentialBucket.d.ts +25 -0
- package/dist/lib/rest/SequentialBucket.js +76 -0
- package/dist/lib/routes/Applications.d.ts +171 -0
- package/dist/lib/routes/Applications.js +447 -0
- package/dist/lib/routes/Channels.d.ts +408 -0
- package/dist/lib/routes/Channels.js +1160 -0
- package/dist/lib/routes/Guilds.d.ts +606 -0
- package/dist/lib/routes/Guilds.js +1669 -0
- package/dist/lib/routes/Interactions.d.ts +74 -0
- package/dist/lib/routes/Interactions.js +141 -0
- package/dist/lib/routes/Miscellaneous.d.ts +31 -0
- package/dist/lib/routes/Miscellaneous.js +69 -0
- package/dist/lib/routes/OAuth.d.ts +108 -0
- package/dist/lib/routes/OAuth.js +312 -0
- package/dist/lib/routes/Users.d.ts +32 -0
- package/dist/lib/routes/Users.js +59 -0
- package/dist/lib/routes/Webhooks.d.ts +128 -0
- package/dist/lib/routes/Webhooks.js +265 -0
- package/dist/lib/structures/AnnouncementChannel.d.ts +36 -0
- package/dist/lib/structures/AnnouncementChannel.js +47 -0
- package/dist/lib/structures/AnnouncementThreadChannel.d.ts +18 -0
- package/dist/lib/structures/AnnouncementThreadChannel.js +27 -0
- package/dist/lib/structures/Application.d.ts +102 -0
- package/dist/lib/structures/Application.js +189 -0
- package/dist/lib/structures/ApplicationCommand.d.ts +74 -0
- package/dist/lib/structures/ApplicationCommand.js +141 -0
- package/dist/lib/structures/Attachment.d.ts +34 -0
- package/dist/lib/structures/Attachment.js +64 -0
- package/dist/lib/structures/AuditLogEntry.d.ts +25 -0
- package/dist/lib/structures/AuditLogEntry.js +53 -0
- package/dist/lib/structures/AutoModerationRule.d.ts +49 -0
- package/dist/lib/structures/AutoModerationRule.js +139 -0
- package/dist/lib/structures/AutocompleteInteraction.d.ts +62 -0
- package/dist/lib/structures/AutocompleteInteraction.js +115 -0
- package/dist/lib/structures/Base.d.ts +20 -0
- package/dist/lib/structures/Base.js +58 -0
- package/dist/lib/structures/BaseEntitlement.d.ts +19 -0
- package/dist/lib/structures/BaseEntitlement.js +44 -0
- package/dist/lib/structures/CategoryChannel.d.ts +41 -0
- package/dist/lib/structures/CategoryChannel.js +105 -0
- package/dist/lib/structures/Channel.d.ts +20 -0
- package/dist/lib/structures/Channel.js +91 -0
- package/dist/lib/structures/ClientApplication.d.ts +153 -0
- package/dist/lib/structures/ClientApplication.js +220 -0
- package/dist/lib/structures/CommandInteraction.d.ts +127 -0
- package/dist/lib/structures/CommandInteraction.js +297 -0
- package/dist/lib/structures/ComponentInteraction.d.ts +137 -0
- package/dist/lib/structures/ComponentInteraction.js +311 -0
- package/dist/lib/structures/Entitlement.d.ts +12 -0
- package/dist/lib/structures/Entitlement.js +26 -0
- package/dist/lib/structures/ExtendedUser.d.ts +26 -0
- package/dist/lib/structures/ExtendedUser.js +57 -0
- package/dist/lib/structures/ForumChannel.d.ts +11 -0
- package/dist/lib/structures/ForumChannel.js +19 -0
- package/dist/lib/structures/GroupChannel.d.ts +62 -0
- package/dist/lib/structures/GroupChannel.js +133 -0
- package/dist/lib/structures/Guild.d.ts +654 -0
- package/dist/lib/structures/Guild.js +1319 -0
- package/dist/lib/structures/GuildChannel.d.ts +34 -0
- package/dist/lib/structures/GuildChannel.js +75 -0
- package/dist/lib/structures/GuildPreview.d.ts +50 -0
- package/dist/lib/structures/GuildPreview.js +119 -0
- package/dist/lib/structures/GuildScheduledEvent.d.ts +60 -0
- package/dist/lib/structures/GuildScheduledEvent.js +154 -0
- package/dist/lib/structures/GuildTemplate.d.ts +55 -0
- package/dist/lib/structures/GuildTemplate.js +126 -0
- package/dist/lib/structures/Integration.d.ts +54 -0
- package/dist/lib/structures/Integration.js +156 -0
- package/dist/lib/structures/Interaction.d.ts +40 -0
- package/dist/lib/structures/Interaction.js +90 -0
- package/dist/lib/structures/InteractionResolvedChannel.d.ts +28 -0
- package/dist/lib/structures/InteractionResolvedChannel.js +45 -0
- package/dist/lib/structures/Invite.d.ts +64 -0
- package/dist/lib/structures/Invite.js +193 -0
- package/dist/lib/structures/InviteGuild.d.ts +52 -0
- package/dist/lib/structures/InviteGuild.js +88 -0
- package/dist/lib/structures/MediaChannel.d.ts +11 -0
- package/dist/lib/structures/MediaChannel.js +19 -0
- package/dist/lib/structures/Member.d.ts +122 -0
- package/dist/lib/structures/Member.js +255 -0
- package/dist/lib/structures/Message.d.ts +194 -0
- package/dist/lib/structures/Message.js +477 -0
- package/dist/lib/structures/ModalSubmitInteraction.d.ts +128 -0
- package/dist/lib/structures/ModalSubmitInteraction.js +240 -0
- package/dist/lib/structures/OAuthApplication.d.ts +79 -0
- package/dist/lib/structures/OAuthApplication.js +210 -0
- package/dist/lib/structures/OAuthGuild.d.ts +35 -0
- package/dist/lib/structures/OAuthGuild.js +61 -0
- package/dist/lib/structures/PartialApplication.d.ts +30 -0
- package/dist/lib/structures/PartialApplication.js +67 -0
- package/dist/lib/structures/Permission.d.ts +21 -0
- package/dist/lib/structures/Permission.js +68 -0
- package/dist/lib/structures/PermissionOverwrite.d.ts +26 -0
- package/dist/lib/structures/PermissionOverwrite.js +49 -0
- package/dist/lib/structures/PingInteraction.d.ts +16 -0
- package/dist/lib/structures/PingInteraction.js +26 -0
- package/dist/lib/structures/Poll.d.ts +28 -0
- package/dist/lib/structures/Poll.js +78 -0
- package/dist/lib/structures/PrivateChannel.d.ts +90 -0
- package/dist/lib/structures/PrivateChannel.js +131 -0
- package/dist/lib/structures/PrivateThreadChannel.d.ts +18 -0
- package/dist/lib/structures/PrivateThreadChannel.js +27 -0
- package/dist/lib/structures/PublicThreadChannel.d.ts +21 -0
- package/dist/lib/structures/PublicThreadChannel.js +37 -0
- package/dist/lib/structures/Role.d.ts +52 -0
- package/dist/lib/structures/Role.js +137 -0
- package/dist/lib/structures/SKU.d.ts +32 -0
- package/dist/lib/structures/SKU.js +53 -0
- package/dist/lib/structures/StageChannel.d.ts +33 -0
- package/dist/lib/structures/StageChannel.js +44 -0
- package/dist/lib/structures/StageInstance.d.ts +36 -0
- package/dist/lib/structures/StageInstance.js +94 -0
- package/dist/lib/structures/Team.d.ts +22 -0
- package/dist/lib/structures/Team.js +67 -0
- package/dist/lib/structures/TestEntitlement.d.ts +10 -0
- package/dist/lib/structures/TestEntitlement.js +21 -0
- package/dist/lib/structures/TextChannel.d.ts +34 -0
- package/dist/lib/structures/TextChannel.js +46 -0
- package/dist/lib/structures/TextableChannel.d.ts +158 -0
- package/dist/lib/structures/TextableChannel.js +276 -0
- package/dist/lib/structures/TextableVoiceChannel.d.ts +39 -0
- package/dist/lib/structures/TextableVoiceChannel.js +81 -0
- package/dist/lib/structures/ThreadChannel.d.ts +159 -0
- package/dist/lib/structures/ThreadChannel.js +295 -0
- package/dist/lib/structures/ThreadOnlyChannel.d.ts +99 -0
- package/dist/lib/structures/ThreadOnlyChannel.js +233 -0
- package/dist/lib/structures/ThreadableChannel.d.ts +36 -0
- package/dist/lib/structures/ThreadableChannel.js +58 -0
- package/dist/lib/structures/UnavailableGuild.d.ts +11 -0
- package/dist/lib/structures/UnavailableGuild.js +21 -0
- package/dist/lib/structures/User.d.ts +82 -0
- package/dist/lib/structures/User.js +168 -0
- package/dist/lib/structures/VoiceChannel.d.ts +20 -0
- package/dist/lib/structures/VoiceChannel.js +35 -0
- package/dist/lib/structures/VoiceState.d.ts +51 -0
- package/dist/lib/structures/VoiceState.js +140 -0
- package/dist/lib/structures/Webhook.d.ts +129 -0
- package/dist/lib/structures/Webhook.js +206 -0
- package/dist/lib/types/applications.d.ts +466 -0
- package/dist/lib/types/audit-log.d.ts +122 -0
- package/dist/lib/types/auto-moderation.d.ts +99 -0
- package/dist/lib/types/channels.d.ts +1244 -0
- package/dist/lib/types/client.d.ts +228 -0
- package/dist/lib/types/events.d.ts +265 -0
- package/dist/lib/types/gateway-raw.d.ts +584 -0
- package/dist/lib/types/gateway.d.ts +351 -0
- package/dist/lib/types/guild-template.d.ts +33 -0
- package/dist/lib/types/guilds.d.ts +855 -0
- package/dist/lib/types/index.d.ts +18 -0
- package/dist/lib/types/interactions.d.ts +377 -0
- package/dist/lib/types/json.d.ts +742 -0
- package/dist/lib/types/misc.d.ts +28 -0
- package/dist/lib/types/oauth.d.ts +201 -0
- package/dist/lib/types/request-handler.d.ts +52 -0
- package/dist/lib/types/scheduled-events.d.ts +88 -0
- package/dist/lib/types/shared.d.ts +9 -0
- package/dist/lib/types/users.d.ts +45 -0
- package/dist/lib/types/voice.d.ts +45 -0
- package/dist/lib/types/webhooks.d.ts +74 -0
- package/dist/lib/util/Collection.d.ts +47 -0
- package/dist/lib/util/Collection.js +78 -0
- package/dist/lib/util/Errors.d.ts +29 -0
- package/dist/lib/util/Errors.js +56 -0
- package/dist/lib/util/Routes.d.ts +127 -0
- package/dist/lib/util/Routes.js +248 -0
- package/dist/lib/util/SimpleCollection.d.ts +12 -0
- package/dist/lib/util/SimpleCollection.js +81 -0
- package/dist/lib/util/TypedCollection.d.ts +24 -0
- package/dist/lib/util/TypedCollection.js +76 -0
- package/dist/lib/util/TypedEmitter.d.ts +19 -0
- package/dist/lib/util/TypedEmitter.js +19 -0
- package/dist/lib/util/Util.d.ts +58 -0
- package/dist/lib/util/Util.js +535 -0
- package/dist/lib/util/interactions/InteractionOptionsWrapper.d.ts +170 -0
- package/dist/lib/util/interactions/InteractionOptionsWrapper.js +213 -0
- package/dist/lib/util/interactions/MessageInteractionResponse.d.ts +24 -0
- package/dist/lib/util/interactions/MessageInteractionResponse.js +28 -0
- package/dist/lib/util/interactions/ModalSubmitInteractionComponentsWrapper.d.ts +24 -0
- package/dist/lib/util/interactions/ModalSubmitInteractionComponentsWrapper.js +34 -0
- package/dist/lib/util/interactions/SelectMenuValuesWrapper.d.ts +60 -0
- package/dist/lib/util/interactions/SelectMenuValuesWrapper.js +124 -0
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Errors_1 = require("../util/Errors");
|
|
4
|
+
/** Represents a guild template. */
|
|
5
|
+
class GuildTemplate {
|
|
6
|
+
_cachedSourceGuild;
|
|
7
|
+
client;
|
|
8
|
+
/** The code of the template. */
|
|
9
|
+
code;
|
|
10
|
+
/** When this template was created. */
|
|
11
|
+
createdAt;
|
|
12
|
+
/** The creator of this template. */
|
|
13
|
+
creator;
|
|
14
|
+
/** The description of this template. */
|
|
15
|
+
description;
|
|
16
|
+
/** If this template has unsynced changes. */
|
|
17
|
+
isDirty;
|
|
18
|
+
/** The name of this template. */
|
|
19
|
+
name;
|
|
20
|
+
/** A snapshot of the guild. */
|
|
21
|
+
serializedSourceGuild;
|
|
22
|
+
/** The ID of the source guild of this template. */
|
|
23
|
+
sourceGuildID;
|
|
24
|
+
/** When this template was last updated. */
|
|
25
|
+
updatedAt;
|
|
26
|
+
/** The amount of times this template has been used. */
|
|
27
|
+
usageCount;
|
|
28
|
+
constructor(data, client) {
|
|
29
|
+
Object.defineProperty(this, "client", {
|
|
30
|
+
value: client,
|
|
31
|
+
enumerable: false,
|
|
32
|
+
writable: false,
|
|
33
|
+
configurable: false
|
|
34
|
+
});
|
|
35
|
+
this.code = data.code;
|
|
36
|
+
this.createdAt = new Date(data.created_at);
|
|
37
|
+
this.creator = this.client.users.update(data.creator);
|
|
38
|
+
this.description = null;
|
|
39
|
+
this.isDirty = null;
|
|
40
|
+
this.name = data.name;
|
|
41
|
+
this.serializedSourceGuild = data.serialized_source_guild;
|
|
42
|
+
this.sourceGuildID = data.source_guild_id;
|
|
43
|
+
this.updatedAt = new Date(data.updated_at);
|
|
44
|
+
this.usageCount = data.usage_count;
|
|
45
|
+
this.update(data);
|
|
46
|
+
}
|
|
47
|
+
update(data) {
|
|
48
|
+
if (data.description !== undefined) {
|
|
49
|
+
this.description = data.description;
|
|
50
|
+
}
|
|
51
|
+
if (data.is_dirty !== undefined) {
|
|
52
|
+
this.isDirty = data.is_dirty;
|
|
53
|
+
}
|
|
54
|
+
if (data.name !== undefined) {
|
|
55
|
+
this.name = data.name;
|
|
56
|
+
}
|
|
57
|
+
if (data.serialized_source_guild !== undefined) {
|
|
58
|
+
this.serializedSourceGuild = data.serialized_source_guild;
|
|
59
|
+
}
|
|
60
|
+
if (data.source_guild_id !== undefined) {
|
|
61
|
+
this.sourceGuildID = data.source_guild_id;
|
|
62
|
+
}
|
|
63
|
+
if (data.updated_at !== undefined) {
|
|
64
|
+
this.updatedAt = new Date(data.updated_at);
|
|
65
|
+
}
|
|
66
|
+
if (data.usage_count !== undefined) {
|
|
67
|
+
this.usageCount = data.usage_count;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** The source guild of this template. This will throw an error if the guild is not cached. */
|
|
71
|
+
get sourceGuild() {
|
|
72
|
+
this._cachedSourceGuild ??= this.client.guilds.get(this.sourceGuildID);
|
|
73
|
+
if (!this._cachedSourceGuild) {
|
|
74
|
+
if (this.client.options.restMode) {
|
|
75
|
+
throw new Errors_1.UncachedError(`${this.constructor.name}#sourceGuild is not present when rest mode is enabled.`);
|
|
76
|
+
}
|
|
77
|
+
if (!this.client.shards.connected) {
|
|
78
|
+
throw new Errors_1.UncachedError(`${this.constructor.name}#sourceGuild is not present without a gateway connection.`);
|
|
79
|
+
}
|
|
80
|
+
throw new Errors_1.UncachedError(`${this.constructor.name}#sourceGuild is not present.`);
|
|
81
|
+
}
|
|
82
|
+
return this._cachedSourceGuild;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Create a guild from this template. This can only be used by bots in less than 10 guilds.
|
|
86
|
+
* @param options The options for creating the guild.
|
|
87
|
+
*/
|
|
88
|
+
async createGuild(options) {
|
|
89
|
+
return this.client.rest.guilds.createFromTemplate(this.code, options);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Delete this template.
|
|
93
|
+
*/
|
|
94
|
+
async delete() {
|
|
95
|
+
return this.client.rest.guilds.deleteTemplate(this.sourceGuild.id, this.code);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Edit this template.
|
|
99
|
+
* @param options The options for editing the template.
|
|
100
|
+
*/
|
|
101
|
+
async editTemplate(options) {
|
|
102
|
+
return this.client.rest.guilds.editTemplate(this.sourceGuild.id, this.code, options);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Sync this template.
|
|
106
|
+
*/
|
|
107
|
+
async syncTemplate() {
|
|
108
|
+
return this.client.rest.guilds.syncTemplate(this.sourceGuild.id, this.code);
|
|
109
|
+
}
|
|
110
|
+
toJSON() {
|
|
111
|
+
return {
|
|
112
|
+
code: this.code,
|
|
113
|
+
createdAt: this.createdAt.getTime(),
|
|
114
|
+
creator: this.creator.toJSON(),
|
|
115
|
+
description: this.description,
|
|
116
|
+
isDirty: this.isDirty,
|
|
117
|
+
name: this.name,
|
|
118
|
+
serializedSourceGuild: this.serializedSourceGuild,
|
|
119
|
+
sourceGuildID: this.sourceGuildID,
|
|
120
|
+
updatedAt: this.updatedAt.getTime(),
|
|
121
|
+
usageCount: this.usageCount
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.default = GuildTemplate;
|
|
126
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiR3VpbGRUZW1wbGF0ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL2xpYi9zdHJ1Y3R1cmVzL0d1aWxkVGVtcGxhdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFPQSwyQ0FBK0M7QUFFL0MsbUNBQW1DO0FBQ25DLE1BQXFCLGFBQWE7SUFDdEIsa0JBQWtCLENBQVM7SUFDbkMsTUFBTSxDQUFVO0lBQ2hCLGdDQUFnQztJQUNoQyxJQUFJLENBQVM7SUFDYixzQ0FBc0M7SUFDdEMsU0FBUyxDQUFPO0lBQ2hCLG9DQUFvQztJQUNwQyxPQUFPLENBQU87SUFDZCx3Q0FBd0M7SUFDeEMsV0FBVyxDQUFnQjtJQUMzQiw2Q0FBNkM7SUFDN0MsT0FBTyxDQUFpQjtJQUN4QixpQ0FBaUM7SUFDakMsSUFBSSxDQUFTO0lBQ2IsK0JBQStCO0lBQy9CLHFCQUFxQixDQUFvQjtJQUN6QyxtREFBbUQ7SUFDbkQsYUFBYSxDQUFTO0lBQ3RCLDJDQUEyQztJQUMzQyxTQUFTLENBQU87SUFDaEIsdURBQXVEO0lBQ3ZELFVBQVUsQ0FBUztJQUNuQixZQUFZLElBQXNCLEVBQUUsTUFBYztRQUM5QyxNQUFNLENBQUMsY0FBYyxDQUFDLElBQUksRUFBRSxRQUFRLEVBQUU7WUFDbEMsS0FBSyxFQUFTLE1BQU07WUFDcEIs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ElBQUksQ0FBQyxNQUFNLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsRUFBRSxFQUFFLElBQUksQ0FBQyxJQUFJLEVBQUUsT0FBTyxDQUFDLENBQUM7SUFDekYsQ0FBQztJQUVEOztPQUVHO0lBQ0gsS0FBSyxDQUFDLFlBQVk7UUFDZCxPQUFPLElBQUksQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxZQUFZLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxFQUFFLEVBQUUsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ2hGLENBQUM7SUFFRCxNQUFNO1FBQ0YsT0FBTztZQUNILElBQUksRUFBbUIsSUFBSSxDQUFDLElBQUk7WUFDaEMsU0FBUyxFQUFjLElBQUksQ0FBQyxTQUFTLENBQUMsT0FBTyxFQUFFO1lBQy9DLE9BQU8sRUFBZ0IsSUFBSSxDQUFDLE9BQU8sQ0FBQyxNQUFNLEVBQUU7WUFDNUMsV0FBVyxFQUFZLElBQUksQ0FBQyxXQUFXO1lBQ3ZDLE9BQU8sRUFBZ0IsSUFBSSxDQUFDLE9BQU87WUFDbkMsSUFBSSxFQUFtQixJQUFJLENBQUMsSUFBSTtZQUNoQyxxQkFBcUIsRUFBRSxJQUFJLENBQUMscUJBQXFCO1lBQ2pELGFBQWEsRUFBVSxJQUFJLENBQUMsYUFBYTtZQUN6QyxTQUFTLEVBQWMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxPQUFPLEVBQUU7WUFDL0MsVUFBVSxFQUFhLElBQUksQ0FBQyxVQUFVO1NBQ3pDLENBQUM7SUFDTixDQUFDO0NBQ0o7QUFqSUQsZ0NBaUlDIn0=
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** @module Integration */
|
|
2
|
+
import Base from "./Base";
|
|
3
|
+
import PartialApplication from "./PartialApplication";
|
|
4
|
+
import type User from "./User";
|
|
5
|
+
import type Guild from "./Guild";
|
|
6
|
+
import type Role from "./Role";
|
|
7
|
+
import type { IntegrationAccount, RawIntegration } from "../types/guilds";
|
|
8
|
+
import type { IntegrationExpireBehaviors, IntegrationType } from "../Constants";
|
|
9
|
+
import type Client from "../Client";
|
|
10
|
+
import type { JSONIntegration } from "../types/json";
|
|
11
|
+
/** Represents a guild integration. */
|
|
12
|
+
export default class Integration extends Base {
|
|
13
|
+
private _cachedGuild?;
|
|
14
|
+
private _cachedRole?;
|
|
15
|
+
/** The account information associated with this integration. */
|
|
16
|
+
account: IntegrationAccount;
|
|
17
|
+
/** The application associated with this integration. */
|
|
18
|
+
application: PartialApplication | null;
|
|
19
|
+
/** If emoticons should be synced for this integration. */
|
|
20
|
+
enableEmoticons: boolean;
|
|
21
|
+
/** If this integration is enabled. */
|
|
22
|
+
enabled: boolean;
|
|
23
|
+
/** The [behavior](https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors) of expiring subscribers. */
|
|
24
|
+
expireBehavior?: IntegrationExpireBehaviors;
|
|
25
|
+
/** The grace period (in days) before expiring subscribers. */
|
|
26
|
+
expireGracePeriod?: number;
|
|
27
|
+
/** The ID of the guild this integration belongs to, if applicable. */
|
|
28
|
+
guildID: string | null;
|
|
29
|
+
/** The name of the integration. */
|
|
30
|
+
name: string;
|
|
31
|
+
/** If this integration has been revoked. */
|
|
32
|
+
revoked: boolean;
|
|
33
|
+
/** The id of the role this integration uses for subscribers, if any. */
|
|
34
|
+
roleID: string | null;
|
|
35
|
+
/** The scopes the application associated with this integration has been authorized for. */
|
|
36
|
+
scopes?: Array<string>;
|
|
37
|
+
/** The number of subscribers this integration has. */
|
|
38
|
+
subscriberCount?: number;
|
|
39
|
+
/** The last date at which this integration was synced at. */
|
|
40
|
+
syncedAt?: Date;
|
|
41
|
+
/** If this integration is syncing. */
|
|
42
|
+
syncing: boolean;
|
|
43
|
+
/** The type of integration. */
|
|
44
|
+
type: IntegrationType;
|
|
45
|
+
/** The user associated with this integration, if applicable. */
|
|
46
|
+
user?: User;
|
|
47
|
+
constructor(data: RawIntegration, client: Client, guildID?: string);
|
|
48
|
+
protected update(data: Partial<RawIntegration>): void;
|
|
49
|
+
/** The guild this integration belongs to, if applicable. This will throw an error if the guild is not cached. */
|
|
50
|
+
get guild(): Guild | null;
|
|
51
|
+
/** The role this integration uses for subscribers, if any. */
|
|
52
|
+
get role(): Role | null | undefined;
|
|
53
|
+
toJSON(): JSONIntegration;
|
|
54
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
/** @module Integration */
|
|
5
|
+
const Base_1 = tslib_1.__importDefault(require("./Base"));
|
|
6
|
+
const PartialApplication_1 = tslib_1.__importDefault(require("./PartialApplication"));
|
|
7
|
+
const Errors_1 = require("../util/Errors");
|
|
8
|
+
/** Represents a guild integration. */
|
|
9
|
+
class Integration extends Base_1.default {
|
|
10
|
+
_cachedGuild;
|
|
11
|
+
_cachedRole;
|
|
12
|
+
/** The account information associated with this integration. */
|
|
13
|
+
account;
|
|
14
|
+
/** The application associated with this integration. */
|
|
15
|
+
application;
|
|
16
|
+
/** If emoticons should be synced for this integration. */
|
|
17
|
+
enableEmoticons;
|
|
18
|
+
/** If this integration is enabled. */
|
|
19
|
+
enabled;
|
|
20
|
+
/** The [behavior](https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors) of expiring subscribers. */
|
|
21
|
+
expireBehavior;
|
|
22
|
+
/** The grace period (in days) before expiring subscribers. */
|
|
23
|
+
expireGracePeriod;
|
|
24
|
+
/** The ID of the guild this integration belongs to, if applicable. */
|
|
25
|
+
guildID;
|
|
26
|
+
/** The name of the integration. */
|
|
27
|
+
name;
|
|
28
|
+
/** If this integration has been revoked. */
|
|
29
|
+
revoked;
|
|
30
|
+
/** The id of the role this integration uses for subscribers, if any. */
|
|
31
|
+
roleID;
|
|
32
|
+
/** The scopes the application associated with this integration has been authorized for. */
|
|
33
|
+
scopes;
|
|
34
|
+
/** The number of subscribers this integration has. */
|
|
35
|
+
subscriberCount;
|
|
36
|
+
/** The last date at which this integration was synced at. */
|
|
37
|
+
syncedAt;
|
|
38
|
+
/** If this integration is syncing. */
|
|
39
|
+
syncing;
|
|
40
|
+
/** The type of integration. */
|
|
41
|
+
type;
|
|
42
|
+
/** The user associated with this integration, if applicable. */
|
|
43
|
+
user;
|
|
44
|
+
constructor(data, client, guildID) {
|
|
45
|
+
super(data.id, client);
|
|
46
|
+
this.account = data.account;
|
|
47
|
+
this.application = null;
|
|
48
|
+
this.enableEmoticons = !!data.enable_emoticons;
|
|
49
|
+
this.enabled = !!data.enabled;
|
|
50
|
+
this.guildID = guildID === undefined ? null : guildID;
|
|
51
|
+
this.name = data.name;
|
|
52
|
+
this.revoked = !!data.revoked;
|
|
53
|
+
this.roleID = data.role_id === undefined ? null : data.role_id;
|
|
54
|
+
this.syncing = !!data.syncing;
|
|
55
|
+
this.type = data.type;
|
|
56
|
+
this.update(data);
|
|
57
|
+
}
|
|
58
|
+
update(data) {
|
|
59
|
+
if (data.account !== undefined) {
|
|
60
|
+
this.account = data.account;
|
|
61
|
+
}
|
|
62
|
+
if (data.application !== undefined) {
|
|
63
|
+
this.application = new PartialApplication_1.default(data.application, this.client);
|
|
64
|
+
}
|
|
65
|
+
if (data.enable_emoticons !== undefined) {
|
|
66
|
+
this.enableEmoticons = data.enable_emoticons;
|
|
67
|
+
}
|
|
68
|
+
if (data.enabled !== undefined) {
|
|
69
|
+
this.enabled = data.enabled;
|
|
70
|
+
}
|
|
71
|
+
if (data.expire_behavior !== undefined) {
|
|
72
|
+
this.expireBehavior = data.expire_behavior;
|
|
73
|
+
}
|
|
74
|
+
if (data.expire_grace_period !== undefined) {
|
|
75
|
+
this.expireGracePeriod = data.expire_grace_period;
|
|
76
|
+
}
|
|
77
|
+
if (data.name !== undefined) {
|
|
78
|
+
this.name = data.name;
|
|
79
|
+
}
|
|
80
|
+
if (data.revoked !== undefined) {
|
|
81
|
+
this.revoked = data.revoked;
|
|
82
|
+
}
|
|
83
|
+
if (data.role_id !== undefined) {
|
|
84
|
+
this.roleID = data.role_id;
|
|
85
|
+
}
|
|
86
|
+
if (data.scopes !== undefined) {
|
|
87
|
+
this.scopes = data.scopes;
|
|
88
|
+
}
|
|
89
|
+
if (data.subscriber_count !== undefined) {
|
|
90
|
+
this.subscriberCount = data.subscriber_count;
|
|
91
|
+
}
|
|
92
|
+
if (data.synced_at !== undefined) {
|
|
93
|
+
this.syncedAt = new Date(data.synced_at);
|
|
94
|
+
}
|
|
95
|
+
if (data.syncing !== undefined) {
|
|
96
|
+
this.syncing = data.syncing;
|
|
97
|
+
}
|
|
98
|
+
if (data.type !== undefined) {
|
|
99
|
+
this.type = data.type;
|
|
100
|
+
}
|
|
101
|
+
if (data.user !== undefined) {
|
|
102
|
+
this.user = this.client.users.update(data.user);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** The guild this integration belongs to, if applicable. This will throw an error if the guild is not cached. */
|
|
106
|
+
get guild() {
|
|
107
|
+
if (this.guildID !== null && this._cachedGuild !== null) {
|
|
108
|
+
this._cachedGuild ??= this.client.guilds.get(this.guildID);
|
|
109
|
+
if (!this._cachedGuild) {
|
|
110
|
+
if (this.client.options.restMode) {
|
|
111
|
+
throw new Errors_1.UncachedError(`${this.constructor.name}#guild is not present when rest mode is enabled.`);
|
|
112
|
+
}
|
|
113
|
+
if (!this.client.shards.connected) {
|
|
114
|
+
throw new Errors_1.UncachedError(`${this.constructor.name}#guild is not present without a gateway connection.`);
|
|
115
|
+
}
|
|
116
|
+
throw new Errors_1.UncachedError(`${this.constructor.name}#guild is not present.`);
|
|
117
|
+
}
|
|
118
|
+
return this._cachedGuild;
|
|
119
|
+
}
|
|
120
|
+
return this._cachedGuild === null ? this._cachedGuild : (this._cachedGuild = null);
|
|
121
|
+
}
|
|
122
|
+
/** The role this integration uses for subscribers, if any. */
|
|
123
|
+
get role() {
|
|
124
|
+
if (this.roleID !== null && this._cachedRole !== null) {
|
|
125
|
+
try {
|
|
126
|
+
return this._cachedRole ?? (this._cachedRole = this.guild?.roles.get(this.roleID));
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return (this._cachedRole = undefined);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return this._cachedRole === null ? this._cachedRole : (this._cachedRole = null);
|
|
133
|
+
}
|
|
134
|
+
toJSON() {
|
|
135
|
+
return {
|
|
136
|
+
...super.toJSON(),
|
|
137
|
+
account: this.account,
|
|
138
|
+
application: this.application?.toJSON(),
|
|
139
|
+
enableEmoticons: this.enableEmoticons,
|
|
140
|
+
enabled: this.enabled,
|
|
141
|
+
expireBehavior: this.expireBehavior,
|
|
142
|
+
expireGracePeriod: this.expireGracePeriod,
|
|
143
|
+
name: this.name,
|
|
144
|
+
revoked: this.revoked,
|
|
145
|
+
roleID: this.roleID,
|
|
146
|
+
scopes: this.scopes,
|
|
147
|
+
subscriberCount: this.subscriberCount,
|
|
148
|
+
syncedAt: this.syncedAt?.getTime(),
|
|
149
|
+
syncing: this.syncing,
|
|
150
|
+
type: this.type,
|
|
151
|
+
user: this.user?.toJSON()
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.default = Integration;
|
|
156
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSW50ZWdyYXRpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9saWIvc3RydWN0dXJlcy9JbnRlZ3JhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwwQkFBMEI7QUFDMUIsMERBQTBCO0FBQzFCLHNGQUFzRDtBQVF0RCwyQ0FBK0M7QUFFL0Msc0NBQXNDO0FBQ3RDLE1BQXFCLFdBQVksU0FBUSxjQUFJO0lBQ2pDLFlBQVksQ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QUF6SkQsOEJBeUpDIn0=
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** @module Interaction */
|
|
2
|
+
import Base from "./Base";
|
|
3
|
+
import type ClientApplication from "./ClientApplication";
|
|
4
|
+
import type ICommandInteraction from "./CommandInteraction";
|
|
5
|
+
import type IModalSubmitInteraction from "./ModalSubmitInteraction";
|
|
6
|
+
import type IPingInteraction from "./PingInteraction";
|
|
7
|
+
import type IComponentInteraction from "./ComponentInteraction";
|
|
8
|
+
import type IAutocompleteInteraction from "./AutocompleteInteraction";
|
|
9
|
+
import type Client from "../Client";
|
|
10
|
+
import type { AnyInteraction, AnyRawInteraction, RawInteraction } from "../types/interactions";
|
|
11
|
+
import { InteractionTypes } from "../Constants";
|
|
12
|
+
import type { JSONInteraction } from "../types/json";
|
|
13
|
+
/** Represents an interaction. */
|
|
14
|
+
export default class Interaction extends Base {
|
|
15
|
+
/** If this interaction has been acknowledged. */
|
|
16
|
+
acknowledged: boolean;
|
|
17
|
+
/** The application this interaction is for. */
|
|
18
|
+
application?: ClientApplication;
|
|
19
|
+
/** The ID of the application this interaction is for. */
|
|
20
|
+
applicationID: string;
|
|
21
|
+
/** The token of this interaction. */
|
|
22
|
+
token: string;
|
|
23
|
+
/** The [type](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type) of this interaction. */
|
|
24
|
+
type: InteractionTypes;
|
|
25
|
+
/** Read-only property, always `1` */
|
|
26
|
+
version: 1;
|
|
27
|
+
constructor(data: AnyRawInteraction, client: Client);
|
|
28
|
+
static from<T extends AnyInteraction = AnyInteraction>(data: RawInteraction, client: Client): T;
|
|
29
|
+
/** A type guard, checking if this interaction is an {@link AutocompleteInteraction | Autocomplete Interaction}. */
|
|
30
|
+
isAutocompleteInteraction(): this is IAutocompleteInteraction;
|
|
31
|
+
/** A type guard, checking if this interaction is a {@link CommandInteraction | Command Interaction}. */
|
|
32
|
+
isCommandInteraction(): this is ICommandInteraction;
|
|
33
|
+
/** A type guard, checking if this interaction is a {@link ComponentInteraction | Component Interaction}. */
|
|
34
|
+
isComponentInteraction(): this is IComponentInteraction;
|
|
35
|
+
/** A type guard, checking if this interaction is a {@link ModalSubmitInteraction | Modal Submit Interaction}. */
|
|
36
|
+
isModalSubmitInteraction(): this is IModalSubmitInteraction;
|
|
37
|
+
/** A type guard, checking if this interaction is a {@link PingInteraction | Ping Interaction}. */
|
|
38
|
+
isPingInteraction(): this is IPingInteraction;
|
|
39
|
+
toJSON(): JSONInteraction;
|
|
40
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
/** @module Interaction */
|
|
5
|
+
const Base_1 = tslib_1.__importDefault(require("./Base"));
|
|
6
|
+
const Constants_1 = require("../Constants");
|
|
7
|
+
/** Represents an interaction. */
|
|
8
|
+
class Interaction extends Base_1.default {
|
|
9
|
+
/** If this interaction has been acknowledged. */
|
|
10
|
+
acknowledged;
|
|
11
|
+
/** The application this interaction is for. */
|
|
12
|
+
application;
|
|
13
|
+
/** The ID of the application this interaction is for. */
|
|
14
|
+
applicationID;
|
|
15
|
+
/** The token of this interaction. */
|
|
16
|
+
token;
|
|
17
|
+
/** The [type](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type) of this interaction. */
|
|
18
|
+
type;
|
|
19
|
+
/** Read-only property, always `1` */
|
|
20
|
+
version;
|
|
21
|
+
constructor(data, client) {
|
|
22
|
+
super(data.id, client);
|
|
23
|
+
this.acknowledged = false;
|
|
24
|
+
this.application = client["_application"] && client.application.id === data.application_id ? client.application : undefined;
|
|
25
|
+
this.applicationID = data.application_id;
|
|
26
|
+
Object.defineProperty(this, "token", { value: data.token, enumerable: false });
|
|
27
|
+
this.type = data.type;
|
|
28
|
+
this.version = data.version;
|
|
29
|
+
}
|
|
30
|
+
static from(data, client) {
|
|
31
|
+
switch (data.type) {
|
|
32
|
+
case Constants_1.InteractionTypes.PING: {
|
|
33
|
+
return new PingInteraction(data, client);
|
|
34
|
+
}
|
|
35
|
+
case Constants_1.InteractionTypes.APPLICATION_COMMAND: {
|
|
36
|
+
return new CommandInteraction(data, client);
|
|
37
|
+
}
|
|
38
|
+
case Constants_1.InteractionTypes.MESSAGE_COMPONENT: {
|
|
39
|
+
return new ComponentInteraction(data, client);
|
|
40
|
+
}
|
|
41
|
+
case Constants_1.InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE: {
|
|
42
|
+
return new AutocompleteInteraction(data, client);
|
|
43
|
+
}
|
|
44
|
+
case Constants_1.InteractionTypes.MODAL_SUBMIT: {
|
|
45
|
+
return new ModalSubmitInteraction(data, client);
|
|
46
|
+
}
|
|
47
|
+
default: {
|
|
48
|
+
return new Interaction(data, client);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** A type guard, checking if this interaction is an {@link AutocompleteInteraction | Autocomplete Interaction}. */
|
|
53
|
+
isAutocompleteInteraction() {
|
|
54
|
+
return this.type === Constants_1.InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE;
|
|
55
|
+
}
|
|
56
|
+
/** A type guard, checking if this interaction is a {@link CommandInteraction | Command Interaction}. */
|
|
57
|
+
isCommandInteraction() {
|
|
58
|
+
return this.type === Constants_1.InteractionTypes.APPLICATION_COMMAND;
|
|
59
|
+
}
|
|
60
|
+
/** A type guard, checking if this interaction is a {@link ComponentInteraction | Component Interaction}. */
|
|
61
|
+
isComponentInteraction() {
|
|
62
|
+
return this.type === Constants_1.InteractionTypes.MESSAGE_COMPONENT;
|
|
63
|
+
}
|
|
64
|
+
/** A type guard, checking if this interaction is a {@link ModalSubmitInteraction | Modal Submit Interaction}. */
|
|
65
|
+
isModalSubmitInteraction() {
|
|
66
|
+
return this.type === Constants_1.InteractionTypes.MODAL_SUBMIT;
|
|
67
|
+
}
|
|
68
|
+
/** A type guard, checking if this interaction is a {@link PingInteraction | Ping Interaction}. */
|
|
69
|
+
isPingInteraction() {
|
|
70
|
+
return this.type === Constants_1.InteractionTypes.PING;
|
|
71
|
+
}
|
|
72
|
+
toJSON() {
|
|
73
|
+
return {
|
|
74
|
+
...super.toJSON(),
|
|
75
|
+
applicationID: this.applicationID,
|
|
76
|
+
type: this.type,
|
|
77
|
+
version: this.version
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.default = Interaction;
|
|
82
|
+
// Yes this sucks, but it works. That's the important part. Circular imports are hell.
|
|
83
|
+
/* eslint-disable @typescript-eslint/no-var-requires, unicorn/prefer-module */
|
|
84
|
+
const AutocompleteInteraction = require("./AutocompleteInteraction").default;
|
|
85
|
+
const CommandInteraction = require("./CommandInteraction").default;
|
|
86
|
+
const ComponentInteraction = require("./ComponentInteraction").default;
|
|
87
|
+
const ModalSubmitInteraction = require("./ModalSubmitInteraction").default;
|
|
88
|
+
const PingInteraction = require("./PingInteraction").default;
|
|
89
|
+
/* eslint-enable @typescript-eslint/no-var-requires, unicorn/prefer-module */
|
|
90
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSW50ZXJhY3Rpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9saWIvc3RydWN0dXJlcy9JbnRlcmFjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwwQkFBMEI7QUFDMUIsMERBQTBCO0FBaUIxQiw0Q0FBZ0Q7QUFJaEQsaUNBQWlDO0FBQ2pDLE1BQXFCLFdBQVksU0FBUSxjQUFJO0lBQ3pDLGlEQUFpRDtJQUNqRCxZQUFZLENBQVU7SUFDdEIsK0NBQStDO0lBQy9DLFdBQVcsQ0FBcUI7SUFDaEMseURBQXlEO0lBQ3pELGFBQWEsQ0FBUztJQUN0QixxQ0FBcUM7SUFDckMsS0FBSyxDQUFVO0lBQ2YscUpBQXFKO0lB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xDQUFDO0lBRUQsaUhBQWlIO0lBQ2pILHdCQUF3QjtRQUNwQixPQUFPLElBQUksQ0FBQyxJQUFJLEtBQUssNEJBQWdCLENBQUMsWUFBWSxDQUFDO0lBQ3ZELENBQUM7SUFFRCxrR0FBa0c7SUFDbEcsaUJBQWlCO1FBQ2IsT0FBTyxJQUFJLENBQUMsSUFBSSxLQUFLLDRCQUFnQixDQUFDLElBQUksQ0FBQztJQUMvQyxDQUFDO0lBRVEsTUFBTTtRQUNYLE9BQU87WUFDSCxHQUFHLEtBQUssQ0FBQyxNQUFNLEVBQUU7WUFDakIsYUFBYSxFQUFFLElBQUksQ0FBQyxhQUFhO1lBQ2pDLElBQUksRUFBVyxJQUFJLENBQUMsSUFBSTtZQUN4QixPQUFPLEVBQVEsSUFBSSxDQUFDLE9BQU87U0FDOUIsQ0FBQztJQUNOLENBQUM7Q0FDSjtBQWhGRCw4QkFnRkM7QUFHRCxzRkFBc0Y7QUFDdEYsOEVBQThFO0FBQzlFLE1BQU0sdUJBQXVCLEdBQUksT0FBTyxDQUFDLDJCQUEyQixDQUFnRCxDQUFDLE9BQU8sQ0FBQztBQUM3SCxNQUFNLGtCQUFrQixHQUFJLE9BQU8sQ0FBQyxzQkFBc0IsQ0FBMkMsQ0FBQyxPQUFPLENBQUM7QUFDOUcsTUFBTSxvQkFBb0IsR0FBSSxPQUFPLENBQUMsd0JBQXdCLENBQTZDLENBQUMsT0FBTyxDQUFDO0FBQ3BILE1BQU0sc0JBQXNCLEdBQUksT0FBTyxDQUFDLDBCQUEwQixDQUErQyxDQUFDLE9BQU8sQ0FBQztBQUMxSCxNQUFNLGVBQWUsR0FBSSxPQUFPLENBQUMsbUJBQW1CLENBQXdDLENBQUMsT0FBTyxDQUFDO0FBQ3JHLDZFQUE2RSJ9
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @module InteractionResolvedChannel */
|
|
2
|
+
import type AnnouncementChannel from "./AnnouncementChannel";
|
|
3
|
+
import type TextChannel from "./TextChannel";
|
|
4
|
+
import Permission from "./Permission";
|
|
5
|
+
import Channel from "./Channel";
|
|
6
|
+
import type ForumChannel from "./ForumChannel";
|
|
7
|
+
import type Client from "../Client";
|
|
8
|
+
import type { RawInteractionResolvedChannel, ThreadMetadata, PrivateThreadMetadata } from "../types/channels";
|
|
9
|
+
import type { AnyImplementedChannel, ImplementedChannels } from "../types";
|
|
10
|
+
/** Represents a channel from an interaction option. This can be any guild channel, or a direct message. */
|
|
11
|
+
export default class InteractionResolvedChannel extends Channel {
|
|
12
|
+
private _cachedCompleteChannel?;
|
|
13
|
+
private _cachedParent?;
|
|
14
|
+
/** The permissions the bot has in the channel. */
|
|
15
|
+
appPermissions: Permission;
|
|
16
|
+
/** The name of this channel. */
|
|
17
|
+
name: string | null;
|
|
18
|
+
/** The ID of the parent of this channel, if this represents a thread. */
|
|
19
|
+
parentID: string | null;
|
|
20
|
+
/** The [thread metadata](https://discord.com/developers/docs/resources/channel#thread-metadata-object-thread-metadata-structure) associated with this channel, if this represents a thread. */
|
|
21
|
+
threadMetadata: ThreadMetadata | PrivateThreadMetadata | null;
|
|
22
|
+
type: ImplementedChannels;
|
|
23
|
+
constructor(data: RawInteractionResolvedChannel, client: Client);
|
|
24
|
+
/** The complete channel this channel option represents, if it's cached. */
|
|
25
|
+
get completeChannel(): AnyImplementedChannel | undefined;
|
|
26
|
+
/** The parent of this channel, if this represents a thread. */
|
|
27
|
+
get parent(): TextChannel | AnnouncementChannel | ForumChannel | null | undefined;
|
|
28
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const Permission_1 = tslib_1.__importDefault(require("./Permission"));
|
|
5
|
+
const Channel_1 = tslib_1.__importDefault(require("./Channel"));
|
|
6
|
+
/** Represents a channel from an interaction option. This can be any guild channel, or a direct message. */
|
|
7
|
+
class InteractionResolvedChannel extends Channel_1.default {
|
|
8
|
+
_cachedCompleteChannel;
|
|
9
|
+
_cachedParent;
|
|
10
|
+
/** The permissions the bot has in the channel. */
|
|
11
|
+
appPermissions;
|
|
12
|
+
/** The name of this channel. */
|
|
13
|
+
name;
|
|
14
|
+
/** The ID of the parent of this channel, if this represents a thread. */
|
|
15
|
+
parentID;
|
|
16
|
+
/** The [thread metadata](https://discord.com/developers/docs/resources/channel#thread-metadata-object-thread-metadata-structure) associated with this channel, if this represents a thread. */
|
|
17
|
+
threadMetadata;
|
|
18
|
+
constructor(data, client) {
|
|
19
|
+
super(data, client);
|
|
20
|
+
this.appPermissions = new Permission_1.default(data.permissions ?? "0");
|
|
21
|
+
this.name = data.name;
|
|
22
|
+
this.parentID = data.parent_id ?? null;
|
|
23
|
+
this.threadMetadata = data.thread_metadata ? {
|
|
24
|
+
archiveTimestamp: new Date(data.thread_metadata.archive_timestamp),
|
|
25
|
+
archived: !!data.thread_metadata.archived,
|
|
26
|
+
autoArchiveDuration: data.thread_metadata.auto_archive_duration,
|
|
27
|
+
createTimestamp: data.thread_metadata.create_timestamp ? new Date(data.thread_metadata.create_timestamp) : null,
|
|
28
|
+
locked: !!data.thread_metadata.locked,
|
|
29
|
+
invitable: data.thread_metadata.invitable
|
|
30
|
+
} : null;
|
|
31
|
+
}
|
|
32
|
+
/** The complete channel this channel option represents, if it's cached. */
|
|
33
|
+
get completeChannel() {
|
|
34
|
+
return this._cachedCompleteChannel ??= this.client.getChannel(this.id);
|
|
35
|
+
}
|
|
36
|
+
/** The parent of this channel, if this represents a thread. */
|
|
37
|
+
get parent() {
|
|
38
|
+
if (this.parentID !== null && this._cachedParent !== null) {
|
|
39
|
+
return this._cachedParent ?? (this._cachedParent = this.client.getChannel(this.parentID));
|
|
40
|
+
}
|
|
41
|
+
return this._cachedParent === null ? this._cachedParent : (this._cachedParent = null);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = InteractionResolvedChannel;
|
|
45
|
+
//# sourceMapping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UFBSSxDQUFDLENBQUM7SUFDMUYsQ0FBQztDQUNKO0FBeENELDZDQXdDQyJ9
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type GuildScheduledEvent from "./GuildScheduledEvent";
|
|
2
|
+
import type User from "./User";
|
|
3
|
+
import PartialApplication from "./PartialApplication";
|
|
4
|
+
import InviteGuild from "./InviteGuild";
|
|
5
|
+
import type { AnyInviteChannel, InviteInfoTypes, InviteStageInstance, PartialInviteChannel, RawInvite, RawInviteWithMetadata } from "../types/channels";
|
|
6
|
+
import type Client from "../Client";
|
|
7
|
+
import type { InviteTargetTypes } from "../Constants";
|
|
8
|
+
import type { JSONInvite } from "../types/json";
|
|
9
|
+
import type { Uncached } from "../types/shared";
|
|
10
|
+
/** Represents an invite. */
|
|
11
|
+
export default class Invite<T extends InviteInfoTypes = "withMetadata", CH extends AnyInviteChannel | Uncached = AnyInviteChannel | Uncached> {
|
|
12
|
+
private _cachedChannel;
|
|
13
|
+
/** The approximate number of total members in the guild this invite leads to. */
|
|
14
|
+
approximateMemberCount?: number;
|
|
15
|
+
/** The approximate number of online members in the guild this invite leads to. */
|
|
16
|
+
approximatePresenceCount?: number;
|
|
17
|
+
/** The ID of the channel this invite leads to. */
|
|
18
|
+
channelID: string | null;
|
|
19
|
+
client: Client;
|
|
20
|
+
/** The code of this invite. */
|
|
21
|
+
code: string;
|
|
22
|
+
/** When this invite was created. */
|
|
23
|
+
createdAt: T extends "withMetadata" ? Date : undefined;
|
|
24
|
+
/** The date at which this invite expires. */
|
|
25
|
+
expiresAt?: T extends "withMetadata" | "withoutExpiration" ? never : Date;
|
|
26
|
+
/** This invite's [flags](https://discord.com/developers/docs/resources/invite#invite-object-invite-flags). */
|
|
27
|
+
flags: number;
|
|
28
|
+
/** The guild this invite leads to or `null` if this invite leads to a Group DM. */
|
|
29
|
+
guild: InviteGuild | null;
|
|
30
|
+
/** The ID of the guild this invite leads to or `null` if this invite leads to a Group DM. */
|
|
31
|
+
guildID: string | null;
|
|
32
|
+
/** The scheduled event associated with this invite. */
|
|
33
|
+
guildScheduledEvent?: GuildScheduledEvent;
|
|
34
|
+
/** The user that created this invite. */
|
|
35
|
+
inviter?: User;
|
|
36
|
+
/** The time after which this invite expires. */
|
|
37
|
+
maxAge: T extends "withMetadata" ? number : never;
|
|
38
|
+
/** The maximum number of times this invite can be used, */
|
|
39
|
+
maxUses: T extends "withMetadata" ? number : never;
|
|
40
|
+
/** @deprecated The stage instance in the invite this channel is for. */
|
|
41
|
+
stageInstance?: InviteStageInstance;
|
|
42
|
+
/** The embedded application this invite will open. */
|
|
43
|
+
targetApplication?: PartialApplication;
|
|
44
|
+
/** The [target type](https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types) of this invite. */
|
|
45
|
+
targetType?: InviteTargetTypes;
|
|
46
|
+
/** The user whose stream to display for this voice channel stream invite. */
|
|
47
|
+
targetUser?: User;
|
|
48
|
+
/** If this invite only grants temporary membership. */
|
|
49
|
+
temporary: T extends "withMetadata" ? boolean : never;
|
|
50
|
+
/** The number of times this invite has been used. */
|
|
51
|
+
uses: T extends "withMetadata" ? number : never;
|
|
52
|
+
constructor(data: RawInvite | RawInviteWithMetadata, client: Client);
|
|
53
|
+
protected update(data: Partial<RawInvite> | Partial<RawInviteWithMetadata>): void;
|
|
54
|
+
/** The channel this invite leads to. If the channel is not cached, this will be a partial with only `id`, `name, and `type`. */
|
|
55
|
+
get channel(): (CH extends AnyInviteChannel ? CH : PartialInviteChannel) | null;
|
|
56
|
+
/**
|
|
57
|
+
* Delete this invite.
|
|
58
|
+
* @param reason The reason for deleting this invite.
|
|
59
|
+
*/
|
|
60
|
+
deleteInvite(reason?: string): Promise<Invite<"withMetadata", CH>>;
|
|
61
|
+
/** Whether this invite belongs to a cached channel. The only difference on using this method over a simple if statement is to easily update all the invite properties typing definitions based on the channel it belongs to. */
|
|
62
|
+
inCachedChannel(): this is Invite<T, AnyInviteChannel>;
|
|
63
|
+
toJSON(): JSONInvite;
|
|
64
|
+
}
|