-
Notifications
You must be signed in to change notification settings - Fork 46
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
base: main
Are you sure you want to change the base?
Changes from all commits
2212473
e8ed217
dc91351
c22ca67
0a22fc8
ebbc19d
947581a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// IVoiceChannelStatusUpdate.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// 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 : IGatewayEvent | ||
{ | ||
/// <summary> | ||
/// Gets the ID of the channel being updated. | ||
/// </summary> | ||
Snowflake ID { get; } | ||
|
||
/// <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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// VoiceChannelStatusUpdate.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// 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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,28 @@ | |
); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public virtual Task<Result> SetVoiceChannelStatusAsync | ||
( | ||
Snowflake channelID, | ||
Optional<string> status, | ||
Optional<string> reason = default, | ||
CancellationToken ct = default | ||
) | ||
{ | ||
if (status is { HasValue: true, Value: { Length: > 500 } }) | ||
Check notice Code scanning / InspectCode Merge nested property patterns Note
Merge nested property patterns
|
||
{ | ||
return Task.FromResult<Result>(new ArgumentOutOfRangeError(nameof(status), "The status must between 0 and 500 characters.")); | ||
} | ||
|
||
return this.RestHttpClient.PatchAsync | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't exist on the non-generic methods it seems. cc @Nihlus There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the check about status length here |
||
( | ||
$"channels/{channelID}/voice-status", | ||
b => b.WithJson(b => b.Write("status", status, this.JsonOptions)).WithRateLimitContext(this.RateLimitCache), | ||
Check warning Code scanning / InspectCode Variable in local function hides variable from outer scope Warning
Parameter 'b' hides outer parameter with the same name
|
||
ct: ct | ||
); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public virtual async Task<Result<IChannel>> ModifyChannelAsync | ||
( | ||
|
Check notice
Code scanning / InspectCode
Type member is never used: Non-private accessibility Note