discord.js
Advanced tools
Comparing version 15.0.0-dev.1735949500-28a250384 to 15.0.0-dev.1736035991-f5d2926c5
{ | ||
"$schema": "https://json.schemastore.org/package.json", | ||
"name": "discord.js", | ||
"version": "15.0.0-dev.1735949500-28a250384", | ||
"version": "15.0.0-dev.1736035991-f5d2926c5", | ||
"description": "A powerful library for interacting with the Discord API", | ||
@@ -63,4 +63,4 @@ "main": "./src/index.js", | ||
"undici": "6.21.0", | ||
"@discordjs/rest": "^2.4.0", | ||
"@discordjs/formatters": "^0.5.0", | ||
"@discordjs/rest": "^2.4.0", | ||
"@discordjs/util": "^1.1.1", | ||
@@ -85,4 +85,4 @@ "@discordjs/ws": "^2.0.0" | ||
"@discordjs/api-extractor": "^7.38.1", | ||
"@discordjs/scripts": "^0.1.0", | ||
"@discordjs/docgen": "^0.12.1" | ||
"@discordjs/docgen": "^0.12.1", | ||
"@discordjs/scripts": "^0.1.0" | ||
}, | ||
@@ -89,0 +89,0 @@ "engines": { |
@@ -109,2 +109,9 @@ 'use strict'; | ||
/** | ||
* Represents the followed channel data. | ||
* @typedef {Object} FollowedChannelData | ||
* @property {Snowflake} channelId Source channel id | ||
* @property {Snowflake} webhookId Created webhook id in the target channel | ||
*/ | ||
/** | ||
* Adds the target channel to a channel's followers. | ||
@@ -114,3 +121,3 @@ * @param {AnnouncementChannelResolvable} channel The channel to follow | ||
* @param {string} [reason] Reason for creating the webhook | ||
* @returns {Promise<Snowflake>} Returns created target webhook id. | ||
* @returns {Promise<FollowedChannelData>} Returns the data for the followed channel | ||
*/ | ||
@@ -126,7 +133,7 @@ async addFollower(channel, targetChannel, reason) { | ||
} | ||
const { webhook_id } = await this.client.rest.post(Routes.channelFollowers(channelId), { | ||
const data = await this.client.rest.post(Routes.channelFollowers(channelId), { | ||
body: { webhook_channel_id: targetChannelId }, | ||
reason, | ||
}); | ||
return webhook_id; | ||
return { channelId: data.channel_id, webhookId: data.webhook_id }; | ||
} | ||
@@ -133,0 +140,0 @@ |
'use strict'; | ||
const { Routes } = require('discord-api-types/v10'); | ||
const BaseGuildTextChannel = require('./BaseGuildTextChannel'); | ||
const { DiscordjsError, ErrorCodes } = require('../errors'); | ||
@@ -16,3 +14,3 @@ /** | ||
* @param {string} [reason] Reason for creating the webhook | ||
* @returns {Promise<AnnouncementChannel>} | ||
* @returns {Promise<FollowedChannelData>} Returns the data for the followed channel | ||
* @example | ||
@@ -26,6 +24,3 @@ * if (channel.type === ChannelType.GuildAnnouncement) { | ||
async addFollower(channel, reason) { | ||
const channelId = this.guild.channels.resolveId(channel); | ||
if (!channelId) throw new DiscordjsError(ErrorCodes.GuildChannelResolve); | ||
await this.client.rest.post(Routes.channelFollowers(this.id), { body: { webhook_channel_id: channelId }, reason }); | ||
return this; | ||
return this.guild.channels.addFollower(this, channel, reason); | ||
} | ||
@@ -32,0 +27,0 @@ } |
@@ -566,3 +566,3 @@ 'use strict'; | ||
// eslint-disable-next-line eqeqeq | ||
return this.content != null ? cleanContent(this.content, this.channel) : null; | ||
return this.content != null && this.channel ? cleanContent(this.content, this.channel) : null; | ||
} | ||
@@ -569,0 +569,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1850453
40898