(ifcbrk) feature: news channel publishing (#1530)

* Added PublishAsync to Messages.

* Added missing implementation.

* 1. Aligned with naming standards
2. Clarified xml docs
3. Properly threw exceptions instead of failing silently.

* Additional documentation included.

* Removed un-needed comments.

Co-authored-by: Matt Smith <v-matsm@microsoft.com>
This commit is contained in:
Matt Smith
2020-05-20 16:28:23 -05:00
committed by GitHub
parent 91b270a0ce
commit a6c1e4c23f
6 changed files with 66 additions and 3 deletions

View File

@@ -123,7 +123,7 @@ namespace Discord.WebSocket
model.Content = text;
}
}
/// <inheritdoc />
/// <exception cref="InvalidOperationException">Only the author of a message may modify the message.</exception>
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
@@ -147,7 +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);
/// <inheritdoc />
/// <exception cref="InvalidOperationException">This operation may only be called on a <see cref="SocketNewsChannel"/> channel.</exception>
public async Task CrosspostAsync(RequestOptions options = null)
{
if (!(Channel is SocketNewsChannel))
{
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;
}