public AudioPlayer(DiscordVoiceConfig __config) { config = __config; callbackInfo = WaveCallbackInfo.FunctionCallback(); outputDevice = new WaveOut(callbackInfo); bufferedWaveProvider = new BufferedWaveProvider(new WaveFormat(48000, 16, config.Channels)); }
public DiscordVoiceClient(DiscordClient parentClient, DiscordVoiceConfig config, DiscordChannel channel) { _parent = parentClient; VoiceConfig = config; Channel = channel; InitializeOpusEncoder(); }
public override void Install(CommandsManager manager) { manager.AddCommand(new CommandStub("yt", "Streams a YouTube Video. Lewd.", "", PermissionType.Owner, 1, cmdArgs => { if (cmdArgs.Args[0].Length > 0) { string url = cmdArgs.Args[0]; var youtube = YouTube.Default; var video = youtube.GetVideo(url); if (video.AudioFormat == AudioFormat.Mp3 || video.AudioFormat == AudioFormat.Vorbis) { SendVoice("", manager.Client, video); } else cmdArgs.Channel.SendMessage($"Tell Axiom not to get lazy and support other audio codecs besides MP3! (This was in {video.AudioFormat})"); } else cmdArgs.Channel.SendMessage($"wrong"); }), this); manager.AddCommand(new CommandStub("disconnect", "Disconnects from voice", "", PermissionType.Owner, 1, cmdArgs => { manager.Client.DisconnectFromVoice(); }), this); manager.AddCommand(new CommandStub("testvoice", "Broadcasts specified file over voice.", "", PermissionType.Owner, 1, cmdArgs => { if (File.Exists(cmdArgs.Args[0])) { if (manager.Client.ConnectedToVoice()) SendVoice(cmdArgs.Args[0], manager.Client); else cmdArgs.Channel.SendMessage("Not connected to voice!"); } else cmdArgs.Channel.SendMessage("Couldn't broadcast specified file! It doesn't exist!"); }), this); manager.AddCommand(new CommandStub("joinvoice", "Joins a specified voice channel", "Arg is case insensitive voice channel name to join.", PermissionType.Owner, 1, cmdArgs => { DiscordChannel channelToJoin = cmdArgs.Channel.Parent.Channels.Find(x => x.Name.ToLower() == cmdArgs.Args[0].ToLower() && x.Type == ChannelType.Voice); if (channelToJoin != null) { DiscordVoiceConfig config = new DiscordVoiceConfig { FrameLengthMs = 60, Channels = 1, OpusMode = DiscordSharp.Voice.OpusApplication.MusicOrMixed, SendOnly = true }; //waveFormat = new WaveFormat(48000, 16, config.Channels); //if (!config.SendOnly) //{ // waveCallbackInfo = WaveCallbackInfo.FunctionCallback(); // outputDevice = new WaveOut(); //} manager.Client.ConnectToVoiceChannel(channelToJoin, config); } else cmdArgs.Channel.SendMessage("Couldn't find the specified channel as a voice channel!"); }), this); manager.AddCommand(new CommandStub("stop", "Stops current voice without disconnecting.", "", PermissionType.Owner, cmdArgs => { if (manager.Client.GetVoiceClient() != null) { manager.Client.GetVoiceClient().ClearVoiceQueue(); } }), this); }
/// <summary> /// Connects to a given voice channel. /// </summary> /// <param name="channel">The channel to connect to. </param> /// <param name="voiceConfig">The voice configuration to use. If null, default values will be used.</param> /// <param name="clientMuted">Whether or not the client will connect muted. Defaults to false.</param> /// <param name="clientDeaf">Whether or not the client will connect deaf. Defaults to false.</param> public void ConnectToVoiceChannel(DiscordChannel channel, DiscordVoiceConfig voiceConfig = null, bool clientMuted = false, bool clientDeaf = false) { if (channel.Type != ChannelType.Voice) throw new InvalidOperationException($"Channel '{channel.ID}' is not a voice channel!"); if (ConnectedToVoice()) DisconnectFromVoice(); if (VoiceClient == null) { if (voiceConfig == null) { VoiceClient = new DiscordVoiceClient(this, new DiscordVoiceConfig()); } else VoiceClient = new DiscordVoiceClient(this, voiceConfig); } VoiceClient.Channel = channel; VoiceClient.ErrorReceived += (sender, e) => { if (GetLastVoiceClientLogger != null) { GetLastVoiceClientLogger = VoiceClient.GetDebugLogger; DisconnectFromVoice(); } }; VoiceClient.UserSpeaking += (sender, e) => { if (UserSpeaking != null) UserSpeaking(this, e); }; VoiceClient.VoiceConnectionComplete += (sender, e) => { if (VoiceClientConnected != null) VoiceClientConnected(this, e); }; VoiceClient.QueueEmpty += (sender, e) => { VoiceQueueEmpty?.Invoke(this, e); }; string joinVoicePayload = JsonConvert.SerializeObject(new { op = 4, d = new { guild_id = channel.Parent.ID, channel_id = channel.ID, self_mute = clientMuted, self_deaf = clientDeaf } }); ws.Send(joinVoicePayload); }
public DiscordVoiceClient(DiscordClient parentClient, DiscordVoiceConfig config) { _parent = parentClient; VoiceConfig = config; InitializeOpusEncoder(); }
public DiscordVoiceClient(DiscordClient parentClient) { _parent = parentClient; VoiceConfig = new DiscordVoiceConfig(); InitializeOpusEncoder(); }
public DiscordVoiceClient(DiscordClient parentClient, DiscordVoiceConfig config, DiscordChannel channel) { _parent = parentClient; VoiceConfig = config; Channel = channel; }
public DiscordVoiceClient(DiscordClient parentClient, DiscordVoiceConfig config) { _parent = parentClient; VoiceConfig = config; }
public DiscordVoiceClient(DiscordClient parentClient) { _parent = parentClient; VoiceConfig = new DiscordVoiceConfig(); }