/// <summary> /// Set the Volume of this Player /// </summary> /// <param name="volume">The Volume to set the player to, Volume may range from 0 to 1000. 100 is default.</param> /// <returns>Task</returns> public Task SetVolumeAsync(int volume) => Node.SendAsync(new VolumePacket { OPCode = "volume", GuildID = GuildID.ToString(), Volume = volume });
/// <summary> /// Seek to a position on this Player /// </summary> /// <param name="position">The position to seek to, in ms</param> /// <returns>Task</returns> public Task SeekAsync(long position) => Node.SendAsync(new SeekPacket { OPCode = "seek", GuildID = GuildID.ToString(), Position = position });
/// <summary> /// Sends an VoiceUpdate to Lavalink for this Player /// </summary> /// <param name="sessionID">The SessionID of this VoiceUpdate</param> /// <param name="event">The VoiceServer event of this VoiceUpdate</param> /// <returns>Task</returns> public Task VoiceUpdateAsync(string sessionID, VoiceServerUpdatePayload @event) => Node.SendAsync(new VoiceUpdatePacket { OPCode = "voiceUpdate", GuildID = GuildID.ToString(), UpdateEvent = @event, SessionID = sessionID });
/// <summary> /// Lets the Bot Leave the Current Connected Channel by sending an Packet to <see cref="LavalinkNode.DiscordSendFunction"/> /// </summary> /// <returns>Task</returns> public Task LeaveAsync() => Node.DiscordSendFunction(GuildID, new UpdateVoiceStateDispatch { GuildId = GuildID.ToString(), ChannelId = null, SelfMute = false, SelfDeaf = false });
public void Save() { using (var Session = DatabaseHandler.Store.OpenSession(DatabaseHandler.DBName)) { Session.Store(this, GuildID.ToString()); Session.SaveChanges(); } }
/// <summary> /// Lets the Bot Join a Channel by sending an Packet to <see cref="LavalinkNode.DiscordSendFunction"/> /// </summary> /// <param name="channelID">The ID of the Channel to join</param> /// <param name="mute">if the bot should be muted</param> /// <param name="deaf">if the bot should be deafen</param> /// <returns>Task</returns> public Task JoinAsync(long channelID, bool mute = false, bool deaf = false) => Node.DiscordSendFunction(GuildID, new UpdateVoiceStateDispatch { GuildId = GuildID.ToString(), ChannelId = channelID.ToString(), SelfMute = mute, SelfDeaf = deaf });
/// <summary> /// Method to set the Volume /// </summary> /// <param name="volume"> the volume to set</param> /// <returns> Task resolving with void. </returns> public Task SetVolumeAsync(int volume) { return(_client.Websocket.SendMessageAsync(JsonConvert.SerializeObject(new VolumePacket { OPCode = "volume", GuildID = GuildID.ToString(), Volume = volume }))); }
/// <summary> /// Method to Seek to a specified position. /// </summary> /// <param name="position"> position to seek to</param> /// <returns> Task resolving with void. </returns> public Task SeekAsync(int position) { return(_client.Websocket.SendMessageAsync(JsonConvert.SerializeObject(new SeekPacket { OPCode = "seek", GuildID = GuildID.ToString(), Position = position }))); }
/// <summary> /// Resumes Playing on this Player /// </summary> /// <returns>Task</returns> public async Task ResumeAsync() { await Node.SendAsync(new PausePacket { OPCode = "pause", GuildID = GuildID.ToString(), Pause = false }); Status = PlayerStatus.PLAYING; }
/// <summary> /// Pauses this Player /// </summary> /// <returns>Task</returns> public async Task PauseAsync() { await Node.SendAsync(new PausePacket { OPCode = "pause", GuildID = GuildID.ToString(), Pause = true }); Status = PlayerStatus.PAUSED; }
/// <summary> /// Method to call on Discord Voice Updates /// </summary> /// <param name="sessionID"> The SessionID </param> /// <param name="voiceEvent"> The VoiceEvent </param> /// <returns> Task resolving with void. </returns> public Task VoiceUpdateAsync(string sessionID, VoiceServerUpdate voiceEvent) { return(_client.Websocket.SendMessageAsync(JsonConvert.SerializeObject(new VoiceUpdatePacket { OPCode = "voiceUpdate", SessionID = sessionID, UpdateEvent = voiceEvent, GuildID = GuildID.ToString() }))); }
// <summary> /// Method to stop the current track from the player /// <returns> Task resolving with void. </returns> public async Task StopAsync() { await _client.Websocket.SendMessageAsync(JsonConvert.SerializeObject(new StopPacket { OPCode = "stop", Stop = true, GuildID = GuildID.ToString() })); Status = Status.STOPPED; }
/// <summary> /// Destroys this Player and removes it from the Node /// </summary> /// <returns>Task</returns> public async Task DestroyAsync() { await Node.SendAsync(new PlayerPacket { OPCode = "destroy", GuildID = GuildID.ToString() }); Status = PlayerStatus.ENDED; Node.Players.TryRemove(GuildID, out _); Node.VoiceServers.TryRemove(GuildID, out _); Node.VoiceStates.TryRemove(GuildID, out _); }
/// <summary> /// Starts to Play a Track on this Player /// </summary> /// <param name="track">The Track string to play</param> /// <param name="start">The Start time, defaults to 0</param> /// <param name="end">The End time, defaults to 0</param> /// <returns>Task</returns> public async Task PlayAsync(string track, int? start = 0, int? end = 0) { await Node.SendAsync(new PlayPacket { OPCode = "play", GuildID = GuildID.ToString(), Track = track, StartTime = start.ToString(), EndTime = end.ToString() }); Status = PlayerStatus.PLAYING; }
/// <summary> /// Method to let the player start a track /// </summary> /// <param name="track"> Track instance of the track to play. </param> /// <param name="start"> optional: start time of the track</param> /// <param name="end"> optional: end time of the track</param> /// <returns> Task resolving with void. </returns> public async Task PlayAsync(Track track, int?start = 0, int?end = 0) { await _client.Websocket.SendMessageAsync(JsonConvert.SerializeObject(new PlayPacket { OPCode = "play", GuildID = GuildID.ToString(), Track = track.TrackString, StartTime = start.ToString(), EndTime = end.ToString() })); Status = Status.PLAYING; }
/// <summary> /// Method to pause/resume the player /// </summary> /// <param name="pause"> boolean </param> /// <returns> Task resolving with void. </returns> public async Task PauseAsync(bool pause = true) { await _client.Websocket.SendMessageAsync(JsonConvert.SerializeObject(new PausePacket { OPCode = "pause", Pause = pause, GuildID = GuildID.ToString() })); if (pause) { Status = Status.PAUSED; } else { Status = Status.PLAYING; } }
public override void CheckForFile() { // eg. "g_262726242036350976.xml" if (!File.Exists(BasePath + FileName)) { GuildConfig config = new GuildConfig(GuildID.ToString()); config.GuildID = config.GuildID; config.DungeonCombatLog = "\u200B\n\u200B\n\u200B\n\u200B\n\u200B"; config.Save(); } else { GuildConfig config = Load() as GuildConfig; config.Save(); } }
/// <summary> /// Stops the Player /// </summary> /// <returns>Task</returns> public Task StopAsync() => Node.SendAsync(new PlayerPacket { OPCode = "stop", GuildID = GuildID.ToString() });