fix!: move crosspost() to GuildMessageManager (#10703)

BREAKING CHANGE: The `crosspost()` method from `MessageManager` has been moved to `GuildMessageManager`.
This commit is contained in:
Danial Raza
2025-01-15 12:29:35 +01:00
committed by GitHub
parent 1fd587c935
commit 6a42c5f929
2 changed files with 15 additions and 13 deletions

View File

@@ -1,6 +1,8 @@
'use strict';
const { Routes } = require('discord-api-types/v10');
const MessageManager = require('./MessageManager');
const { DiscordjsTypeError, ErrorCodes } = require('../errors');
/**
* Manages API methods for messages in a guild and holds their cache.
@@ -12,6 +14,19 @@ class GuildMessageManager extends MessageManager {
* @name GuildMessageManager#channel
* @type {GuildTextBasedChannel}
*/
/**
* Publishes a message in an announcement channel to all channels following it, even if it's not cached.
* @param {MessageResolvable} message The message to publish
* @returns {Promise<Message>}
*/
async crosspost(message) {
const messageId = this.resolveId(message);
if (!messageId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'message', 'MessageResolvable');
const data = await this.client.rest.post(Routes.channelMessageCrosspost(this.channel.id, messageId));
return this.cache.get(data.id) ?? this._add(data);
}
}
module.exports = GuildMessageManager;

View File

@@ -196,19 +196,6 @@ class MessageManager extends CachedManager {
return this._add(d);
}
/**
* Publishes a message in an announcement channel to all channels following it, even if it's not cached.
* @param {MessageResolvable} message The message to publish
* @returns {Promise<Message>}
*/
async crosspost(message) {
message = this.resolveId(message);
if (!message) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'message', 'MessageResolvable');
const data = await this.client.rest.post(Routes.channelMessageCrosspost(this.channel.id, message));
return this.cache.get(data.id) ?? this._add(data);
}
/**
* Pins a message to the channel's pinned messages, even if it's not cached.
* @param {MessageResolvable} message The message to pin