Readded outgoing audio

This commit is contained in:
RogueException
2016-12-30 00:41:29 -04:00
parent c9a12cde10
commit 2877653a09
15 changed files with 257 additions and 65 deletions

View File

@@ -1,6 +1,10 @@
namespace Discord.WebSocket
using Discord.Audio;
using System.Threading.Tasks;
namespace Discord.WebSocket
{
public interface ISocketAudioChannel : IAudioChannel
{
Task<IAudioClient> ConnectAsync();
}
}

View File

@@ -1,4 +1,5 @@
using Discord.Rest;
using Discord.Audio;
using Discord.Rest;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -64,6 +65,11 @@ namespace Discord.WebSocket
public Task LeaveAsync(RequestOptions options = null)
=> ChannelHelper.DeleteAsync(this, Discord, options);
public Task<IAudioClient> ConnectAsync()
{
throw new NotSupportedException("Voice is not yet supported for group channels.");
}
//Messages
public SocketMessage GetCachedMessage(ulong id)
=> _messages?.Get(id);

View File

@@ -41,6 +41,17 @@ namespace Discord.WebSocket
public Task ModifyAsync(Action<VoiceChannelProperties> func, RequestOptions options = null)
=> ChannelHelper.ModifyAsync(this, Discord, func, options);
public async Task<IAudioClient> ConnectAsync()
{
var audioMode = Discord.AudioMode;
if (audioMode == AudioMode.Disabled)
throw new InvalidOperationException($"Audio is not enabled on this client, {nameof(DiscordSocketConfig.AudioMode)} in {nameof(DiscordSocketConfig)} must be set.");
return await Guild.ConnectAudioAsync(Id,
(audioMode & AudioMode.Incoming) == 0,
(audioMode & AudioMode.Outgoing) == 0).ConfigureAwait(false);
}
public override SocketGuildUser GetUser(ulong id)
{
var user = Guild.GetUser(id);
@@ -52,9 +63,6 @@ namespace Discord.WebSocket
private string DebuggerDisplay => $"{Name} ({Id}, Voice)";
internal new SocketVoiceChannel Clone() => MemberwiseClone() as SocketVoiceChannel;
//IVoiceChannel
Task<IAudioClient> IVoiceChannel.ConnectAsync() { throw new NotSupportedException(); }
//IGuildChannel
Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
=> Task.FromResult<IGuildUser>(GetUser(id));