Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add voice channel statuses #312

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// IVoiceChannelStatusUpdate.cs
//
// Author:
// Jarl Gullberg <jarl.gullberg@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
//

using Remora.Rest.Core;

namespace Remora.Discord.API.Abstractions.Gateway.Events;

/// <summary>
/// Represents an update to the respective voice channel.
/// </summary>
public interface IVoiceChannelStatusUpdate
VelvetToroyashi marked this conversation as resolved.
Show resolved Hide resolved
{
/// <summary>
/// Gets the ID of the channel being updated.
/// </summary>
Snowflake ID { get; }

Check notice

Code scanning / InspectCode

Type member is never used: Non-private accessibility Note

Property 'ID' is never used

/// <summary>
/// Gets the ID of the guild.
/// </summary>
Snowflake GuildID { get; }

Check notice

Code scanning / InspectCode

Type member is never used: Non-private accessibility Note

Property 'GuildID' is never used

/// <summary>
/// Gets the new status of the voice channel.
/// </summary>
Optional<string> Status { get; }

Check notice

Code scanning / InspectCode

Type member is never used: Non-private accessibility Note

Property 'Status' is never used
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ public interface IChannel : IPartialChannel
/// </summary>
new Optional<ForumLayout> DefaultForumLayout { get; }

/// <summary>
/// Gets the status of the channel.
/// </summary>
new Optional<string?> Status { get; }

/// <inheritdoc/>
Optional<Snowflake> IPartialChannel.ID => this.ID;

Expand Down Expand Up @@ -316,4 +321,7 @@ public interface IChannel : IPartialChannel

/// <inheritdoc/>
Optional<ForumLayout> IPartialChannel.DefaultForumLayout => this.DefaultForumLayout;

/// <inheritdoc/>
Optional<string?> IPartialChannel.Status => this.Status;
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,7 @@ public interface IPartialChannel

/// <inheritdoc cref="IChannel.DefaultForumLayout" />
Optional<ForumLayout> DefaultForumLayout { get; }

/// <inheritdoc cref="IChannel.Status"/>
Optional<string?> Status { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ public enum DiscordPermission
/// </summary>
UseSoundboard = 42,

/// <summary>
/// Allows for creating emojis, stickers, and soundboard sounds, independently of managing them.
/// </summary>
CreateGuildExpressions = 43,

/// <summary>
/// Allows the usage of custom soundboard sounds from other servers.
/// </summary>
Expand All @@ -261,5 +266,15 @@ public enum DiscordPermission
/// <summary>
/// Allows for sending voice messages.
/// </summary>
SendVoiceMessages = 46
SendVoiceMessages = 46,

/// <summary>
/// Allows for interaction with Clyde (AI).
/// </summary>
UseClydeAi = 47,

/// <summary>
/// Allows for setting the status of a voice channel.
/// </summary>
SetVoiceChannelStatus = 48
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public interface IDiscordRestChannelAPI
/// <param name="appliedTags">The tags applied to the thread.</param>
/// <param name="defaultSortOrder">The default sort order of posts.</param>
/// <param name="defaultForumLayout">The default layout of posts in a forum.</param>
/// <param name="status">The new status of the voice 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 Down Expand Up @@ -122,6 +123,7 @@ Task<Result<IChannel>> ModifyChannelAsync
Optional<IReadOnlyList<Snowflake>> appliedTags = default,
Optional<SortOrder> defaultSortOrder = default,
Optional<ForumLayout> defaultForumLayout = default,
Optional<string?> status = default,
Optional<string> reason = default,
CancellationToken ct = default
);
Expand Down Expand Up @@ -197,6 +199,7 @@ 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 @@ -213,6 +216,7 @@ 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 @@ -67,5 +67,6 @@ public record ChannelCreate
Optional<IDefaultReaction?> DefaultReactionEmoji = default,
Optional<TimeSpan> DefaultThreadRateLimitPerUser = default,
Optional<SortOrder?> DefaultSortOrder = default,
Optional<ForumLayout> DefaultForumLayout = default
Optional<ForumLayout> DefaultForumLayout = default,
Optional<string?> Status = default
) : IChannelCreate;
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ public record ChannelDelete
Optional<IDefaultReaction?> DefaultReactionEmoji = default,
Optional<TimeSpan> DefaultThreadRateLimitPerUser = default,
Optional<SortOrder?> DefaultSortOrder = default,
Optional<ForumLayout> DefaultForumLayout = default
Optional<ForumLayout> DefaultForumLayout = default,
Optional<string?> Status = default
) : IChannelDelete;
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ public record ChannelUpdate
Optional<IDefaultReaction?> DefaultReactionEmoji = default,
Optional<TimeSpan> DefaultThreadRateLimitPerUser = default,
Optional<SortOrder?> DefaultSortOrder = default,
Optional<ForumLayout> DefaultForumLayout = default
Optional<ForumLayout> DefaultForumLayout = default,
Optional<string?> Status = default
) : IChannelUpdate;
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ public record ThreadCreate
Optional<IDefaultReaction?> DefaultReactionEmoji = default,
Optional<TimeSpan> DefaultThreadRateLimitPerUser = default,
Optional<SortOrder?> DefaultSortOrder = default,
Optional<ForumLayout> DefaultForumLayout = default
Optional<ForumLayout> DefaultForumLayout = default,
Optional<string?> Status = default
) : IThreadCreate;
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ public record ThreadDelete
Optional<IDefaultReaction?> DefaultReactionEmoji = default,
Optional<TimeSpan> DefaultThreadRateLimitPerUser = default,
Optional<SortOrder?> DefaultSortOrder = default,
Optional<ForumLayout> DefaultForumLayout = default
Optional<ForumLayout> DefaultForumLayout = default,
Optional<string?> Status = default
) : IThreadDelete;
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ public record ThreadUpdate
Optional<IDefaultReaction?> DefaultReactionEmoji = default,
Optional<TimeSpan> DefaultThreadRateLimitPerUser = default,
Optional<SortOrder?> DefaultSortOrder = default,
Optional<ForumLayout> DefaultForumLayout = default
Optional<ForumLayout> DefaultForumLayout = default,
Optional<string?> Status = default
) : IThreadUpdate;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// VoiceChannelStatusUpdate.cs
//
// Author:
// Jarl Gullberg <jarl.gullberg@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
//

