From 2212473e8583334f00500e8ab9dce9819ced9af5 Mon Sep 17 00:00:00 2001 From: Velvet Toroyashi <42438262+VelvetToroyashi@users.noreply.github.com> Date: Mon, 4 Sep 2023 12:35:29 -0400 Subject: [PATCH 1/6] feat: Add new permissions This commit implements the new permissions (USE_CLYDE_AI, SET_VOICE_CHANNEL_STATUS, and CREATE_GUILD_EXPRESSIONS) as seen in these PRs: https://github.com/discord/discord-api-docs/pull/6354 https://github.com/discord/discord-api-docs/pull/6398 https://github.com/discord/discord-api-docs/pull/6120 --- .../Objects/Permissions/DiscordPermission.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Backend/Remora.Discord.API.Abstractions/API/Objects/Permissions/DiscordPermission.cs b/Backend/Remora.Discord.API.Abstractions/API/Objects/Permissions/DiscordPermission.cs index 370334bf71..820bd6f5ec 100644 --- a/Backend/Remora.Discord.API.Abstractions/API/Objects/Permissions/DiscordPermission.cs +++ b/Backend/Remora.Discord.API.Abstractions/API/Objects/Permissions/DiscordPermission.cs @@ -253,6 +253,11 @@ public enum DiscordPermission /// UseSoundboard = 42, + /// + /// Allows for creating emojis, stickers, and soundboard sounds, independently of managing them. + /// + CreateGuildExpressions = 43, + /// /// Allows the usage of custom soundboard sounds from other servers. /// @@ -261,5 +266,15 @@ public enum DiscordPermission /// /// Allows for sending voice messages. /// - SendVoiceMessages = 46 + SendVoiceMessages = 46, + + /// + /// Allows for interaction with Clyde (AI). + /// + UseClydeAi = 47, + + /// + /// Allows for setting the status of a voice channel. + /// + SetVoiceChannelStatus = 48 } From e8ed2171dfd0ca0b7392b58db2e72974518d0d82 Mon Sep 17 00:00:00 2001 From: Velvet Toroyashi <42438262+VelvetToroyashi@users.noreply.github.com> Date: Mon, 4 Sep 2023 13:03:20 -0400 Subject: [PATCH 2/6] feat: Implement voice channel statuses --- .../Channels/IVoiceChannelStatusUpdate.cs | 46 +++++++++++++++++++ .../API/Objects/Channels/IChannel.cs | 8 ++++ .../API/Objects/Channels/IPartialChannel.cs | 3 ++ .../API/Rest/IDiscordRestChannelAPI.cs | 4 ++ .../Gateway/Events/Channels/ChannelCreate.cs | 3 +- .../Gateway/Events/Channels/ChannelDelete.cs | 3 +- .../Gateway/Events/Channels/ChannelUpdate.cs | 3 +- .../Gateway/Events/Channels/ThreadCreate.cs | 3 +- .../Gateway/Events/Channels/ThreadDelete.cs | 3 +- .../Gateway/Events/Channels/ThreadUpdate.cs | 3 +- .../Channels/VoiceChannelStatusUpdate.cs | 34 ++++++++++++++ .../API/Objects/Channels/Channel.cs | 3 +- .../API/Objects/Channels/PartialChannel.cs | 3 +- ...achingDiscordRestChannelAPI.Delegations.cs | 2 + .../API/CachingDiscordRestChannelAPI.cs | 2 + .../API/Channels/DiscordRestChannelAPI.cs | 9 ++++ 16 files changed, 124 insertions(+), 8 deletions(-) create mode 100644 Backend/Remora.Discord.API.Abstractions/API/Gateway/Events/Channels/IVoiceChannelStatusUpdate.cs create mode 100644 Backend/Remora.Discord.API/API/Gateway/Events/Channels/VoiceChannelStatusUpdate.cs diff --git a/Backend/Remora.Discord.API.Abstractions/API/Gateway/Events/Channels/IVoiceChannelStatusUpdate.cs b/Backend/Remora.Discord.API.Abstractions/API/Gateway/Events/Channels/IVoiceChannelStatusUpdate.cs new file mode 100644 index 0000000000..3e7e55cbe8 --- /dev/null +++ b/Backend/Remora.Discord.API.Abstractions/API/Gateway/Events/Channels/IVoiceChannelStatusUpdate.cs @@ -0,0 +1,46 @@ +// +// IVoiceChannelStatusUpdate.cs +// +// Author: +// Jarl Gullberg +// +// Copyright (c) Jarl Gullberg +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// + +using Remora.Rest.Core; + +namespace Remora.Discord.API.Abstractions.Gateway.Events; + +/// +/// Represents an update to the respective voice channel. +/// +public interface IVoiceChannelStatusUpdate +{ + /// + /// Gets the ID of the channel being updated. + /// + Snowflake ID { get; } + + /// + /// Gets the ID of the guild. + /// + Snowflake GuildID { get; } + + /// + /// Gets the new status of the voice channel. + /// + Optional Status { get; } +} diff --git a/Backend/Remora.Discord.API.Abstractions/API/Objects/Channels/IChannel.cs b/Backend/Remora.Discord.API.Abstractions/API/Objects/Channels/IChannel.cs index aa19fdb6d0..a139d7ccc8 100644 --- a/Backend/Remora.Discord.API.Abstractions/API/Objects/Channels/IChannel.cs +++ b/Backend/Remora.Discord.API.Abstractions/API/Objects/Channels/IChannel.cs @@ -212,6 +212,11 @@ public interface IChannel : IPartialChannel /// new Optional DefaultForumLayout { get; } + /// + /// Gets the status of the channel. + /// + new Optional Status { get; } + /// Optional IPartialChannel.ID => this.ID; @@ -316,4 +321,7 @@ public interface IChannel : IPartialChannel /// Optional IPartialChannel.DefaultForumLayout => this.DefaultForumLayout; + + /// + Optional IPartialChannel.Status => this.Status; } diff --git a/Backend/Remora.Discord.API.Abstractions/API/Objects/Channels/IPartialChannel.cs b/Backend/Remora.Discord.API.Abstractions/API/Objects/Channels/IPartialChannel.cs index 9d4977a6e4..c933c0decf 100644 --- a/Backend/Remora.Discord.API.Abstractions/API/Objects/Channels/IPartialChannel.cs +++ b/Backend/Remora.Discord.API.Abstractions/API/Objects/Channels/IPartialChannel.cs @@ -137,4 +137,7 @@ public interface IPartialChannel /// Optional DefaultForumLayout { get; } + + /// + Optional Status { get; } } diff --git a/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs b/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs index 93ab8c0e43..1d0d519675 100644 --- a/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs +++ b/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs @@ -91,6 +91,7 @@ public interface IDiscordRestChannelAPI /// The tags applied to the thread. /// The default sort order of posts. /// The default layout of posts in a forum. + /// The new status of the voice channel. /// The reason to mark the action in the audit log with. /// The cancellation token for this operation. /// A modification result which may or may not have succeeded. @@ -122,6 +123,7 @@ Task> ModifyChannelAsync Optional> appliedTags = default, Optional defaultSortOrder = default, Optional defaultForumLayout = default, + Optional status = default, Optional reason = default, CancellationToken ct = default ); @@ -197,6 +199,7 @@ Task> ModifyGuildTextChannelAsync /// The new parent category ID. /// The channel's voice region. Automatic when null. /// The new video quality mode. + /// The new status for the channel. /// The reason to mark the action in the audit log with. /// The cancellation token for this operation. /// A modification result which may or may not have succeeded. @@ -213,6 +216,7 @@ Task> ModifyGuildVoiceChannelAsync Optional parentID = default, Optional rtcRegion = default, Optional videoQualityMode = default, + Optional status = default, Optional reason = default, CancellationToken ct = default ); diff --git a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ChannelCreate.cs b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ChannelCreate.cs index a43a002c27..be6e6f99f3 100644 --- a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ChannelCreate.cs +++ b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ChannelCreate.cs @@ -67,5 +67,6 @@ public record ChannelCreate Optional DefaultReactionEmoji = default, Optional DefaultThreadRateLimitPerUser = default, Optional DefaultSortOrder = default, - Optional DefaultForumLayout = default + Optional DefaultForumLayout = default, + Optional Status = default ) : IChannelCreate; diff --git a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ChannelDelete.cs b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ChannelDelete.cs index e7daa340b7..2fc61d1766 100644 --- a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ChannelDelete.cs +++ b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ChannelDelete.cs @@ -67,5 +67,6 @@ public record ChannelDelete Optional DefaultReactionEmoji = default, Optional DefaultThreadRateLimitPerUser = default, Optional DefaultSortOrder = default, - Optional DefaultForumLayout = default + Optional DefaultForumLayout = default, + Optional Status = default ) : IChannelDelete; diff --git a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ChannelUpdate.cs b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ChannelUpdate.cs index 3734b175dc..8fc54378fb 100644 --- a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ChannelUpdate.cs +++ b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ChannelUpdate.cs @@ -67,5 +67,6 @@ public record ChannelUpdate Optional DefaultReactionEmoji = default, Optional DefaultThreadRateLimitPerUser = default, Optional DefaultSortOrder = default, - Optional DefaultForumLayout = default + Optional DefaultForumLayout = default, + Optional Status = default ) : IChannelUpdate; diff --git a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ThreadCreate.cs b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ThreadCreate.cs index f894ba43df..efcb06fe31 100644 --- a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ThreadCreate.cs +++ b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ThreadCreate.cs @@ -68,5 +68,6 @@ public record ThreadCreate Optional DefaultReactionEmoji = default, Optional DefaultThreadRateLimitPerUser = default, Optional DefaultSortOrder = default, - Optional DefaultForumLayout = default + Optional DefaultForumLayout = default, + Optional Status = default ) : IThreadCreate; diff --git a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ThreadDelete.cs b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ThreadDelete.cs index 2f54e11aa6..c0a01c7379 100644 --- a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ThreadDelete.cs +++ b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ThreadDelete.cs @@ -67,5 +67,6 @@ public record ThreadDelete Optional DefaultReactionEmoji = default, Optional DefaultThreadRateLimitPerUser = default, Optional DefaultSortOrder = default, - Optional DefaultForumLayout = default + Optional DefaultForumLayout = default, + Optional Status = default ) : IThreadDelete; diff --git a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ThreadUpdate.cs b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ThreadUpdate.cs index e7ea9279da..aa7a812617 100644 --- a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ThreadUpdate.cs +++ b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/ThreadUpdate.cs @@ -67,5 +67,6 @@ public record ThreadUpdate Optional DefaultReactionEmoji = default, Optional DefaultThreadRateLimitPerUser = default, Optional DefaultSortOrder = default, - Optional DefaultForumLayout = default + Optional DefaultForumLayout = default, + Optional Status = default ) : IThreadUpdate; diff --git a/Backend/Remora.Discord.API/API/Gateway/Events/Channels/VoiceChannelStatusUpdate.cs b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/VoiceChannelStatusUpdate.cs new file mode 100644 index 0000000000..589e45d43e --- /dev/null +++ b/Backend/Remora.Discord.API/API/Gateway/Events/Channels/VoiceChannelStatusUpdate.cs @@ -0,0 +1,34 @@ +// +// VoiceChannelStatusUpdate.cs +// +// Author: +// Jarl Gullberg +// +// Copyright (c) Jarl Gullberg +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// + +using Remora.Discord.API.Abstractions.Gateway.Events; +using Remora.Rest.Core; + +namespace Remora.Discord.API.Gateway.Events.Channels; + +/// +public record VoiceChannelStatusUpdate +( + Snowflake ID, + Snowflake GuildID, + Optional Status +) : IVoiceChannelStatusUpdate; diff --git a/Backend/Remora.Discord.API/API/Objects/Channels/Channel.cs b/Backend/Remora.Discord.API/API/Objects/Channels/Channel.cs index 9b6ec4f736..54b98897a8 100644 --- a/Backend/Remora.Discord.API/API/Objects/Channels/Channel.cs +++ b/Backend/Remora.Discord.API/API/Objects/Channels/Channel.cs @@ -68,5 +68,6 @@ public record Channel Optional DefaultReactionEmoji = default, Optional DefaultThreadRateLimitPerUser = default, Optional DefaultSortOrder = default, - Optional DefaultForumLayout = default + Optional DefaultForumLayout = default, + Optional Status = default ) : IChannel; diff --git a/Backend/Remora.Discord.API/API/Objects/Channels/PartialChannel.cs b/Backend/Remora.Discord.API/API/Objects/Channels/PartialChannel.cs index 34f2b20f98..d5e5e21992 100644 --- a/Backend/Remora.Discord.API/API/Objects/Channels/PartialChannel.cs +++ b/Backend/Remora.Discord.API/API/Objects/Channels/PartialChannel.cs @@ -68,5 +68,6 @@ public record PartialChannel Optional DefaultReactionEmoji = default, Optional DefaultThreadRateLimitPerUser = default, Optional DefaultSortOrder = default, - Optional DefaultForumLayout = default + Optional DefaultForumLayout = default, + Optional Status = default ) : IPartialChannel; diff --git a/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.Delegations.cs b/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.Delegations.cs index d75b4f7da5..9ce9f876c6 100644 --- a/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.Delegations.cs +++ b/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.Delegations.cs @@ -95,6 +95,7 @@ public Task> ModifyGuildVoiceChannelAsync Optional parentId = default, Optional rtcRegion = default, Optional videoQualityMode = default, + Optional status = default, Optional reason = default, CancellationToken ct = default ) @@ -112,6 +113,7 @@ public Task> ModifyGuildVoiceChannelAsync parentId, rtcRegion, videoQualityMode, + status, reason, ct ); diff --git a/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs b/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs index 47ad0b913c..722be43ed4 100644 --- a/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs +++ b/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs @@ -117,6 +117,7 @@ public async Task> ModifyChannelAsync Optional> appliedTags = default, Optional defaultSortOrder = default, Optional defaultForumLayout = default, + Optional status = default, Optional reason = default, CancellationToken ct = default ) @@ -149,6 +150,7 @@ public async Task> ModifyChannelAsync appliedTags, defaultSortOrder, defaultForumLayout, + status, reason, ct ); diff --git a/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs b/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs index 7c1b2fb21c..ff31bc0ee9 100644 --- a/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs +++ b/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs @@ -109,6 +109,7 @@ public virtual async Task> ModifyChannelAsync Optional> appliedTags = default, Optional defaultSortOrder = default, Optional defaultForumLayout = default, + Optional status = default, Optional reason = default, CancellationToken ct = default ) @@ -155,6 +156,11 @@ public virtual async Task> ModifyChannelAsync return Result.FromError(packImage); } + if (status is { HasValue: true, Value: { Length: > 500 } }) + { + return new ArgumentOutOfRangeError(nameof(status), "The status must between 0 and 500 characters."); + } + Optional base64EncodedIcon = packImage.Entity!; return await this.RestHttpClient.PatchAsync @@ -196,6 +202,7 @@ public virtual async Task> ModifyChannelAsync json.Write("applied_tags", appliedTags, this.JsonOptions); json.Write("default_sort_order", defaultSortOrder, this.JsonOptions); json.Write("default_forum_layout", defaultForumLayout, this.JsonOptions); + json.Write("status", status, this.JsonOptions); } ) .WithRateLimitContext(this.RateLimitCache), @@ -263,6 +270,7 @@ public virtual Task> ModifyGuildVoiceChannelAsync Optional parentID = default, Optional rtcRegion = default, Optional videoQualityMode = default, + Optional status = default, Optional reason = default, CancellationToken ct = default ) @@ -280,6 +288,7 @@ public virtual Task> ModifyGuildVoiceChannelAsync parentID: parentID, rtcRegion: rtcRegion, videoQualityMode: videoQualityMode, + status: status, reason: reason, ct: ct ); From dc91351f3027cc0a2cc2d5aa4f47bde0ad914ddd Mon Sep 17 00:00:00 2001 From: Velvet <42438262+VelvetToroyashi@users.noreply.github.com> Date: Wed, 6 Sep 2023 16:22:30 -0400 Subject: [PATCH 3/6] fix: Make IVoiceChannelStatusUpdate implement IGatewayEvent Co-authored-by: MazeXP <26042705+MazeXP@users.noreply.github.com> --- .../API/Gateway/Events/Channels/IVoiceChannelStatusUpdate.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backend/Remora.Discord.API.Abstractions/API/Gateway/Events/Channels/IVoiceChannelStatusUpdate.cs b/Backend/Remora.Discord.API.Abstractions/API/Gateway/Events/Channels/IVoiceChannelStatusUpdate.cs index 3e7e55cbe8..beb6899b8c 100644 --- a/Backend/Remora.Discord.API.Abstractions/API/Gateway/Events/Channels/IVoiceChannelStatusUpdate.cs +++ b/Backend/Remora.Discord.API.Abstractions/API/Gateway/Events/Channels/IVoiceChannelStatusUpdate.cs @@ -27,7 +27,7 @@ namespace Remora.Discord.API.Abstractions.Gateway.Events; /// /// Represents an update to the respective voice channel. /// -public interface IVoiceChannelStatusUpdate +public interface IVoiceChannelStatusUpdate : IGatewayEvent { /// /// Gets the ID of the channel being updated. From c22ca679094021d3a2da69c30437a32a0f211181 Mon Sep 17 00:00:00 2001 From: Velvet Toroyashi <42438262+VelvetToroyashi@users.noreply.github.com> Date: Wed, 6 Sep 2023 16:42:52 -0400 Subject: [PATCH 4/6] feat(?): Implement voice status API correctly --- .../API/Rest/IDiscordRestChannelAPI.cs | 18 ++++++++++++++++-- ...achingDiscordRestChannelAPI.Delegations.cs | 14 ++++++++++++-- .../API/Channels/DiscordRestChannelAPI.cs | 19 +++++++++++++++++-- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs b/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs index 1d0d519675..b2f1d36db7 100644 --- a/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs +++ b/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs @@ -47,6 +47,22 @@ public interface IDiscordRestChannelAPI /// A retrieval result which may or may not have succeeded. Task> GetChannelAsync(Snowflake channelID, CancellationToken ct = default); + /// + /// Sets the status of a given voice channel. + /// + /// The ID of the channel. + /// The status to set. + /// The reason to mark the action in the audit log with. + /// The cancellation token for this operation. + /// A modification result that may or not have succeeded. + Task SetVoiceChannelStatusAsync + ( + Snowflake channelID, + Optional status, + Optional reason = default, + CancellationToken ct = default + ); + /// /// Modifies the given channel. /// @@ -199,7 +215,6 @@ Task> ModifyGuildTextChannelAsync /// The new parent category ID. /// The channel's voice region. Automatic when null. /// The new video quality mode. - /// The new status for the channel. /// The reason to mark the action in the audit log with. /// The cancellation token for this operation. /// A modification result which may or may not have succeeded. @@ -216,7 +231,6 @@ Task> ModifyGuildVoiceChannelAsync Optional parentID = default, Optional rtcRegion = default, Optional videoQualityMode = default, - Optional status = default, Optional reason = default, CancellationToken ct = default ); diff --git a/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.Delegations.cs b/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.Delegations.cs index 9ce9f876c6..7b0649a309 100644 --- a/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.Delegations.cs +++ b/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.Delegations.cs @@ -35,6 +35,18 @@ namespace Remora.Discord.Caching.API; public partial class CachingDiscordRestChannelAPI { + /// + public Task SetVoiceChannelStatusAsync + ( + Snowflake channelID, + Optional status, + Optional reason = default, + CancellationToken ct = default + ) + { + return _actual.SetVoiceChannelStatusAsync(channelID, status, reason, ct); + } + /// public Task> ModifyGroupDMChannelAsync ( @@ -95,7 +107,6 @@ public Task> ModifyGuildVoiceChannelAsync Optional parentId = default, Optional rtcRegion = default, Optional videoQualityMode = default, - Optional status = default, Optional reason = default, CancellationToken ct = default ) @@ -113,7 +124,6 @@ public Task> ModifyGuildVoiceChannelAsync parentId, rtcRegion, videoQualityMode, - status, reason, ct ); diff --git a/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs b/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs index ff31bc0ee9..971dde588d 100644 --- a/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs +++ b/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs @@ -80,6 +80,23 @@ public virtual Task> GetChannelAsync ); } + /// + public virtual Task SetVoiceChannelStatusAsync + ( + Snowflake channelID, + Optional status, + Optional reason = default, + CancellationToken ct = default + ) + { + return this.RestHttpClient.PatchAsync + ( + $"channels/{channelID}/voice-status", + b => b.WithRateLimitContext(this.RateLimitCache), + ct: ct + ); + } + /// public virtual async Task> ModifyChannelAsync ( @@ -270,7 +287,6 @@ public virtual Task> ModifyGuildVoiceChannelAsync Optional parentID = default, Optional rtcRegion = default, Optional videoQualityMode = default, - Optional status = default, Optional reason = default, CancellationToken ct = default ) @@ -288,7 +304,6 @@ public virtual Task> ModifyGuildVoiceChannelAsync parentID: parentID, rtcRegion: rtcRegion, videoQualityMode: videoQualityMode, - status: status, reason: reason, ct: ct ); From 0a22fc89bfa4566515d772567f6489b0dbe798a8 Mon Sep 17 00:00:00 2001 From: Velvet Toroyashi <42438262+VelvetToroyashi@users.noreply.github.com> Date: Wed, 6 Sep 2023 23:20:33 -0400 Subject: [PATCH 5/6] fix: Remove erroneous call and perform validation --- .../API/Rest/IDiscordRestChannelAPI.cs | 2 -- .../API/CachingDiscordRestChannelAPI.cs | 1 - .../API/Channels/DiscordRestChannelAPI.cs | 14 ++++++-------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs b/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs index b2f1d36db7..9e6aea54d5 100644 --- a/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs +++ b/Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestChannelAPI.cs @@ -107,7 +107,6 @@ Task SetVoiceChannelStatusAsync /// The tags applied to the thread. /// The default sort order of posts. /// The default layout of posts in a forum. - /// The new status of the voice channel. /// The reason to mark the action in the audit log with. /// The cancellation token for this operation. /// A modification result which may or may not have succeeded. @@ -139,7 +138,6 @@ Task> ModifyChannelAsync Optional> appliedTags = default, Optional defaultSortOrder = default, Optional defaultForumLayout = default, - Optional status = default, Optional reason = default, CancellationToken ct = default ); diff --git a/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs b/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs index 722be43ed4..08b9629482 100644 --- a/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs +++ b/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs @@ -117,7 +117,6 @@ public async Task> ModifyChannelAsync Optional> appliedTags = default, Optional defaultSortOrder = default, Optional defaultForumLayout = default, - Optional status = default, Optional reason = default, CancellationToken ct = default ) diff --git a/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs b/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs index 971dde588d..33be7ea2cb 100644 --- a/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs +++ b/Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs @@ -89,10 +89,15 @@ public virtual Task SetVoiceChannelStatusAsync CancellationToken ct = default ) { + if (status is { HasValue: true, Value: { Length: > 500 } }) + { + return Task.FromResult(new ArgumentOutOfRangeError(nameof(status), "The status must between 0 and 500 characters.")); + } + return this.RestHttpClient.PatchAsync ( $"channels/{channelID}/voice-status", - b => b.WithRateLimitContext(this.RateLimitCache), + b => b.WithJson(b => b.Write("status", status, this.JsonOptions)).WithRateLimitContext(this.RateLimitCache), ct: ct ); } @@ -126,7 +131,6 @@ public virtual async Task> ModifyChannelAsync Optional> appliedTags = default, Optional defaultSortOrder = default, Optional defaultForumLayout = default, - Optional status = default, Optional reason = default, CancellationToken ct = default ) @@ -173,11 +177,6 @@ public virtual async Task> ModifyChannelAsync return Result.FromError(packImage); } - if (status is { HasValue: true, Value: { Length: > 500 } }) - { - return new ArgumentOutOfRangeError(nameof(status), "The status must between 0 and 500 characters."); - } - Optional base64EncodedIcon = packImage.Entity!; return await this.RestHttpClient.PatchAsync @@ -219,7 +218,6 @@ public virtual async Task> ModifyChannelAsync json.Write("applied_tags", appliedTags, this.JsonOptions); json.Write("default_sort_order", defaultSortOrder, this.JsonOptions); json.Write("default_forum_layout", defaultForumLayout, this.JsonOptions); - json.Write("status", status, this.JsonOptions); } ) .WithRateLimitContext(this.RateLimitCache), From 947581ad4426f068669efc0a4454066399dfe912 Mon Sep 17 00:00:00 2001 From: Velvet Toroyashi <42438262+VelvetToroyashi@users.noreply.github.com> Date: Thu, 2 May 2024 13:56:11 -0400 Subject: [PATCH 6/6] fix: remove status from method --- .../Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs b/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs index b1ed35b7df..0682190055 100644 --- a/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs +++ b/Backend/Remora.Discord.Caching/API/CachingDiscordRestChannelAPI.cs @@ -149,7 +149,6 @@ public async Task> ModifyChannelAsync appliedTags, defaultSortOrder, defaultForumLayout, - status, reason, ct );