discord.js 15.0.0-dev.1746663224-f6da9495e → 15.0.0-dev.1746792317-4f6fedfb1
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 +3 -3
- package/src/managers/ChannelManager.js +7 -0
- package/src/managers/GuildManager.js +2 -2
- package/src/managers/GuildSoundboardSoundManager.js +40 -18
- package/src/structures/Guild.js +7 -0
- package/src/structures/SoundboardSound.js +4 -4
- package/typings/index.d.mts +8 -2
- package/typings/index.d.ts +8 -2
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.1746792317-4f6fedfb1",
|
|
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",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"@discordjs/builders": "^1.11.1",
|
|
65
65
|
"@discordjs/formatters": "^0.6.1",
|
|
66
66
|
"@discordjs/collection": "^2.1.1",
|
|
67
|
-
"@discordjs/util": "^1.1.1",
|
|
68
67
|
"@discordjs/rest": "^2.5.0",
|
|
68
|
+
"@discordjs/util": "^1.1.1",
|
|
69
69
|
"@discordjs/ws": "^2.0.2"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"tslint": "6.1.3",
|
|
87
87
|
"turbo": "^2.5.2",
|
|
88
88
|
"typescript": "~5.8.3",
|
|
89
|
-
"@discordjs/api-extractor": "^7.38.1",
|
|
90
89
|
"@discordjs/docgen": "^0.12.1",
|
|
90
|
+
"@discordjs/api-extractor": "^7.38.1",
|
|
91
91
|
"@discordjs/scripts": "^0.1.0"
|
|
92
92
|
},
|
|
93
93
|
"engines": {
|
|
@@ -73,6 +73,13 @@ class ChannelManager extends CachedManager {
|
|
|
73
73
|
|
|
74
74
|
channel?.parent?.threads?.cache.delete(id);
|
|
75
75
|
this.cache.delete(id);
|
|
76
|
+
|
|
77
|
+
if (channel?.threads) {
|
|
78
|
+
for (const threadId of channel.threads.cache.keys()) {
|
|
79
|
+
this.cache.delete(threadId);
|
|
80
|
+
channel.guild?.channels.cache.delete(threadId);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
76
83
|
}
|
|
77
84
|
|
|
78
85
|
/**
|
|
@@ -285,8 +285,8 @@ class GuildManager extends CachedManager {
|
|
|
285
285
|
|
|
286
286
|
/**
|
|
287
287
|
* @typedef {Object} FetchSoundboardSoundsOptions
|
|
288
|
-
* @
|
|
289
|
-
* @
|
|
288
|
+
* @property {Snowflake[]} guildIds The ids of the guilds to fetch soundboard sounds for
|
|
289
|
+
* @property {number} [time=10_000] The timeout for receipt of the soundboard sounds
|
|
290
290
|
*/
|
|
291
291
|
|
|
292
292
|
/**
|
|
@@ -105,7 +105,7 @@ class GuildSoundboardSoundManager extends CachedManager {
|
|
|
105
105
|
* Data for editing a soundboard sound.
|
|
106
106
|
* @typedef {Object} GuildSoundboardSoundEditOptions
|
|
107
107
|
* @property {string} [name] The name of the soundboard sound
|
|
108
|
-
* @property {?number} [volume] The volume of the soundboard sound, from 0 to 1
|
|
108
|
+
* @property {?number} [volume] The volume (a double) of the soundboard sound, from 0 (inclusive) to 1
|
|
109
109
|
* @property {?Snowflake} [emojiId] The emoji id of the soundboard sound
|
|
110
110
|
* @property {?string} [emojiName] The emoji name of the soundboard sound
|
|
111
111
|
* @property {string} [reason] The reason for editing the soundboard sound
|
|
@@ -157,35 +157,57 @@ class GuildSoundboardSoundManager extends CachedManager {
|
|
|
157
157
|
await this.client.rest.delete(Routes.guildSoundboardSound(this.guild.id, soundId), { reason });
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Options used to fetch a soundboard sound.
|
|
162
|
+
* @typedef {BaseFetchOptions} FetchSoundboardSoundOptions
|
|
163
|
+
* @property {SoundboardSoundResolvable} soundboardSound The soundboard sound to fetch
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Options used to fetch soundboard sounds from Discord
|
|
168
|
+
* @typedef {Object} FetchGuildSoundboardSoundsOptions
|
|
169
|
+
* @property {boolean} [cache] Whether to cache the fetched soundboard sounds
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
/* eslint-disable max-len */
|
|
160
173
|
/**
|
|
161
174
|
* Obtains one or more soundboard sounds from Discord, or the soundboard sound cache if they're already available.
|
|
162
|
-
* @param {
|
|
163
|
-
* @param {BaseFetchOptions} [options] Additional options for this fetch
|
|
175
|
+
* @param {SoundboardSoundResolvable|FetchSoundboardSoundOptions|FetchGuildSoundboardSoundsOptions} [options] Options for fetching soundboard sound(s)
|
|
164
176
|
* @returns {Promise<SoundboardSound|Collection<Snowflake, SoundboardSound>>}
|
|
165
177
|
* @example
|
|
166
|
-
* // Fetch all soundboard sounds from the guild
|
|
167
|
-
* guild.soundboardSounds.fetch()
|
|
168
|
-
* .then(sounds => console.log(`There are ${sounds.size} soundboard sounds.`))
|
|
169
|
-
* .catch(console.error);
|
|
170
|
-
* @example
|
|
171
178
|
* // Fetch a single soundboard sound
|
|
172
179
|
* guild.soundboardSounds.fetch('222078108977594368')
|
|
173
180
|
* .then(sound => console.log(`The soundboard sound name is: ${sound.name}`))
|
|
174
181
|
* .catch(console.error);
|
|
182
|
+
* @example
|
|
183
|
+
* // Fetch all soundboard sounds from the guild
|
|
184
|
+
* guild.soundboardSounds.fetch()
|
|
185
|
+
* .then(sounds => console.log(`There are ${sounds.size} soundboard sounds.`))
|
|
186
|
+
* .catch(console.error);
|
|
175
187
|
*/
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
188
|
+
/* eslint-enable max-len */
|
|
189
|
+
async fetch(options) {
|
|
190
|
+
if (!options) return this._fetchMany();
|
|
191
|
+
const { cache, force, soundboardSound } = options;
|
|
192
|
+
const resolvedSoundboardSound = this.resolveId(soundboardSound ?? options);
|
|
193
|
+
if (resolvedSoundboardSound) return this._fetchSingle({ cache, force, soundboardSound: resolvedSoundboardSound });
|
|
194
|
+
return this._fetchMany({ cache });
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async _fetchSingle({ cache, force, soundboardSound } = {}) {
|
|
198
|
+
if (!force) {
|
|
199
|
+
const existing = this.cache.get(soundboardSound);
|
|
200
|
+
if (existing) return existing;
|
|
185
201
|
}
|
|
186
202
|
|
|
203
|
+
const data = await this.client.rest.get(Routes.guildSoundboardSound(this.guild.id, soundboardSound));
|
|
204
|
+
return this._add(data, cache);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async _fetchMany({ cache } = {}) {
|
|
187
208
|
const data = await this.client.rest.get(Routes.guildSoundboardSounds(this.guild.id));
|
|
188
|
-
|
|
209
|
+
|
|
210
|
+
return data.items.reduce((coll, sound) => coll.set(sound.sound_id, this._add(sound, cache)), new Collection());
|
|
189
211
|
}
|
|
190
212
|
}
|
|
191
213
|
|
package/src/structures/Guild.js
CHANGED
|
@@ -489,6 +489,13 @@ class Guild extends AnonymousGuild {
|
|
|
489
489
|
} else {
|
|
490
490
|
this.incidentsData ??= null;
|
|
491
491
|
}
|
|
492
|
+
|
|
493
|
+
if (data.soundboard_sounds) {
|
|
494
|
+
this.soundboardSounds.cache.clear();
|
|
495
|
+
for (const soundboardSound of data.soundboard_sounds) {
|
|
496
|
+
this.soundboardSounds._add(soundboardSound);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
492
499
|
}
|
|
493
500
|
|
|
494
501
|
/**
|
|
@@ -181,8 +181,8 @@ class SoundboardSound extends Base {
|
|
|
181
181
|
this.available === other.available &&
|
|
182
182
|
this.name === other.name &&
|
|
183
183
|
this.volume === other.volume &&
|
|
184
|
-
this.
|
|
185
|
-
this.
|
|
184
|
+
this._emoji?.id === other._emoji?.id &&
|
|
185
|
+
this._emoji?.name === other._emoji?.name &&
|
|
186
186
|
this.guildId === other.guildId &&
|
|
187
187
|
this.user?.id === other.user?.id
|
|
188
188
|
);
|
|
@@ -193,8 +193,8 @@ class SoundboardSound extends Base {
|
|
|
193
193
|
this.available === other.available &&
|
|
194
194
|
this.name === other.name &&
|
|
195
195
|
this.volume === other.volume &&
|
|
196
|
-
this.
|
|
197
|
-
this.
|
|
196
|
+
(this._emoji?.id ?? null) === other.emoji_id &&
|
|
197
|
+
(this._emoji?.name ?? null) === other.emoji_name &&
|
|
198
198
|
this.guildId === other.guild_id &&
|
|
199
199
|
this.user?.id === other.user?.id
|
|
200
200
|
);
|
package/typings/index.d.mts
CHANGED
|
@@ -4290,8 +4290,15 @@ export interface GuildSoundboardSoundEditOptions {
|
|
|
4290
4290
|
volume?: number | null;
|
|
4291
4291
|
emojiId?: Snowflake | null;
|
|
4292
4292
|
emojiName?: string | null;
|
|
4293
|
+
reason?: string;
|
|
4294
|
+
}
|
|
4295
|
+
|
|
4296
|
+
export interface FetchGuildSoundboardSoundOptions extends BaseFetchOptions {
|
|
4297
|
+
soundboardSound: SoundboardSoundResolvable;
|
|
4293
4298
|
}
|
|
4294
4299
|
|
|
4300
|
+
export interface FetchGuildSoundboardSoundsOptions extends Pick<BaseFetchOptions, 'cache'> {}
|
|
4301
|
+
|
|
4295
4302
|
export class GuildSoundboardSoundManager extends CachedManager<Snowflake, SoundboardSound, SoundboardSoundResolvable> {
|
|
4296
4303
|
private constructor(guild: Guild, iterable?: Iterable<APISoundboardSound>);
|
|
4297
4304
|
public guild: Guild;
|
|
@@ -5804,8 +5811,7 @@ export interface GuildAuditLogsEntryTargetField<TAction extends AuditLogEvent> {
|
|
|
5804
5811
|
ApplicationCommand: ApplicationCommand | { id: Snowflake };
|
|
5805
5812
|
AutoModeration: AutoModerationRule;
|
|
5806
5813
|
GuildOnboardingPrompt: GuildOnboardingPrompt | { id: Snowflake; [x: string]: unknown };
|
|
5807
|
-
|
|
5808
|
-
SoundboardSound: { id: Snowflake };
|
|
5814
|
+
SoundboardSound: SoundboardSound | { id: Snowflake };
|
|
5809
5815
|
}
|
|
5810
5816
|
|
|
5811
5817
|
export interface GuildAuditLogsFetchOptions<Event extends GuildAuditLogsResolvable> {
|
package/typings/index.d.ts
CHANGED
|
@@ -4290,8 +4290,15 @@ export interface GuildSoundboardSoundEditOptions {
|
|
|
4290
4290
|
volume?: number | null;
|
|
4291
4291
|
emojiId?: Snowflake | null;
|
|
4292
4292
|
emojiName?: string | null;
|
|
4293
|
+
reason?: string;
|
|
4294
|
+
}
|
|
4295
|
+
|
|
4296
|
+
export interface FetchGuildSoundboardSoundOptions extends BaseFetchOptions {
|
|
4297
|
+
soundboardSound: SoundboardSoundResolvable;
|
|
4293
4298
|
}
|
|
4294
4299
|
|
|
4300
|
+
export interface FetchGuildSoundboardSoundsOptions extends Pick<BaseFetchOptions, 'cache'> {}
|
|
4301
|
+
|
|
4295
4302
|
export class GuildSoundboardSoundManager extends CachedManager<Snowflake, SoundboardSound, SoundboardSoundResolvable> {
|
|
4296
4303
|
private constructor(guild: Guild, iterable?: Iterable<APISoundboardSound>);
|
|
4297
4304
|
public guild: Guild;
|
|
@@ -5804,8 +5811,7 @@ export interface GuildAuditLogsEntryTargetField<TAction extends AuditLogEvent> {
|
|
|
5804
5811
|
ApplicationCommand: ApplicationCommand | { id: Snowflake };
|
|
5805
5812
|
AutoModeration: AutoModerationRule;
|
|
5806
5813
|
GuildOnboardingPrompt: GuildOnboardingPrompt | { id: Snowflake; [x: string]: unknown };
|
|
5807
|
-
|
|
5808
|
-
SoundboardSound: { id: Snowflake };
|
|
5814
|
+
SoundboardSound: SoundboardSound | { id: Snowflake };
|
|
5809
5815
|
}
|
|
5810
5816
|
|
|
5811
5817
|
export interface GuildAuditLogsFetchOptions<Event extends GuildAuditLogsResolvable> {
|