diff --git a/structures/Message.ts b/structures/Message.ts index a84722f..500185f 100644 --- a/structures/Message.ts +++ b/structures/Message.ts @@ -250,6 +250,23 @@ export class Message implements Model { ); } + async crosspost() { + const message = await this.session.rest.runMethod( + this.session.rest, + "POST", + Routes.CHANNEL_MESSAGE_CROSSPOST(this.channelId, this.id), + ); + + return new Message(this.session, message); + } + + /* + * alias of Message.crosspost + * */ + get publish() { + return this.crosspost; + } + inGuild(): this is { guildId: Snowflake } & Message { return !!this.guildId; } diff --git a/structures/NewsChannel.ts b/structures/NewsChannel.ts index fcd15aa..ef76049 100644 --- a/structures/NewsChannel.ts +++ b/structures/NewsChannel.ts @@ -2,6 +2,7 @@ import type { Snowflake } from "../util/Snowflake.ts"; import type { Session } from "../session/Session.ts"; import type { DiscordChannel } from "../vendor/external.ts"; import TextChannel from "./TextChannel.ts"; +import Message from "./Message.ts"; export class NewsChannel extends TextChannel { constructor(session: Session, data: DiscordChannel, guildId: Snowflake) { @@ -9,6 +10,14 @@ export class NewsChannel extends TextChannel { this.defaultAutoArchiveDuration = data.default_auto_archive_duration; } defaultAutoArchiveDuration?: number; + + crosspostMessage(messageId: Snowflake): Promise { + return Message.prototype.crosspost.call({ id: messageId, channelId: this.id, session: this.session }); + } + + get publishMessage() { + return this.crosspostMessage; + } } export default NewsChannel; diff --git a/structures/TextChannel.ts b/structures/TextChannel.ts index a332079..e5e9d1e 100644 --- a/structures/TextChannel.ts +++ b/structures/TextChannel.ts @@ -118,15 +118,15 @@ export class TextChannel extends GuildChannel { } async addReaction(messageId: Snowflake, reaction: ReactionResolvable) { - await Message.prototype.addReaction.call({ channelId: this.id, id: messageId }, reaction); + await Message.prototype.addReaction.call({ channelId: this.id, id: messageId, session: this.session }, reaction); } async removeReaction(messageId: Snowflake, reaction: ReactionResolvable, options?: { userId: Snowflake }) { - await Message.prototype.removeReaction.call({ channelId: this.id, id: messageId }, reaction, options); + await Message.prototype.removeReaction.call({ channelId: this.id, id: messageId, session: this.session }, reaction, options); } async removeReactionEmoji(messageId: Snowflake, reaction: ReactionResolvable) { - await Message.prototype.removeReactionEmoji.call({ channelId: this.id, id: messageId }, reaction); + await Message.prototype.removeReactionEmoji.call({ channelId: this.id, id: messageId, session: this.session }, reaction); } async nukeReactions(messageId: Snowflake) { @@ -134,7 +134,7 @@ export class TextChannel extends GuildChannel { } async fetchReactions(messageId: Snowflake, reaction: ReactionResolvable, options?: GetReactions) { - const users = await Message.prototype.fetchReactions.call({ channelId: this.id, id: messageId }, reaction, options); + const users = await Message.prototype.fetchReactions.call({ channelId: this.id, id: messageId, session: this.session }, reaction, options); return users; } diff --git a/util/Routes.ts b/util/Routes.ts index 9204472..a53b7de 100644 --- a/util/Routes.ts +++ b/util/Routes.ts @@ -207,3 +207,7 @@ export function CHANNEL_MESSAGE_REACTION(channelId: Snowflake, messageId: Snowfl return url; } + +export function CHANNEL_MESSAGE_CROSSPOST(channelId: Snowflake, messageId: Snowflake) { + return `/channels/${channelId}/messages/${messageId}/crosspost`; +}