using Remora.Discord.API.Abstractions.Gateway.Events;
using Remora.Rest.Core;

namespace Remora.Discord.API.Gateway.Events.Channels;

/// <inheritdoc cref="Remora.Discord.API.Abstractions.Gateway.Events.IVoiceChannelStatusUpdate"/>
public record VoiceChannelStatusUpdate

Check notice

Code scanning / InspectCode

Type is never used: Non-private accessibility Note

Record 'VoiceChannelStatusUpdate' is never used
(
Snowflake ID,
Snowflake GuildID,
Optional<string> Status
) : IVoiceChannelStatusUpdate;
3 changes: 2 additions & 1 deletion Backend/Remora.Discord.API/API/Objects/Channels/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ public record Channel
Optional<IDefaultReaction?> DefaultReactionEmoji = default,
Optional<TimeSpan> DefaultThreadRateLimitPerUser = default,
Optional<SortOrder?> DefaultSortOrder = default,
Optional<ForumLayout> DefaultForumLayout = default
Optional<ForumLayout> DefaultForumLayout = default,
Optional<string?> Status = default
) : IChannel;
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ public record PartialChannel
Optional<IDefaultReaction?> DefaultReactionEmoji = default,
Optional<TimeSpan> DefaultThreadRateLimitPerUser = default,
Optional<SortOrder?> DefaultSortOrder = default,
Optional<ForumLayout> DefaultForumLayout = default
Optional<ForumLayout> DefaultForumLayout = default,
Optional<string?> Status = default
) : IPartialChannel;
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ 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 @@ -112,6 +113,7 @@ public Task<Result<IChannel>> ModifyGuildVoiceChannelAsync
parentId,
rtcRegion,
videoQualityMode,
status,
reason,
ct
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ CacheService cacheService
Optional<IReadOnlyList<Snowflake>> appliedTags = default,
Optional<SortOrder> defaultSortOrder = default,
Optional<ForumLayout> defaultForumLayout = default,
Optional<string?> status = default,
Optional<string> reason = default,
CancellationToken ct = default
)
Expand Down Expand Up @@ -149,6 +150,7 @@ CacheService cacheService
appliedTags,
defaultSortOrder,
defaultForumLayout,
status,
reason,
ct
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public virtual Task<Result<IChannel>> GetChannelAsync
Optional<IReadOnlyList<Snowflake>> appliedTags = default,
Optional<SortOrder> defaultSortOrder = default,
Optional<ForumLayout> defaultForumLayout = default,
Optional<string?> status = default,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModifyChannelAsync should not be modified as it is not meant to be used for setting the voice channel status by documentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swear I removed that. Bwah

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dw, there are many Modify...Channel calls

Optional<string> reason = default,
CancellationToken ct = default
)
Expand Down Expand Up @@ -155,6 +156,11 @@ public virtual Task<Result<IChannel>> GetChannelAsync
return Result<IChannel>.FromError(packImage);
}

if (status is { HasValue: true, Value: { Length: > 500 } })
{
return new ArgumentOutOfRangeError(nameof(status), "The status must between 0 and 500 characters.");
}

Optional<string> base64EncodedIcon = packImage.Entity!;

return await this.RestHttpClient.PatchAsync<IChannel>
Expand Down Expand Up @@ -196,6 +202,7 @@ public virtual Task<Result<IChannel>> GetChannelAsync
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),
Expand Down Expand Up @@ -263,6 +270,7 @@ 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 @@ -280,6 +288,7 @@ public virtual Task<Result<IChannel>> ModifyGuildVoiceChannelAsync
parentID: parentID,
rtcRegion: rtcRegion,
videoQualityMode: videoQualityMode,
status: status,
reason: reason,
ct: ct
);
Expand Down
Loading