| @@ -70,6 +70,51 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| Task StopStageAsync(RequestOptions options = null); | Task StopStageAsync(RequestOptions options = null); | ||||
| /// <summary> | |||||
| /// Indicates that the bot would like to speak within a stage channel. | |||||
| /// </summary> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous request to speak operation. | |||||
| /// </returns> | |||||
| Task RequestToSpeak(RequestOptions options = null); | Task RequestToSpeak(RequestOptions options = null); | ||||
| /// <summary> | |||||
| /// Makes the current user become a speaker within a stage. | |||||
| /// </summary> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous speaker modify operation. | |||||
| /// </returns> | |||||
| Task BecomeSpeakerAsync(RequestOptions options = null); | |||||
| /// <summary> | |||||
| /// Makes the current user a listener. | |||||
| /// </summary> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous stop operation. | |||||
| /// </returns> | |||||
| Task StopSpeakingAsync(RequestOptions options = null); | |||||
| /// <summary> | |||||
| /// Makes a user a speaker within a stage. | |||||
| /// </summary> | |||||
| /// <param name="user">The user to make the speaker.</param> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous move operation. | |||||
| /// </returns> | |||||
| Task MoveToSpeaker(IGuildUser user, RequestOptions options = null); | |||||
| /// <summary> | |||||
| /// Removes a user from speaking. | |||||
| /// </summary> | |||||
| /// <param name="user">The user to remove from speaking.</param> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A task that represents the asynchronous remove operation. | |||||
| /// </returns> | |||||
| Task RemoveFromSpeaker(IGuildUser user, RequestOptions options = null); | |||||
| } | } | ||||
| } | } | ||||
| @@ -646,6 +646,18 @@ namespace Discord.API | |||||
| await SendJsonAsync("PATCH", () => $"guilds/{guildId}/voice-states/@me", args, bucket, options: options).ConfigureAwait(false); | await SendJsonAsync("PATCH", () => $"guilds/{guildId}/voice-states/@me", args, bucket, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task ModifyUserVoiceState(ulong guildId, ulong userId, ModifyVoiceStateParams args, RequestOptions options = null) | |||||
| { | |||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||||
| Preconditions.NotEqual(userId, 0, nameof(userId)); | |||||
| options = RequestOptions.CreateOrClone(options); | |||||
| var bucket = new BucketIds(); | |||||
| await SendJsonAsync("PATCH", () => $"guilds/{guildId}/voice-states/{userId}", args, bucket, options: options).ConfigureAwait(false); | |||||
| } | |||||
| // roles | // roles | ||||
| public async Task AddRoleAsync(ulong guildId, ulong userId, ulong roleId, RequestOptions options = null) | public async Task AddRoleAsync(ulong guildId, ulong userId, ulong roleId, RequestOptions options = null) | ||||
| { | { | ||||
| @@ -105,5 +105,51 @@ namespace Discord.Rest | |||||
| }; | }; | ||||
| return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | ||||
| } | } | ||||
| /// <inheritdoc/> | |||||
| public Task BecomeSpeakerAsync(RequestOptions options = null) | |||||
| { | |||||
| var args = new API.Rest.ModifyVoiceStateParams() | |||||
| { | |||||
| ChannelId = this.Id, | |||||
| Suppressed = false | |||||
| }; | |||||
| return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | |||||
| } | |||||
| /// <inheritdoc/> | |||||
| public Task StopSpeakingAsync(RequestOptions options = null) | |||||
| { | |||||
| var args = new API.Rest.ModifyVoiceStateParams() | |||||
| { | |||||
| ChannelId = this.Id, | |||||
| Suppressed = true | |||||
| }; | |||||
| return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | |||||
| } | |||||
| /// <inheritdoc/> | |||||
| public Task MoveToSpeaker(IGuildUser user, RequestOptions options = null) | |||||
| { | |||||
| var args = new API.Rest.ModifyVoiceStateParams() | |||||
| { | |||||
| ChannelId = this.Id, | |||||
| Suppressed = false | |||||
| }; | |||||
| return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args); | |||||
| } | |||||
| /// <inheritdoc/> | |||||
| public Task RemoveFromSpeaker(IGuildUser user, RequestOptions options = null) | |||||
| { | |||||
| var args = new API.Rest.ModifyVoiceStateParams() | |||||
| { | |||||
| ChannelId = this.Id, | |||||
| Suppressed = true | |||||
| }; | |||||
| return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -27,6 +27,12 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public bool Live { get; private set; } = false; | public bool Live { get; private set; } = false; | ||||
| /// <summary> | |||||
| /// Returns <see langword="true"/> if the current user is a speaker within the stage, otherwise <see langword="false"/>. | |||||
| /// </summary> | |||||
| public bool IsSpeaker | |||||
| => !Guild.CurrentUser.IsSuppressed; | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of users who are speakers within the stage. | /// Gets a collection of users who are speakers within the stage. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -112,5 +118,51 @@ namespace Discord.WebSocket | |||||
| }; | }; | ||||
| return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | ||||
| } | } | ||||
| /// <inheritdoc/> | |||||
| public Task BecomeSpeakerAsync(RequestOptions options = null) | |||||
| { | |||||
| var args = new API.Rest.ModifyVoiceStateParams() | |||||
| { | |||||
| ChannelId = this.Id, | |||||
| Suppressed = false | |||||
| }; | |||||
| return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | |||||
| } | |||||
| /// <inheritdoc/> | |||||
| public Task StopSpeakingAsync(RequestOptions options = null) | |||||
| { | |||||
| var args = new API.Rest.ModifyVoiceStateParams() | |||||
| { | |||||
| ChannelId = this.Id, | |||||
| Suppressed = true | |||||
| }; | |||||
| return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | |||||
| } | |||||
| /// <inheritdoc/> | |||||
| public Task MoveToSpeaker(IGuildUser user, RequestOptions options = null) | |||||
| { | |||||
| var args = new API.Rest.ModifyVoiceStateParams() | |||||
| { | |||||
| ChannelId = this.Id, | |||||
| Suppressed = false | |||||
| }; | |||||
| return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args); | |||||
| } | |||||
| /// <inheritdoc/> | |||||
| public Task RemoveFromSpeaker(IGuildUser user, RequestOptions options = null) | |||||
| { | |||||
| var args = new API.Rest.ModifyVoiceStateParams() | |||||
| { | |||||
| ChannelId = this.Id, | |||||
| Suppressed = true | |||||
| }; | |||||
| return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||