fix: Crosspost throwing InvalidOperationException (#1671)
* Add INewsChannel * Renaming variable to match the new type
This commit is contained in:
@@ -15,7 +15,7 @@ namespace Discord.WebSocket
|
||||
/// </note>
|
||||
/// </remarks>
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public class SocketNewsChannel : SocketTextChannel
|
||||
public class SocketNewsChannel : SocketTextChannel, INewsChannel
|
||||
{
|
||||
internal SocketNewsChannel(DiscordSocketClient discord, ulong id, SocketGuild guild)
|
||||
:base(discord, id, guild)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Discord.WebSocket
|
||||
case ICategoryChannel categoryChannel: return ChannelType.Category;
|
||||
case IDMChannel dmChannel: return ChannelType.DM;
|
||||
case IGroupChannel groupChannel: return ChannelType.Group;
|
||||
case SocketNewsChannel socketNewsChannel: return ChannelType.News;
|
||||
case INewsChannel newsChannel: return ChannelType.News;
|
||||
case ITextChannel textChannel: return ChannelType.Text;
|
||||
default: throw new InvalidOperationException("Invalid channel type.");
|
||||
}
|
||||
|
||||
@@ -158,10 +158,10 @@ namespace Discord.WebSocket
|
||||
=> 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>
|
||||
/// <exception cref="InvalidOperationException">This operation may only be called on a <see cref="INewsChannel"/> channel.</exception>
|
||||
public async Task CrosspostAsync(RequestOptions options = null)
|
||||
{
|
||||
if (!(Channel is SocketNewsChannel))
|
||||
if (!(Channel is INewsChannel))
|
||||
{
|
||||
throw new InvalidOperationException("Publishing (crossposting) is only valid in news channels.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user