mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
fix!: move crosspost() to GuildMessageManager (#10703)
BREAKING CHANGE: The `crosspost()` method from `MessageManager` has been moved to `GuildMessageManager`.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user