Skip to content

Commit

Permalink
feat(?): Implement voice status API correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
VelvetToroyashi committed Sep 6, 2023
1 parent dc91351 commit c22ca67
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ public interface IDiscordRestChannelAPI
/// <returns>A retrieval result which may or may not have succeeded.</returns>
Task<Result<IChannel>> GetChannelAsync(Snowflake channelID, CancellationToken ct = default);

/// <summary>
/// Sets the status of a given voice channel.
/// </summary>
/// <param name="channelID">The ID of the channel.</param>
/// <param name="status">The status to set.</param>
/// <param name="reason">The reason to mark the action in the audit log with.</param>
/// <param name="ct">The cancellation token for this operation.</param>
/// <returns>A modification result that may or not have succeeded.</returns>
Task<Result> SetVoiceChannelStatusAsync
(
Snowflake channelID,
Optional<string> status,
Optional<string> reason = default,
CancellationToken ct = default
);

/// <summary>
/// Modifies the given channel.
/// </summary>
Expand Down Expand Up @@ -199,7 +215,6 @@ Task<Result<IChannel>> ModifyGuildTextChannelAsync
/// <param name="parentID">The new parent category ID.</param>
/// <param name="rtcRegion">The channel's voice region. Automatic when null.</param>
/// <param name="videoQualityMode">The new video quality mode.</param>
/// <param name="status">The new status for the channel.</param>
/// <param name="reason">The reason to mark the action in the audit log with.</param>
/// <param name="ct">The cancellation token for this operation.</param>
/// <returns>A modification result which may or may not have succeeded.</returns>
Expand All @@ -216,7 +231,6 @@ Task<Result<IChannel>> ModifyGuildVoiceChannelAsync
Optional<Snowflake?> parentID = default,
Optional<string?> rtcRegion = default,
Optional<VideoQualityMode?> videoQualityMode = default,
Optional<string?> status = default,
Optional<string> reason = default,
CancellationToken ct = default
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ namespace Remora.Discord.Caching.API;

public partial class CachingDiscordRestChannelAPI
{
/// <inheritdoc />
public Task<Result> SetVoiceChannelStatusAsync
(
Snowflake channelID,
Optional<string> status,
Optional<string> reason = default,
CancellationToken ct = default
)
{
return _actual.SetVoiceChannelStatusAsync(channelID, status, reason, ct);
}

/// <inheritdoc />
public Task<Result<IChannel>> ModifyGroupDMChannelAsync
(
Expand Down Expand Up @@ -95,7 +107,6 @@ public Task<Result<IChannel>> ModifyGuildVoiceChannelAsync
Optional<Snowflake?> parentId = default,
Optional<string?> rtcRegion = default,
Optional<VideoQualityMode?> videoQualityMode = default,
Optional<string?> status = default,
Optional<string> reason = default,
CancellationToken ct = default
)
Expand All @@ -113,7 +124,6 @@ public Task<Result<IChannel>> ModifyGuildVoiceChannelAsync
parentId,
rtcRegion,
videoQualityMode,
status,
reason,
ct
);
Expand Down
19 changes: 17 additions & 2 deletions Backend/Remora.Discord.Rest/API/Channels/DiscordRestChannelAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ public virtual Task<Result<IChannel>> GetChannelAsync
);
}

/// <inheritdoc />
public virtual Task<Result> SetVoiceChannelStatusAsync
(
Snowflake channelID,
Optional<string> status,
Optional<string> reason = default,
CancellationToken ct = default
)
{
return this.RestHttpClient.PatchAsync
(
$"channels/{channelID}/voice-status",
b => b.WithRateLimitContext(this.RateLimitCache),
ct: ct
);
}

/// <inheritdoc />
public virtual async Task<Result<IChannel>> ModifyChannelAsync
(
Expand Down Expand Up @@ -270,7 +287,6 @@ public virtual Task<Result<IChannel>> ModifyGuildVoiceChannelAsync
Optional<Snowflake?> parentID = default,
Optional<string?> rtcRegion = default,
Optional<VideoQualityMode?> videoQualityMode = default,
Optional<string?> status = default,
Optional<string> reason = default,
CancellationToken ct = default
)
Expand All @@ -288,7 +304,6 @@ public virtual Task<Result<IChannel>> ModifyGuildVoiceChannelAsync
parentID: parentID,
rtcRegion: rtcRegion,
videoQualityMode: videoQualityMode,
status: status,
reason: reason,
ct: ct
);
Expand Down

0 comments on commit c22ca67

Please sign in to comment.