discord.js 15.0.0-dev.1735949500-28a250384 → 15.0.0-dev.1736078675-28126cd37

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 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.1735949500-28a250384",
4
+ "version": "15.0.0-dev.1736078675-28126cd37",
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",
@@ -62,8 +62,8 @@
62
62
  "undici": "6.21.0",
63
63
  "@discordjs/formatters": "^0.5.0",
64
64
  "@discordjs/rest": "^2.4.0",
65
- "@discordjs/util": "^1.1.1",
66
- "@discordjs/ws": "^2.0.0"
65
+ "@discordjs/ws": "^2.0.0",
66
+ "@discordjs/util": "^1.1.1"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@favware/cliff-jumper": "^4.1.0",
@@ -81,8 +81,8 @@
81
81
  "turbo": "^2.3.3",
82
82
  "typescript": "~5.5.4",
83
83
  "@discordjs/api-extractor": "^7.38.1",
84
- "@discordjs/scripts": "^0.1.0",
85
- "@discordjs/docgen": "^0.12.1"
84
+ "@discordjs/docgen": "^0.12.1",
85
+ "@discordjs/scripts": "^0.1.0"
86
86
  },
87
87
  "engines": {
88
88
  "node": ">=20"
@@ -105,12 +105,19 @@ class GuildChannelManager extends CachedManager {
105
105
  * @typedef {AnnouncementChannel|Snowflake} AnnouncementChannelResolvable
106
106
  */
107
107
 
108
+ /**
109
+ * Represents the followed channel data.
110
+ * @typedef {Object} FollowedChannelData
111
+ * @property {Snowflake} channelId Source channel id
112
+ * @property {Snowflake} webhookId Created webhook id in the target channel
113
+ */
114
+
108
115
  /**
109
116
  * Adds the target channel to a channel's followers.
110
117
  * @param {AnnouncementChannelResolvable} channel The channel to follow
111
118
  * @param {TextChannelResolvable} targetChannel The channel where published announcements will be posted at
112
119
  * @param {string} [reason] Reason for creating the webhook
113
- * @returns {Promise<Snowflake>} Returns created target webhook id.
120
+ * @returns {Promise<FollowedChannelData>} Returns the data for the followed channel
114
121
  */
115
122
  async addFollower(channel, targetChannel, reason) {
116
123
  const channelId = this.resolveId(channel);
@@ -121,11 +128,11 @@ class GuildChannelManager extends CachedManager {
121
128
  if (!targetChannelId) {
122
129
  throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'targetChannel', 'TextChannelResolvable');
123
130
  }
124
- const { webhook_id } = await this.client.rest.post(Routes.channelFollowers(channelId), {
131
+ const data = await this.client.rest.post(Routes.channelFollowers(channelId), {
125
132
  body: { webhook_channel_id: targetChannelId },
126
133
  reason,
127
134
  });
128
- return webhook_id;
135
+ return { channelId: data.channel_id, webhookId: data.webhook_id };
129
136
  }
130
137
 
131
138
  /**
@@ -1,8 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { Routes } = require('discord-api-types/v10');
4
3
  const BaseGuildTextChannel = require('./BaseGuildTextChannel');
5
- const { DiscordjsError, ErrorCodes } = require('../errors');
6
4
 
7
5
  /**
8
6
  * Represents a guild announcement channel on Discord.
@@ -13,7 +11,7 @@ class AnnouncementChannel extends BaseGuildTextChannel {
13
11
  * Adds the target to this channel's followers.
14
12
  * @param {TextChannelResolvable} channel The channel where the webhook should be created
15
13
  * @param {string} [reason] Reason for creating the webhook
16
- * @returns {Promise<AnnouncementChannel>}
14
+ * @returns {Promise<FollowedChannelData>} Returns the data for the followed channel
17
15
  * @example
18
16
  * if (channel.type === ChannelType.GuildAnnouncement) {
19
17
  * channel.addFollower('222197033908436994', 'Important announcements')
@@ -22,10 +20,7 @@ class AnnouncementChannel extends BaseGuildTextChannel {
22
20
  * }
23
21
  */
24
22
  async addFollower(channel, reason) {
25
- const channelId = this.guild.channels.resolveId(channel);
26
- if (!channelId) throw new DiscordjsError(ErrorCodes.GuildChannelResolve);
27
- await this.client.rest.post(Routes.channelFollowers(this.id), { body: { webhook_channel_id: channelId }, reason });
28
- return this;
23
+ return this.guild.channels.addFollower(this, channel, reason);
29
24
  }
30
25
  }
31
26
 
@@ -563,7 +563,7 @@ class Message extends Base {
563
563
  */
564
564
  get cleanContent() {
565
565
  // eslint-disable-next-line eqeqeq
566
- return this.content != null ? cleanContent(this.content, this.channel) : null;
566
+ return this.content != null && this.channel ? cleanContent(this.content, this.channel) : null;
567
567
  }
568
568
 
569
569
  /**
@@ -2585,7 +2585,7 @@ export class ModalSubmitInteraction<Cached extends CacheType = CacheType> extend
2585
2585
  export class AnnouncementChannel extends BaseGuildTextChannel {
2586
2586
  public threads: GuildTextThreadManager<AllowedThreadTypeForAnnouncementChannel>;
2587
2587
  public type: ChannelType.GuildAnnouncement;
2588
- public addFollower(channel: TextChannelResolvable, reason?: string): Promise<AnnouncementChannel>;
2588
+ public addFollower(channel: TextChannelResolvable, reason?: string): Promise<FollowedChannelData>;
2589
2589
  }
2590
2590
 
2591
2591
  export type AnnouncementChannelResolvable = AnnouncementChannel | Snowflake;
@@ -4210,6 +4210,11 @@ export class GuildApplicationCommandManager extends ApplicationCommandManager<Ap
4210
4210
  public set(commands: readonly ApplicationCommandDataResolvable[]): Promise<Collection<Snowflake, ApplicationCommand>>;
4211
4211
  }
4212
4212
 
4213
+ export interface FollowedChannelData {
4214
+ channelId: Snowflake;
4215
+ webhookId: Snowflake;
4216
+ }
4217
+
4213
4218
  export type MappedGuildChannelTypes = {
4214
4219
  [ChannelType.GuildCategory]: CategoryChannel;
4215
4220
  } & MappedChannelCategoryTypes;
@@ -4225,7 +4230,7 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
4225
4230
  channel: AnnouncementChannelResolvable,
4226
4231
  targetChannel: TextChannelResolvable,
4227
4232
  reason?: string,
4228
- ): Promise<Snowflake>;
4233
+ ): Promise<FollowedChannelData>;
4229
4234
  public create<Type extends GuildChannelTypes>(
4230
4235
  options: GuildChannelCreateOptions & { type: Type },
4231
4236
  ): Promise<MappedGuildChannelTypes[Type]>;
@@ -2585,7 +2585,7 @@ export class ModalSubmitInteraction<Cached extends CacheType = CacheType> extend
2585
2585
  export class AnnouncementChannel extends BaseGuildTextChannel {
2586
2586
  public threads: GuildTextThreadManager<AllowedThreadTypeForAnnouncementChannel>;
2587
2587
  public type: ChannelType.GuildAnnouncement;
2588
- public addFollower(channel: TextChannelResolvable, reason?: string): Promise<AnnouncementChannel>;
2588
+ public addFollower(channel: TextChannelResolvable, reason?: string): Promise<FollowedChannelData>;
2589
2589
  }
2590
2590
 
2591
2591
  export type AnnouncementChannelResolvable = AnnouncementChannel | Snowflake;
@@ -4210,6 +4210,11 @@ export class GuildApplicationCommandManager extends ApplicationCommandManager<Ap
4210
4210
  public set(commands: readonly ApplicationCommandDataResolvable[]): Promise<Collection<Snowflake, ApplicationCommand>>;
4211
4211
  }
4212
4212
 
4213
+ export interface FollowedChannelData {
4214
+ channelId: Snowflake;
4215
+ webhookId: Snowflake;
4216
+ }
4217
+
4213
4218
  export type MappedGuildChannelTypes = {
4214
4219
  [ChannelType.GuildCategory]: CategoryChannel;
4215
4220
  } & MappedChannelCategoryTypes;
@@ -4225,7 +4230,7 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
4225
4230
  channel: AnnouncementChannelResolvable,
4226
4231
  targetChannel: TextChannelResolvable,
4227
4232
  reason?: string,
4228
- ): Promise<Snowflake>;
4233
+ ): Promise<FollowedChannelData>;
4229
4234
  public create<Type extends GuildChannelTypes>(
4230
4235
  options: GuildChannelCreateOptions & { type: Type },
4231
4236
  ): Promise<MappedGuildChannelTypes[Type]>;