| @@ -26,6 +26,9 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| string Topic { get; } | string Topic { get; } | ||||
| ///<summary> Gets the current slow-mode delay for this channel. 0 if disabled. </summary> | |||||
| int SlowModeInterval { get; } | |||||
| /// <summary> | /// <summary> | ||||
| /// Bulk-deletes multiple messages. | /// Bulk-deletes multiple messages. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -14,5 +14,15 @@ namespace Discord | |||||
| /// Gets or sets whether this channel should be flagged as NSFW. | /// Gets or sets whether this channel should be flagged as NSFW. | ||||
| /// </summary> | /// </summary> | ||||
| public Optional<bool> IsNsfw { get; set; } | public Optional<bool> IsNsfw { get; set; } | ||||
| /// <summary> | |||||
| /// What the slow-mode ratelimit for this channel should be set to; 0 will disable slow-mode. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// This value must fall within [0, 120] | |||||
| /// | |||||
| /// Users with <see cref="ChannelPermission.ManageMessages"/> will be exempt from slow-mode. | |||||
| /// </remarks> | |||||
| /// <exception cref="ArgumentOutOfRangeException">Throws ArgummentOutOfRange if the value does not fall within [0, 120]</exception> | |||||
| public Optional<int> SlowModeInterval { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| #pragma warning disable CS1591 | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| using System; | using System; | ||||
| @@ -33,6 +33,8 @@ namespace Discord.API | |||||
| public Optional<DateTimeOffset?> LastPinTimestamp { get; set; } | public Optional<DateTimeOffset?> LastPinTimestamp { get; set; } | ||||
| [JsonProperty("nsfw")] | [JsonProperty("nsfw")] | ||||
| public Optional<bool> Nsfw { get; set; } | public Optional<bool> Nsfw { get; set; } | ||||
| [JsonProperty("rate_limit_per_user")] | |||||
| public Optional<int> SlowMode { get; set; } | |||||
| //VoiceChannel | //VoiceChannel | ||||
| [JsonProperty("bitrate")] | [JsonProperty("bitrate")] | ||||
| @@ -1,4 +1,4 @@ | |||||
| #pragma warning disable CS1591 | |||||
| #pragma warning disable CS1591 | |||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| namespace Discord.API.Rest | namespace Discord.API.Rest | ||||
| @@ -10,5 +10,7 @@ namespace Discord.API.Rest | |||||
| public Optional<string> Topic { get; set; } | public Optional<string> Topic { get; set; } | ||||
| [JsonProperty("nsfw")] | [JsonProperty("nsfw")] | ||||
| public Optional<bool> IsNsfw { get; set; } | public Optional<bool> IsNsfw { get; set; } | ||||
| [JsonProperty("rate_limit_per_user")] | |||||
| public Optional<int> SlowModeInterval { get; set; } | |||||
| } | } | ||||
| } | } | ||||
| @@ -360,6 +360,8 @@ namespace Discord.API | |||||
| Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
| Preconditions.AtLeast(args.Position, 0, nameof(args.Position)); | Preconditions.AtLeast(args.Position, 0, nameof(args.Position)); | ||||
| Preconditions.NotNullOrEmpty(args.Name, nameof(args.Name)); | Preconditions.NotNullOrEmpty(args.Name, nameof(args.Name)); | ||||
| Preconditions.AtLeast(args.SlowModeInterval, 0, nameof(args.SlowModeInterval)); | |||||
| Preconditions.AtMost(args.SlowModeInterval, 120, nameof(args.SlowModeInterval)); | |||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| var ids = new BucketIds(channelId: channelId); | var ids = new BucketIds(channelId: channelId); | ||||
| @@ -44,7 +44,8 @@ namespace Discord.Rest | |||||
| Position = args.Position, | Position = args.Position, | ||||
| CategoryId = args.CategoryId, | CategoryId = args.CategoryId, | ||||
| Topic = args.Topic, | Topic = args.Topic, | ||||
| IsNsfw = args.IsNsfw | |||||
| IsNsfw = args.IsNsfw, | |||||
| SlowModeInterval = args.SlowModeInterval, | |||||
| }; | }; | ||||
| return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); | return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); | ||||
| } | } | ||||
| @@ -16,6 +16,7 @@ namespace Discord.Rest | |||||
| { | { | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public string Topic { get; private set; } | public string Topic { get; private set; } | ||||
| public int SlowModeInterval { get; private set; } | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public ulong? CategoryId { get; private set; } | public ulong? CategoryId { get; private set; } | ||||
| @@ -40,6 +41,7 @@ namespace Discord.Rest | |||||
| base.Update(model); | base.Update(model); | ||||
| CategoryId = model.CategoryId; | CategoryId = model.CategoryId; | ||||
| Topic = model.Topic.Value; | Topic = model.Topic.Value; | ||||
| SlowModeInterval = model.SlowMode.Value; | |||||
| IsNsfw = model.Nsfw.GetValueOrDefault(); | IsNsfw = model.Nsfw.GetValueOrDefault(); | ||||
| } | } | ||||
| @@ -158,7 +158,7 @@ namespace Discord.Rest | |||||
| { | { | ||||
| CategoryId = props.CategoryId, | CategoryId = props.CategoryId, | ||||
| Topic = props.Topic, | Topic = props.Topic, | ||||
| IsNsfw = props.IsNsfw | |||||
| IsNsfw = props.IsNsfw, | |||||
| }; | }; | ||||
| var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); | var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); | ||||
| return RestTextChannel.Create(client, guild, model); | return RestTextChannel.Create(client, guild, model); | ||||
| @@ -20,6 +20,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public string Topic { get; private set; } | public string Topic { get; private set; } | ||||
| public int SlowModeInterval { get; private set; } | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public ulong? CategoryId { get; private set; } | public ulong? CategoryId { get; private set; } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -62,6 +63,7 @@ namespace Discord.WebSocket | |||||
| base.Update(state, model); | base.Update(state, model); | ||||
| CategoryId = model.CategoryId; | CategoryId = model.CategoryId; | ||||
| Topic = model.Topic.Value; | Topic = model.Topic.Value; | ||||
| SlowModeInterval = model.SlowMode.GetValueOrDefault(); // some guilds haven't been patched to include this yet? | |||||
| _nsfw = model.Nsfw.GetValueOrDefault(); | _nsfw = model.Nsfw.GetValueOrDefault(); | ||||
| } | } | ||||