diff --git a/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs b/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
index fddc9da4b..9430e9af2 100644
--- a/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
+++ b/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
@@ -58,13 +58,16 @@ namespace Discord
Task UnpinAsync(RequestOptions options = null);
///
- /// Publish this message when executed in a News Channel.
+ /// Publish (crosspost) this message.
///
/// The options to be used when sending the request.
///
/// A task that represents the asynchronous operation for publishing this message.
///
- Task PublishAsync(RequestOptions options = null);
+ ///
+ /// Publishing (crossposting) is only available in news channels.
+ ///
+ Task CrosspostAsync(RequestOptions options = null);
///
/// Transforms this message's text into a human-readable form by resolving its tags.
diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs
index f437f29c1..732cb5f17 100644
--- a/src/Discord.Net.Rest/DiscordRestApiClient.cs
+++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs
@@ -695,7 +695,7 @@ namespace Discord.API
var ids = new BucketIds(channelId: channelId);
await SendAsync("POST", () => $"channels/{channelId}/typing", ids, options: options).ConfigureAwait(false);
}
- public async Task PublishAsync(ulong channelId, ulong messageId, RequestOptions options = null)
+ public async Task CrosspostAsync(ulong channelId, ulong messageId, RequestOptions options = null)
{
Preconditions.NotEqual(channelId, 0, nameof(channelId));
Preconditions.NotEqual(messageId, 0, nameof(messageId));
diff --git a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs
index 1dbd96fbd..57f8b2509 100644
--- a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs
@@ -286,13 +286,13 @@ namespace Discord.Rest
return MessageSource.User;
}
- public static Task PublishAsync(IMessage msg, BaseDiscordClient client, RequestOptions options)
- => PublishAsync(msg.Channel.Id, msg.Id, client, options);
+ public static Task CrosspostAsync(IMessage msg, BaseDiscordClient client, RequestOptions options)
+ => CrosspostAsync(msg.Channel.Id, msg.Id, client, options);
- public static async Task PublishAsync(ulong channelId, ulong msgId, BaseDiscordClient client,
+ public static async Task CrosspostAsync(ulong channelId, ulong msgId, BaseDiscordClient client,
RequestOptions options)
{
- await client.ApiClient.PublishAsync(channelId, msgId, options).ConfigureAwait(false);
+ await client.ApiClient.CrosspostAsync(channelId, msgId, options).ConfigureAwait(false);
}
}
}
diff --git a/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
index 5fc3b5e83..d116ae341 100644
--- a/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
+++ b/src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
@@ -148,12 +148,15 @@ namespace Discord.Rest
TagHandling roleHandling = TagHandling.Name, TagHandling everyoneHandling = TagHandling.Ignore, TagHandling emojiHandling = TagHandling.Name)
=> MentionUtils.Resolve(this, 0, userHandling, channelHandling, roleHandling, everyoneHandling, emojiHandling);
- public async Task PublishAsync(RequestOptions options = null)
+ ///
+ public async Task CrosspostAsync(RequestOptions options = null)
{
- if (Channel.GetType() == typeof(RestNewsChannel))
+ if (!(Channel is RestNewsChannel))
{
- await MessageHelper.PublishAsync(this, Discord, options);
+ throw new InvalidOperationException("Publishing (crossposting) is only valid in news channels.");
}
+
+ await MessageHelper.CrosspostAsync(this, Discord, options);
}
private string DebuggerDisplay => $"{Author}: {Content} ({Id}{(Attachments.Count > 0 ? $", {Attachments.Count} Attachments" : "")})";
diff --git a/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs b/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs
index a7808fc5d..56f0f593e 100644
--- a/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs
+++ b/src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs
@@ -147,16 +147,19 @@ namespace Discord.WebSocket
public string Resolve(TagHandling userHandling = TagHandling.Name, TagHandling channelHandling = TagHandling.Name,
TagHandling roleHandling = TagHandling.Name, TagHandling everyoneHandling = TagHandling.Ignore, TagHandling emojiHandling = TagHandling.Name)
=> MentionUtils.Resolve(this, 0, userHandling, channelHandling, roleHandling, everyoneHandling, emojiHandling);
-
- private string DebuggerDisplay => $"{Author}: {Content} ({Id}{(Attachments.Count > 0 ? $", {Attachments.Count} Attachments" : "")})";
- internal new SocketUserMessage Clone() => MemberwiseClone() as SocketUserMessage;
- public async Task PublishAsync(RequestOptions options = null)
+ ///
+ public async Task CrosspostAsync(RequestOptions options = null)
{
- if (Channel.GetType() == typeof(SocketNewsChannel))
+ if (!(Channel is SocketNewsChannel))
{
- await MessageHelper.PublishAsync(this, Discord, options);
+ throw new InvalidOperationException("Publishing (crossposting) is only valid in news channels.");
}
+
+ await MessageHelper.CrosspostAsync(this, Discord, options);
}
+
+ private string DebuggerDisplay => $"{Author}: {Content} ({Id}{(Attachments.Count > 0 ? $", {Attachments.Count} Attachments" : "")})";
+ internal new SocketUserMessage Clone() => MemberwiseClone() as SocketUserMessage;
}
}