discord.js 15.0.0-dev.1752711321-1dfc511e4 → 15.0.0-dev.1752797696-43a995bef
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/package.json +5 -5
- package/src/client/Client.js +8 -5
- package/src/client/websocket/handlers/INVITE_CREATE.js +1 -1
- package/src/client/websocket/handlers/INVITE_DELETE.js +3 -3
- package/src/index.js +3 -1
- package/src/managers/GuildInviteManager.js +24 -14
- package/src/managers/GuildManager.js +3 -3
- package/src/structures/BaseInvite.js +187 -0
- package/src/structures/GroupDMInvite.js +37 -0
- package/src/structures/GuildAuditLogsEntry.js +2 -2
- package/src/structures/GuildInvite.js +211 -0
- package/src/util/DataResolver.js +2 -2
- package/src/util/Invites.js +31 -0
- package/typings/index.d.mts +67 -47
- package/typings/index.d.ts +67 -47
- package/src/structures/Invite.js +0 -345
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "discord.js",
|
|
4
|
-
"version": "15.0.0-dev.
|
|
4
|
+
"version": "15.0.0-dev.1752797696-43a995bef",
|
|
5
5
|
"description": "A powerful library for interacting with the Discord API",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"types": "./typings/index.d.ts",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"undici": "7.11.0",
|
|
64
64
|
"@discordjs/builders": "^1.11.1",
|
|
65
65
|
"@discordjs/collection": "^2.1.1",
|
|
66
|
-
"@discordjs/formatters": "^0.6.1",
|
|
67
66
|
"@discordjs/rest": "^2.5.0",
|
|
67
|
+
"@discordjs/util": "^1.1.1",
|
|
68
68
|
"@discordjs/ws": "^2.0.2",
|
|
69
|
-
"@discordjs/
|
|
69
|
+
"@discordjs/formatters": "^0.6.1"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@favware/cliff-jumper": "^4.1.0",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"turbo": "^2.5.4",
|
|
84
84
|
"typescript": "~5.8.3",
|
|
85
85
|
"@discordjs/api-extractor": "^7.52.7",
|
|
86
|
-
"@discordjs/
|
|
87
|
-
"@discordjs/
|
|
86
|
+
"@discordjs/scripts": "^0.1.0",
|
|
87
|
+
"@discordjs/docgen": "^0.12.1"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=22.12.0"
|
package/src/client/Client.js
CHANGED
|
@@ -14,7 +14,6 @@ const { ShardClientUtil } = require('../sharding/ShardClientUtil.js');
|
|
|
14
14
|
const { ClientPresence } = require('../structures/ClientPresence.js');
|
|
15
15
|
const { GuildPreview } = require('../structures/GuildPreview.js');
|
|
16
16
|
const { GuildTemplate } = require('../structures/GuildTemplate.js');
|
|
17
|
-
const { Invite } = require('../structures/Invite.js');
|
|
18
17
|
const { SoundboardSound } = require('../structures/SoundboardSound.js');
|
|
19
18
|
const { Sticker } = require('../structures/Sticker.js');
|
|
20
19
|
const { StickerPack } = require('../structures/StickerPack.js');
|
|
@@ -24,6 +23,7 @@ const { Widget } = require('../structures/Widget.js');
|
|
|
24
23
|
const { resolveInviteCode, resolveGuildTemplateCode } = require('../util/DataResolver.js');
|
|
25
24
|
const { Events } = require('../util/Events.js');
|
|
26
25
|
const { IntentsBitField } = require('../util/IntentsBitField.js');
|
|
26
|
+
const { createInvite } = require('../util/Invites.js');
|
|
27
27
|
const { Options } = require('../util/Options.js');
|
|
28
28
|
const { PermissionsBitField } = require('../util/PermissionsBitField.js');
|
|
29
29
|
const { Status } = require('../util/Status.js');
|
|
@@ -459,6 +459,7 @@ class Client extends BaseClient {
|
|
|
459
459
|
* Options used when fetching an invite from Discord.
|
|
460
460
|
*
|
|
461
461
|
* @typedef {Object} ClientFetchInviteOptions
|
|
462
|
+
* @property {boolean} [withCounts] Whether to include approximate member counts
|
|
462
463
|
* @property {Snowflake} [guildScheduledEventId] The id of the guild scheduled event to include with
|
|
463
464
|
* the invite
|
|
464
465
|
*/
|
|
@@ -474,14 +475,16 @@ class Client extends BaseClient {
|
|
|
474
475
|
* .then(invite => console.log(`Obtained invite with code: ${invite.code}`))
|
|
475
476
|
* .catch(console.error);
|
|
476
477
|
*/
|
|
477
|
-
async fetchInvite(invite,
|
|
478
|
+
async fetchInvite(invite, { withCounts, guildScheduledEventId } = {}) {
|
|
478
479
|
const code = resolveInviteCode(invite);
|
|
480
|
+
|
|
479
481
|
const query = makeURLSearchParams({
|
|
480
|
-
with_counts:
|
|
481
|
-
guild_scheduled_event_id:
|
|
482
|
+
with_counts: withCounts,
|
|
483
|
+
guild_scheduled_event_id: guildScheduledEventId,
|
|
482
484
|
});
|
|
485
|
+
|
|
483
486
|
const data = await this.rest.get(Routes.invite(code), { query });
|
|
484
|
-
return
|
|
487
|
+
return createInvite(this, data);
|
|
485
488
|
}
|
|
486
489
|
|
|
487
490
|
/**
|
|
@@ -15,7 +15,7 @@ module.exports = (client, { d: data }) => {
|
|
|
15
15
|
* <info>This event requires the {@link PermissionFlagsBits.ManageChannels} permission for the channel.</info>
|
|
16
16
|
*
|
|
17
17
|
* @event Client#inviteCreate
|
|
18
|
-
* @param {
|
|
18
|
+
* @param {GuildInvite} invite The invite that was created
|
|
19
19
|
*/
|
|
20
20
|
client.emit(Events.InviteCreate, invite);
|
|
21
21
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { GuildInvite } = require('../../../structures/GuildInvite.js');
|
|
4
4
|
const { Events } = require('../../../util/Events.js');
|
|
5
5
|
|
|
6
6
|
module.exports = (client, { d: data }) => {
|
|
@@ -9,7 +9,7 @@ module.exports = (client, { d: data }) => {
|
|
|
9
9
|
if (!channel) return;
|
|
10
10
|
|
|
11
11
|
const inviteData = Object.assign(data, { channel, guild });
|
|
12
|
-
const invite = new
|
|
12
|
+
const invite = new GuildInvite(client, inviteData);
|
|
13
13
|
|
|
14
14
|
guild.invites.cache.delete(invite.code);
|
|
15
15
|
|
|
@@ -18,7 +18,7 @@ module.exports = (client, { d: data }) => {
|
|
|
18
18
|
* <info>This event requires the {@link PermissionFlagsBits.ManageChannels} permission for the channel.</info>
|
|
19
19
|
*
|
|
20
20
|
* @event Client#inviteDelete
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {GuildInvite} invite The invite that was deleted
|
|
22
22
|
*/
|
|
23
23
|
client.emit(Events.InviteDelete, invite);
|
|
24
24
|
};
|
package/src/index.js
CHANGED
|
@@ -124,6 +124,7 @@ exports.BaseGuildEmoji = require('./structures/BaseGuildEmoji.js').BaseGuildEmoj
|
|
|
124
124
|
exports.BaseGuildTextChannel = require('./structures/BaseGuildTextChannel.js').BaseGuildTextChannel;
|
|
125
125
|
exports.BaseGuildVoiceChannel = require('./structures/BaseGuildVoiceChannel.js').BaseGuildVoiceChannel;
|
|
126
126
|
exports.BaseInteraction = require('./structures/BaseInteraction.js').BaseInteraction;
|
|
127
|
+
exports.BaseInvite = require('./structures/BaseInvite.js').BaseInvite;
|
|
127
128
|
exports.BaseSelectMenuComponent = require('./structures/BaseSelectMenuComponent.js').BaseSelectMenuComponent;
|
|
128
129
|
exports.ButtonComponent = require('./structures/ButtonComponent.js').ButtonComponent;
|
|
129
130
|
exports.ButtonInteraction = require('./structures/ButtonInteraction.js').ButtonInteraction;
|
|
@@ -151,12 +152,14 @@ exports.Emoji = require('./structures/Emoji.js').Emoji;
|
|
|
151
152
|
exports.Entitlement = require('./structures/Entitlement.js').Entitlement;
|
|
152
153
|
exports.FileComponent = require('./structures/FileComponent.js').FileComponent;
|
|
153
154
|
exports.ForumChannel = require('./structures/ForumChannel.js').ForumChannel;
|
|
155
|
+
exports.GroupDMInvite = require('./structures/GroupDMInvite.js').GroupDMInvite;
|
|
154
156
|
exports.Guild = require('./structures/Guild.js').Guild;
|
|
155
157
|
exports.GuildAuditLogs = require('./structures/GuildAuditLogs.js').GuildAuditLogs;
|
|
156
158
|
exports.GuildAuditLogsEntry = require('./structures/GuildAuditLogsEntry.js').GuildAuditLogsEntry;
|
|
157
159
|
exports.GuildBan = require('./structures/GuildBan.js').GuildBan;
|
|
158
160
|
exports.GuildChannel = require('./structures/GuildChannel.js').GuildChannel;
|
|
159
161
|
exports.GuildEmoji = require('./structures/GuildEmoji.js').GuildEmoji;
|
|
162
|
+
exports.GuildInvite = require('./structures/GuildInvite.js').GuildInvite;
|
|
160
163
|
exports.GuildMember = require('./structures/GuildMember.js').GuildMember;
|
|
161
164
|
exports.GuildOnboarding = require('./structures/GuildOnboarding.js').GuildOnboarding;
|
|
162
165
|
exports.GuildOnboardingPrompt = require('./structures/GuildOnboardingPrompt.js').GuildOnboardingPrompt;
|
|
@@ -175,7 +178,6 @@ exports.InteractionCallbackResponse =
|
|
|
175
178
|
require('./structures/InteractionCallbackResponse.js').InteractionCallbackResponse;
|
|
176
179
|
exports.InteractionCollector = require('./structures/InteractionCollector.js').InteractionCollector;
|
|
177
180
|
exports.InteractionWebhook = require('./structures/InteractionWebhook.js').InteractionWebhook;
|
|
178
|
-
exports.Invite = require('./structures/Invite.js').Invite;
|
|
179
181
|
exports.InviteGuild = require('./structures/InviteGuild.js').InviteGuild;
|
|
180
182
|
exports.MediaChannel = require('./structures/MediaChannel.js').MediaChannel;
|
|
181
183
|
exports.MediaGalleryComponent = require('./structures/MediaGalleryComponent.js').MediaGalleryComponent;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { Collection } = require('@discordjs/collection');
|
|
4
4
|
const { Routes } = require('discord-api-types/v10');
|
|
5
5
|
const { DiscordjsError, ErrorCodes } = require('../errors/index.js');
|
|
6
|
-
const {
|
|
6
|
+
const { GuildInvite } = require('../structures/GuildInvite.js');
|
|
7
7
|
const { resolveInviteCode } = require('../util/DataResolver.js');
|
|
8
8
|
const { CachedManager } = require('./CachedManager.js');
|
|
9
9
|
|
|
@@ -14,7 +14,7 @@ const { CachedManager } = require('./CachedManager.js');
|
|
|
14
14
|
*/
|
|
15
15
|
class GuildInviteManager extends CachedManager {
|
|
16
16
|
constructor(guild, iterable) {
|
|
17
|
-
super(guild.client,
|
|
17
|
+
super(guild.client, GuildInvite, iterable);
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* The guild this Manager belongs to
|
|
@@ -27,7 +27,7 @@ class GuildInviteManager extends CachedManager {
|
|
|
27
27
|
/**
|
|
28
28
|
* The cache of this Manager
|
|
29
29
|
*
|
|
30
|
-
* @type {Collection<string,
|
|
30
|
+
* @type {Collection<string, GuildInvite>}
|
|
31
31
|
* @name GuildInviteManager#cache
|
|
32
32
|
*/
|
|
33
33
|
|
|
@@ -36,35 +36,44 @@ class GuildInviteManager extends CachedManager {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* Data that resolves to give
|
|
39
|
+
* Data that resolves to give a `GuildInvite`. This can be:
|
|
40
|
+
*
|
|
40
41
|
* - An invite code
|
|
41
42
|
* - An invite URL
|
|
42
43
|
*
|
|
43
|
-
* @typedef {string}
|
|
44
|
+
* @typedef {string} GuildInviteResolvable
|
|
44
45
|
*/
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
|
-
*
|
|
48
|
+
* A guild channel where an invite may be created on. This can be:
|
|
48
49
|
* - TextChannel
|
|
49
50
|
* - VoiceChannel
|
|
50
51
|
* - AnnouncementChannel
|
|
51
52
|
* - StageChannel
|
|
52
53
|
* - ForumChannel
|
|
53
54
|
* - MediaChannel
|
|
55
|
+
*
|
|
56
|
+
* @typedef {TextChannel|VoiceChannel|AnnouncementChannel|StageChannel|ForumChannel|MediaChannel}
|
|
57
|
+
* GuildInvitableChannel
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Data that can be resolved to a guild channel where an invite may be created on. This can be:
|
|
62
|
+
* - GuildInvitableChannel
|
|
54
63
|
* - Snowflake
|
|
55
64
|
*
|
|
56
|
-
* @typedef {
|
|
65
|
+
* @typedef {GuildInvitableChannel|Snowflake}
|
|
57
66
|
* GuildInvitableChannelResolvable
|
|
58
67
|
*/
|
|
59
68
|
|
|
60
69
|
/**
|
|
61
|
-
* Resolves an
|
|
70
|
+
* Resolves an `GuildInviteResolvable` to a `GuildInvite` object.
|
|
62
71
|
*
|
|
63
72
|
* @method resolve
|
|
64
73
|
* @memberof GuildInviteManager
|
|
65
74
|
* @instance
|
|
66
|
-
* @param {
|
|
67
|
-
* @returns {?
|
|
75
|
+
* @param {GuildInviteResolvable} invite The invite resolvable to resolve
|
|
76
|
+
* @returns {?GuildInvite}
|
|
68
77
|
*/
|
|
69
78
|
|
|
70
79
|
/**
|
|
@@ -98,8 +107,9 @@ class GuildInviteManager extends CachedManager {
|
|
|
98
107
|
/**
|
|
99
108
|
* Fetches invite(s) from Discord.
|
|
100
109
|
*
|
|
101
|
-
* @param {
|
|
102
|
-
*
|
|
110
|
+
* @param {GuildInviteResolvable|FetchInviteOptions|FetchInvitesOptions} [options]
|
|
111
|
+
* Options for fetching guild invite(s)
|
|
112
|
+
* @returns {Promise<GuildInvite|Collection<string, GuildInvite>>}
|
|
103
113
|
* @example
|
|
104
114
|
* // Fetch all invites from a guild
|
|
105
115
|
* guild.invites.fetch()
|
|
@@ -183,7 +193,7 @@ class GuildInviteManager extends CachedManager {
|
|
|
183
193
|
*
|
|
184
194
|
* @param {GuildInvitableChannelResolvable} channel The options for creating the invite from a channel.
|
|
185
195
|
* @param {InviteCreateOptions} [options={}] The options for creating the invite from a channel.
|
|
186
|
-
* @returns {Promise<
|
|
196
|
+
* @returns {Promise<GuildInvite>}
|
|
187
197
|
* @example
|
|
188
198
|
* // Create an invite to a selected channel
|
|
189
199
|
* guild.invites.create('599942732013764608')
|
|
@@ -209,7 +219,7 @@ class GuildInviteManager extends CachedManager {
|
|
|
209
219
|
},
|
|
210
220
|
reason,
|
|
211
221
|
});
|
|
212
|
-
return new
|
|
222
|
+
return new GuildInvite(this.client, invite);
|
|
213
223
|
}
|
|
214
224
|
|
|
215
225
|
/**
|
|
@@ -10,8 +10,8 @@ const { ShardClientUtil } = require('../sharding/ShardClientUtil.js');
|
|
|
10
10
|
const { Guild } = require('../structures/Guild.js');
|
|
11
11
|
const { GuildChannel } = require('../structures/GuildChannel.js');
|
|
12
12
|
const { GuildEmoji } = require('../structures/GuildEmoji.js');
|
|
13
|
+
const { GuildInvite } = require('../structures/GuildInvite.js');
|
|
13
14
|
const { GuildMember } = require('../structures/GuildMember.js');
|
|
14
|
-
const { Invite } = require('../structures/Invite.js');
|
|
15
15
|
const { OAuth2Guild } = require('../structures/OAuth2Guild.js');
|
|
16
16
|
const { Role } = require('../structures/Role.js');
|
|
17
17
|
const { resolveImage } = require('../util/DataResolver.js');
|
|
@@ -119,7 +119,7 @@ class GuildManager extends CachedManager {
|
|
|
119
119
|
guild instanceof GuildMember ||
|
|
120
120
|
guild instanceof GuildEmoji ||
|
|
121
121
|
guild instanceof Role ||
|
|
122
|
-
(guild instanceof
|
|
122
|
+
(guild instanceof GuildInvite && guild.guild)
|
|
123
123
|
) {
|
|
124
124
|
return super.resolve(guild.guild);
|
|
125
125
|
}
|
|
@@ -142,7 +142,7 @@ class GuildManager extends CachedManager {
|
|
|
142
142
|
guild instanceof GuildMember ||
|
|
143
143
|
guild instanceof GuildEmoji ||
|
|
144
144
|
guild instanceof Role ||
|
|
145
|
-
(guild instanceof
|
|
145
|
+
(guild instanceof GuildInvite && guild.guild)
|
|
146
146
|
) {
|
|
147
147
|
return super.resolveId(guild.guild.id);
|
|
148
148
|
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { RouteBases } = require('discord-api-types/v10');
|
|
4
|
+
const { Base } = require('./Base.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The base invite class.
|
|
8
|
+
*
|
|
9
|
+
* @extends {Base}
|
|
10
|
+
*/
|
|
11
|
+
class BaseInvite extends Base {
|
|
12
|
+
constructor(client, data) {
|
|
13
|
+
super(client);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The type of this invite.
|
|
17
|
+
*
|
|
18
|
+
* @type {InviteType}
|
|
19
|
+
*/
|
|
20
|
+
this.type = data.type;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The invite code.
|
|
24
|
+
*
|
|
25
|
+
* @type {string}
|
|
26
|
+
*/
|
|
27
|
+
this.code = data.code;
|
|
28
|
+
|
|
29
|
+
this._patch(data);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_patch(data) {
|
|
33
|
+
if ('inviter_id' in data) {
|
|
34
|
+
/**
|
|
35
|
+
* The id of the user that created this invite.
|
|
36
|
+
*
|
|
37
|
+
* @type {?Snowflake}
|
|
38
|
+
*/
|
|
39
|
+
this.inviterId = data.inviter_id;
|
|
40
|
+
} else {
|
|
41
|
+
this.inviterId ??= null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if ('inviter' in data) {
|
|
45
|
+
this.client.users._add(data.inviter);
|
|
46
|
+
this.inviterId ??= data.inviter.id;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if ('max_age' in data) {
|
|
50
|
+
/**
|
|
51
|
+
* The maximum age of the invite in seconds. `0` for no expiry.
|
|
52
|
+
*
|
|
53
|
+
* @type {?number}
|
|
54
|
+
*/
|
|
55
|
+
this.maxAge = data.max_age;
|
|
56
|
+
} else {
|
|
57
|
+
this.maxAge ??= null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if ('created_at' in data) {
|
|
61
|
+
/**
|
|
62
|
+
* The timestamp this invite was created at.
|
|
63
|
+
*
|
|
64
|
+
* @type {?number}
|
|
65
|
+
*/
|
|
66
|
+
this.createdTimestamp = Date.parse(data.created_at);
|
|
67
|
+
} else {
|
|
68
|
+
this.createdTimestamp ??= null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if ('expires_at' in data) {
|
|
72
|
+
this._expiresTimestamp = data.expires_at && Date.parse(data.expires_at);
|
|
73
|
+
} else {
|
|
74
|
+
this._expiresTimestamp ??= null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if ('channel_id' in data) {
|
|
78
|
+
/**
|
|
79
|
+
* The id of the channel this invite is for.
|
|
80
|
+
*
|
|
81
|
+
* @type {?Snowflake}
|
|
82
|
+
*/
|
|
83
|
+
this.channelId = data.channel_id;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if ('approximate_member_count' in data) {
|
|
87
|
+
/**
|
|
88
|
+
* The approximate total number of members.
|
|
89
|
+
*
|
|
90
|
+
* @type {?number}
|
|
91
|
+
*/
|
|
92
|
+
this.approximateMemberCount = data.approximate_member_count;
|
|
93
|
+
} else {
|
|
94
|
+
this.approximateMemberCount ??= null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The user that created this invite.
|
|
100
|
+
*
|
|
101
|
+
* @type {?User}
|
|
102
|
+
* @readonly
|
|
103
|
+
*/
|
|
104
|
+
get inviter() {
|
|
105
|
+
return this.inviterId && this.client.users.resolve(this.inviterId);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The creation date of this invite.
|
|
110
|
+
*
|
|
111
|
+
* @type {?Date}
|
|
112
|
+
* @readonly
|
|
113
|
+
*/
|
|
114
|
+
get createdAt() {
|
|
115
|
+
return this.createdTimestamp && new Date(this.createdTimestamp);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The timestamp this invite expires at.
|
|
120
|
+
*
|
|
121
|
+
* @type {?number}
|
|
122
|
+
* @readonly
|
|
123
|
+
*/
|
|
124
|
+
get expiresTimestamp() {
|
|
125
|
+
return (
|
|
126
|
+
this._expiresTimestamp ??
|
|
127
|
+
(this.createdTimestamp && this.maxAge ? this.createdTimestamp + this.maxAge * 1_000 : null)
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The expiry date of this invite.
|
|
133
|
+
*
|
|
134
|
+
* @type {?Date}
|
|
135
|
+
* @readonly
|
|
136
|
+
*/
|
|
137
|
+
get expiresAt() {
|
|
138
|
+
return this.expiresTimestamp && new Date(this.expiresTimestamp);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The URL to the invite.
|
|
143
|
+
*
|
|
144
|
+
* @type {string}
|
|
145
|
+
* @readonly
|
|
146
|
+
*/
|
|
147
|
+
get url() {
|
|
148
|
+
return `${RouteBases.invite}/${this.code}`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* A regular expression that matches Discord invite links.
|
|
153
|
+
* The `code` group property is present on the `exec()` result of this expression.
|
|
154
|
+
*
|
|
155
|
+
* @type {RegExp}
|
|
156
|
+
* @memberof BaseInvite
|
|
157
|
+
*/
|
|
158
|
+
static InvitesPattern = /discord(?:(?:app)?\.com\/invite|\.gg(?:\/invite)?)\/(?<code>[\w-]{2,255})/i;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* When concatenated with a string, this automatically concatenates the invite's URL instead of the object.
|
|
162
|
+
*
|
|
163
|
+
* @returns {string}
|
|
164
|
+
* @example
|
|
165
|
+
* // Logs: Invite: https://discord.gg/djs
|
|
166
|
+
* console.log(`Invite: ${invite}`);
|
|
167
|
+
*/
|
|
168
|
+
toString() {
|
|
169
|
+
return this.url;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
toJSON() {
|
|
173
|
+
return super.toJSON({
|
|
174
|
+
url: true,
|
|
175
|
+
expiresTimestamp: true,
|
|
176
|
+
uses: false,
|
|
177
|
+
channel: 'channelId',
|
|
178
|
+
inviter: 'inviterId',
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
valueOf() {
|
|
183
|
+
return this.code;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
exports.BaseInvite = BaseInvite;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { BaseInvite } = require('./BaseInvite.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A channel invite leading to a group direct message channel.
|
|
7
|
+
*
|
|
8
|
+
* @extends {BaseInvite}
|
|
9
|
+
*/
|
|
10
|
+
class GroupDMInvite extends BaseInvite {
|
|
11
|
+
/**
|
|
12
|
+
* The approximate total number of members of in the group direct message channel.
|
|
13
|
+
* <info>This is only available when the invite was fetched through {@link Client#fetchInvite}.</info>
|
|
14
|
+
*
|
|
15
|
+
* @name GroupDMInvite#approximateMemberCount
|
|
16
|
+
* @type {?number}
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
_patch(data) {
|
|
20
|
+
super._patch(data);
|
|
21
|
+
|
|
22
|
+
if ('channel' in data) {
|
|
23
|
+
/**
|
|
24
|
+
* The channel this invite is for.
|
|
25
|
+
*
|
|
26
|
+
* @type {?PartialGroupDMChannel}
|
|
27
|
+
*/
|
|
28
|
+
this.channel =
|
|
29
|
+
this.client.channels._add(data.channel, null, { cache: false }) ??
|
|
30
|
+
this.client.channels.cache.get(this.channelId);
|
|
31
|
+
|
|
32
|
+
this.channelId ??= data.channel.id;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.GroupDMInvite = GroupDMInvite;
|
|
@@ -5,10 +5,10 @@ const { AuditLogOptionsType, AuditLogEvent } = require('discord-api-types/v10');
|
|
|
5
5
|
const { Partials } = require('../util/Partials.js');
|
|
6
6
|
const { flatten } = require('../util/Util.js');
|
|
7
7
|
const { AutoModerationRule } = require('./AutoModerationRule.js');
|
|
8
|
+
const { GuildInvite } = require('./GuildInvite.js');
|
|
8
9
|
const { GuildOnboardingPrompt } = require('./GuildOnboardingPrompt.js');
|
|
9
10
|
const { GuildScheduledEvent } = require('./GuildScheduledEvent.js');
|
|
10
11
|
const { Integration } = require('./Integration.js');
|
|
11
|
-
const { Invite } = require('./Invite.js');
|
|
12
12
|
const { StageInstance } = require('./StageInstance.js');
|
|
13
13
|
const { Sticker } = require('./Sticker.js');
|
|
14
14
|
const { Webhook } = require('./Webhook.js');
|
|
@@ -337,7 +337,7 @@ class GuildAuditLogsEntry {
|
|
|
337
337
|
|
|
338
338
|
this.target =
|
|
339
339
|
guild.invites.cache.get(inviteChange.new ?? inviteChange.old) ??
|
|
340
|
-
new
|
|
340
|
+
new GuildInvite(guild.client, changesReduce(this.changes, { guild }));
|
|
341
341
|
} else if (targetType === Targets.Message) {
|
|
342
342
|
// Discord sends a channel id for the MessageBulkDelete action type.
|
|
343
343
|
this.target =
|