as of writing, this feature is still only available to verified guilds, which makes it impossible for testing.pull/1293/head
| @@ -38,5 +38,15 @@ namespace Discord | |||||
| /// </remarks> | /// </remarks> | ||||
| /// <exception cref="ArgumentOutOfRangeException">Thrown if the value does not fall within [0, 120].</exception> | /// <exception cref="ArgumentOutOfRangeException">Thrown if the value does not fall within [0, 120].</exception> | ||||
| public Optional<int> SlowModeInterval { get; set; } | public Optional<int> SlowModeInterval { get; set; } | ||||
| /// <summary> | |||||
| /// Gets or sets the type of channel. | |||||
| /// Only setting to a <see cref="ChannelType.News"/> is supported. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// Setting this value to a different type will change the type of channel that is associated with this Id. | |||||
| /// </remarks> | |||||
| /// <exception cref="ArgumentException">Thrown if the type of channel that is being set is not valid.</exception> | |||||
| public Optional<ChannelType> Type { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -12,5 +12,7 @@ namespace Discord.API.Rest | |||||
| public Optional<bool> IsNsfw { get; set; } | public Optional<bool> IsNsfw { get; set; } | ||||
| [JsonProperty("rate_limit_per_user")] | [JsonProperty("rate_limit_per_user")] | ||||
| public Optional<int> SlowModeInterval { get; set; } | public Optional<int> SlowModeInterval { get; set; } | ||||
| [JsonProperty("type")] | |||||
| public Optional<ChannelType> Type { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -377,6 +377,15 @@ namespace Discord.API | |||||
| Preconditions.NotNullOrEmpty(args.Name, nameof(args.Name)); | Preconditions.NotNullOrEmpty(args.Name, nameof(args.Name)); | ||||
| Preconditions.AtLeast(args.SlowModeInterval, 0, nameof(args.SlowModeInterval)); | Preconditions.AtLeast(args.SlowModeInterval, 0, nameof(args.SlowModeInterval)); | ||||
| Preconditions.AtMost(args.SlowModeInterval, 120, nameof(args.SlowModeInterval)); | Preconditions.AtMost(args.SlowModeInterval, 120, nameof(args.SlowModeInterval)); | ||||
| if (args.Type.IsSpecified) | |||||
| { | |||||
| // can only change Text/NewsChannel into a Text or News | |||||
| var warn = "You may not change a Text or News channel into a Voice, Group, DM, or Category channel."; | |||||
| Preconditions.NotEqual((uint)args.Type.Value, (uint)ChannelType.Voice, nameof(args.Type), warn); | |||||
| Preconditions.NotEqual((uint)args.Type.Value, (uint)ChannelType.Group, nameof(args.Type), warn); | |||||
| Preconditions.NotEqual((uint)args.Type.Value, (uint)ChannelType.DM, nameof(args.Type), warn); | |||||
| Preconditions.NotEqual((uint)args.Type.Value, (uint)ChannelType.Category, nameof(args.Type), warn); | |||||
| } | |||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| var ids = new BucketIds(channelId: channelId); | var ids = new BucketIds(channelId: channelId); | ||||
| @@ -46,6 +46,7 @@ namespace Discord.Rest | |||||
| Topic = args.Topic, | Topic = args.Topic, | ||||
| IsNsfw = args.IsNsfw, | IsNsfw = args.IsNsfw, | ||||
| SlowModeInterval = args.SlowModeInterval, | SlowModeInterval = args.SlowModeInterval, | ||||
| Type = args.Type | |||||
| }; | }; | ||||
| return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); | return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); | ||||
| } | } | ||||
| @@ -19,5 +19,6 @@ namespace Discord.WebSocket | |||||
| entity.Update(state, model); | entity.Update(state, model); | ||||
| return entity; | return entity; | ||||
| } | } | ||||
| //TODO: Need to set custom channel properties for this type, as apparently it does not support slow mode or overwrites. | |||||
| } | } | ||||
| } | } | ||||