/// <summary> /// Block a song /// </summary> /// <param name="p_Service">Chat service</param> /// <param name="p_Message">Chat message</param> /// <param name="p_ID">ID of the BSR</param> private void Command_Block(IChatService p_Service, IChatMessage p_Message, string p_ID) { if (!HasPower(p_Message.Sender)) { SendChatMessage($"@{p_Message.Sender.UserName} You have no power here!"); return; } string l_Key = p_ID.ToLower(); if (!OnlyHexInString(l_Key)) { SendChatMessage($"@{p_Message.Sender.UserName} Invalid key!"); return; } lock (SongBlackList) { var l_BeatMap = SongBlackList.Where(x => x.BeatMap.Key.ToLower() == l_Key).FirstOrDefault(); if (l_BeatMap != null) { SendChatMessage($"@{p_Message.Sender.UserName} (bsr {l_BeatMap.BeatMap.Key}) {l_BeatMap.BeatMap.Metadata.SongName} / {l_BeatMap.BeatMap.Metadata.LevelAuthorName} is already blacklisted!"); return; } } /// Fetch beatmap _ = m_BeatSaver.Key(l_Key).ContinueWith(p_SongTaskResult => { try { string l_Reply = "@" + p_Message.Sender.UserName + " map " + l_Key + " not found."; if (p_SongTaskResult.Result != null) { var l_BeatMap = p_SongTaskResult.Result; l_Reply = $"@{p_Message.Sender.UserName} (bsr {l_BeatMap.Key}) {l_BeatMap.Metadata.SongName} / {l_BeatMap.Metadata.LevelAuthorName} is now blacklisted!"; lock (SongQueue) { lock (SongHistory) { lock (SongBlackList) { SongQueue.RemoveAll(x => x.BeatMap.Key == l_BeatMap.Key); SongHistory.RemoveAll(x => x.BeatMap.Key == l_BeatMap.Key); /// Add to blacklist SongBlackList.RemoveAll(x => x.BeatMap.Hash == l_BeatMap.Hash); SongBlackList.Insert(0, new SongEntry() { BeatMap = l_BeatMap, NamePrefix = "🗡", RequesterName = p_Message.Sender.DisplayName }); } } } /// Update request manager OnQueueChanged(); } SendChatMessage(l_Reply); } catch (System.Exception p_Exception) { Logger.Instance.Error("Command_Block"); Logger.Instance.Error(p_Exception); } }); }