Browse Source

Add not supported exception on news channels when creating threads, #296

pull/1958/head
quin lynch 3 years ago
parent
commit
4ec6c166ae
4 changed files with 18 additions and 2 deletions
  1. +8
    -0
      src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs
  2. +1
    -1
      src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
  3. +8
    -0
      src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs
  4. +1
    -1
      src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs

+ 8
- 0
src/Discord.Net.Rest/Entities/Channels/RestNewsChannel.cs View File

@@ -25,5 +25,13 @@ namespace Discord.Rest
return entity;
}
public override int SlowModeInterval => throw new NotSupportedException("News channels do not support Slow Mode.");

/// <summary>
/// <b>News channels do not support thread creation with bots.</b>
/// </summary>
/// <inheritdoc/>
/// <exception cref="NotSupportedException"></exception>
public override Task<RestThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null)
=> throw new NotSupportedException("Cannot create threads in News channels");
}
}

+ 1
- 1
src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs View File

@@ -270,7 +270,7 @@ namespace Discord.Rest
/// <returns>
/// A task that represents the asynchronous create operation. The task result contains a <see cref="IThreadChannel"/>
/// </returns>
public async Task<RestThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread,
public virtual async Task<RestThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread,
ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null)
{
var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, invitable, slowmode, options);


+ 8
- 0
src/Discord.Net.WebSocket/Entities/Channels/SocketNewsChannel.cs View File

@@ -35,5 +35,13 @@ namespace Discord.WebSocket
/// </remarks>
public override int SlowModeInterval
=> throw new NotSupportedException("News channels do not support Slow Mode.");

/// <summary>
/// <b>News channels do not support thread creation with bots.</b>
/// </summary>
/// <inheritdoc/>
/// <exception cref="NotSupportedException"></exception>
public override Task<SocketThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread, ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null)
=> throw new NotSupportedException("Cannot create threads in News channels");
}
}

+ 1
- 1
src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs View File

@@ -112,7 +112,7 @@ namespace Discord.WebSocket
/// <returns>
/// A task that represents the asynchronous create operation. The task result contains a <see cref="IThreadChannel"/>
/// </returns>
public async Task<SocketThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread,
public virtual async Task<SocketThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread,
ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool? invitable = null, int? slowmode = null, RequestOptions options = null)
{
var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, invitable, slowmode, options);


Loading…
Cancel
Save